Skip to content

Commit

Permalink
Added Gate end point for Notification alert service (#479)
Browse files Browse the repository at this point in the history
* Added Gate end point for Notification alert service

* added port number and edited changes related to notification controller and service class

* added id for put api call

* corrected config name

* corrected config name

* corrected config name in gate config

* Removed Logs and Print statement from the code
  • Loading branch information
vivek-opsmx authored Sep 3, 2024
1 parent dddc335 commit 1e55df1
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docker_build/gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ services:
visibility:
baseUrl: http://localhost:8096
enabled: true
notifications:
baseUrl: http://localhost:8099
enabled: true
auditservice:
baseUrl: http://localhost:8097
enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import com.opsmx.spinnaker.gate.services.OpsmxAuditClientService
import com.opsmx.spinnaker.gate.services.OpsmxAuditService
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.apache.camel.spi.annotations.Component
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.beans.factory.annotation.Value
Expand Down Expand Up @@ -187,6 +186,12 @@ class GateConfig extends RedisHttpSessionConfiguration {
createClient "clouddriver", ClouddriverService
}

@Bean
@ConditionalOnProperty("services.notifications.enabled")
OpsmxNotificationsAlertservice opsmxNotificationsAlertservice(OkHttpClientProvider clientProvider) {
createClient "notifications", OpsmxNotificationsAlertservice
}

@Bean
@ConditionalOnProperty("services.keel.enabled")
KeelService keelService(OkHttpClientProvider clientProvider) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright 2024 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.gate.controllers

import com.netflix.spinnaker.gate.services.internal.OpsmxNotificationsAlertservice
import groovy.util.logging.Slf4j
import io.swagger.v3.oas.annotations.Operation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RestController



@RequestMapping("/notifications")
@RestController
@Slf4j
@ConditionalOnExpression('${services.notifications.enabled:false}')
class OpsmxNotificationsAlertController {

@Autowired
OpsmxNotificationsAlertservice opsmxNotificationsAlertservice

@Operation(summary = "Endpoint for notification rest services")
@RequestMapping(value = "/{type}", method = RequestMethod.POST)
Object postNotificationServiceResponse1(@PathVariable("type") String type,
@RequestBody(required = false) Object data) {
return opsmxNotificationsAlertservice.postNotificationServiceResponse1(type, data)
}

@Operation(summary = "Endpoint for notification rest services")
@RequestMapping(value = "/{type}/{id}", method = RequestMethod.PUT)
Object putNotificationServiceResponse1(@PathVariable("type") String type,
@PathVariable("id") String id,
@RequestBody(required = false) Object data) {
return opsmxNotificationsAlertservice.putNotificationServiceResponse2(type,id, data)
}

@Operation(summary = "Endpoint for notification services")
@RequestMapping(value = "/{type}", method = RequestMethod.GET)
Object getNotificationServiceResponse1(@PathVariable("type") String type) {
return opsmxNotificationsAlertservice.getNotificationServiceResponse3(type)
}

@Operation(summary = "Endpoint for notification rest services")
@RequestMapping(value = "/{type}/{id}", method = RequestMethod.DELETE)
Object deleteNotificationServiceResponse1(@PathVariable("type") String type,
@PathVariable("id") String id) {
return opsmxNotificationsAlertservice.deleteNotificationServiceResponse4(type,id)
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2024 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.gate.services.internal

import retrofit.http.*

interface OpsmxNotificationsAlertservice {

@POST("/notifications/{type}")
Object postNotificationServiceResponse1(@Path('type') String type,
@Body Object data)

@PUT("/notifications/{type}/{id}")
Object putNotificationServiceResponse2(@Path('type') String type,
@Path('id') String id,
@Body Object data)

@GET("/notifications/{type}")
Object getNotificationServiceResponse3(@Path('type') String type)

@DELETE("/notifications/{type}/{id}")
Object deleteNotificationServiceResponse4(@Path('type') String type,
@Path('id') String id)

}

0 comments on commit 1e55df1

Please sign in to comment.