diff --git a/harness/nextgen/api_srm_notification.go b/harness/nextgen/api_srm_notification.go index 4f1f4ac8..125096be 100644 --- a/harness/nextgen/api_srm_notification.go +++ b/harness/nextgen/api_srm_notification.go @@ -43,13 +43,13 @@ SaveSrmNotification saves srm notification data @return NotificationRuleResponse */ -func (a *SrmNotificationApiService) SaveSrmNotification(ctx context.Context, accountId string, localVarOptionals *SrmNotificationServiceSaveSrmNotificationOpts) (NotificationRuleResponse, *http.Response, error) { +func (a *SrmNotificationApiService) SaveSrmNotification(ctx context.Context, accountId string, localVarOptionals *SrmNotificationServiceSaveSrmNotificationOpts) (RestResponseSrmNotificationResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Post") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - localVarReturnValue NotificationRuleResponse + localVarReturnValue RestResponseSrmNotificationResponse ) // create path and map variables @@ -153,13 +153,13 @@ GetSrmNotification get srm notirication data @return NotificationRuleResponse */ -func (a *SrmNotificationApiService) GetSrmNotification(ctx context.Context, identifier string, accountId string, orgIdentifier string, projectIdentifier string) (NotificationRuleResponse, *http.Response, error) { +func (a *SrmNotificationApiService) GetSrmNotification(ctx context.Context, identifier string, accountId string, orgIdentifier string, projectIdentifier string) (RestResponseSrmNotificationResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Get") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - localVarReturnValue NotificationRuleResponse + localVarReturnValue RestResponseSrmNotificationResponse ) // create path and map variables @@ -254,19 +254,21 @@ func (a *SrmNotificationApiService) GetSrmNotification(ctx context.Context, iden UpdateSrmNotification updates srm notification data - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param accountId + - @param orgIdentifier + - @param projectIdentifier - @param identifier - @param optional nil or *SrmNotificationApiUpdateSrmNotificationOpts - Optional Parameters: - @param "Body" (optional.Interface of NotificationRule) - @return NotificationRuleResponse */ -func (a *SrmNotificationApiService) UpdateSrmNotification(ctx context.Context, accountId string, identifier string, localVarOptionals *SrmNotificationApiUpdateSrmNotificationOpts) (NotificationRuleResponse, *http.Response, error) { +func (a *SrmNotificationApiService) UpdateSrmNotification(ctx context.Context, accountId string, orgIdentifier string, projectIdentifier string, identifier string, localVarOptionals *SrmNotificationApiUpdateSrmNotificationOpts) (RestResponseSrmNotificationResponse, *http.Response, error) { var ( localVarHttpMethod = strings.ToUpper("Put") localVarPostBody interface{} localVarFileName string localVarFileBytes []byte - localVarReturnValue NotificationRuleResponse + localVarReturnValue RestResponseSrmNotificationResponse ) // create path and map variables @@ -280,6 +282,8 @@ func (a *SrmNotificationApiService) UpdateSrmNotification(ctx context.Context, a localVarHeaderParams["Harness-Account"] = a.client.cfg.AccountId localVarQueryParams.Add("accountId", parameterToString(accountId, "")) + localVarQueryParams.Add("orgIdentifier", parameterToString(orgIdentifier, "")) + localVarQueryParams.Add("projectIdentifier", parameterToString(projectIdentifier, "")) // to determine the Content-Type header localVarHttpContentTypes := []string{"application/json"} diff --git a/harness/nextgen/client.go b/harness/nextgen/client.go index d36ecb88..24801da8 100644 --- a/harness/nextgen/client.go +++ b/harness/nextgen/client.go @@ -295,6 +295,7 @@ func NewAPIClient(cfg *Configuration) *APIClient { c.ServicesApi = (*ServicesApiService)(&c.common) c.ServiceOverridesApi = (*ServiceOverridesApiService)(&c.common) c.SloApi = (*SloApiService)(&c.common) + c.SrmNotificationApiService = (*SrmNotificationApiService)(&c.common) c.SourceCodeManagerApi = (*SourceCodeManagerApiService)(&c.common) c.TargetGroupsApi = (*TargetGroupsApiService)(&c.common) c.TargetsApi = (*TargetsApiService)(&c.common) diff --git a/harness/nextgen/model_kubernetes_dependency_metadata.go b/harness/nextgen/model_kubernetes_dependency_metadata.go index 19d799da..aeed67ee 100644 --- a/harness/nextgen/model_kubernetes_dependency_metadata.go +++ b/harness/nextgen/model_kubernetes_dependency_metadata.go @@ -10,7 +10,6 @@ package nextgen type KubernetesDependencyMetadata struct { - Type_ string `json:"type"` Namespace string `json:"namespace"` - Workload string `json:"workload"` + Workload string `json:"workload"` } diff --git a/harness/nextgen/model_service_dependency_metadata.go b/harness/nextgen/model_rest_response_srm_notification_response.go similarity index 62% rename from harness/nextgen/model_service_dependency_metadata.go rename to harness/nextgen/model_rest_response_srm_notification_response.go index 3cfa001b..d8dece6d 100644 --- a/harness/nextgen/model_service_dependency_metadata.go +++ b/harness/nextgen/model_rest_response_srm_notification_response.go @@ -9,7 +9,8 @@ */ package nextgen -type ServiceDependencyMetadata struct { - Type_ DependencyMetadataType `json:"type,omitempty"` - KUBERNETES *KubernetesDependencyMetadata `json:"-"` +type RestResponseSrmNotificationResponse struct { + MetaData map[string]interface{} `json:"metaData,omitempty"` + Resource *NotificationRuleResponse `json:"resource,omitempty"` + ResponseMessages []ResponseMessage `json:"responseMessages,omitempty"` } diff --git a/harness/nextgen/model_service_dependency_dto.go b/harness/nextgen/model_service_dependency_dto.go index 8a6729c9..1e9ff0f6 100644 --- a/harness/nextgen/model_service_dependency_dto.go +++ b/harness/nextgen/model_service_dependency_dto.go @@ -9,7 +9,13 @@ */ package nextgen +import "encoding/json" + type ServiceDependencyDto struct { - MonitoredServiceIdentifier string `json:"monitoredServiceIdentifier,omitempty"` - DependencyMetadata *ServiceDependencyMetadata `json:"dependencyMetadata,omitempty"` + MonitoredServiceIdentifier string `json:"monitoredServiceIdentifier,omitempty"` + + Type_ DependencyMetadataType `json:"type,omitempty"` + KUBERNETES *KubernetesDependencyMetadata `json:"-"` + + DependencyMetadata json.RawMessage `json:"dependencyMetadata"` } diff --git a/harness/nextgen/model_service_dependency_dto_serializer.go b/harness/nextgen/model_service_dependency_dto_serializer.go new file mode 100644 index 00000000..9d1d7f51 --- /dev/null +++ b/harness/nextgen/model_service_dependency_dto_serializer.go @@ -0,0 +1,53 @@ +package nextgen + +import ( + "encoding/json" + "fmt" +) + +func (a *ServiceDependencyDto) UnmarshalJSON(data []byte) error { + + type Alias ServiceDependencyDto + + aux := &struct { + *Alias + }{ + Alias: (*Alias)(a), + } + + err := json.Unmarshal(data, &aux) + if err != nil { + return err + } + + switch a.Type_ { + case DependencyMetadataTypes.KUBERNETES: + err = json.Unmarshal(aux.DependencyMetadata, &a.KUBERNETES) + default: + panic(fmt.Sprintf("unknown dependency metadata type %s", a.Type_)) + } + + return err +} + +func (a *ServiceDependencyDto) MarshalJSON() ([]byte, error) { + type Alias ServiceDependencyDto + + var dependencyMetadata []byte + var err error + + switch a.Type_ { + case DependencyMetadataTypes.KUBERNETES: + dependencyMetadata, err = json.Marshal(a.KUBERNETES) + default: + panic(fmt.Sprintf("unknown dependency metadata type %s", a.Type_)) + } + + if err != nil { + return nil, err + } + + a.DependencyMetadata = dependencyMetadata + + return json.Marshal((*Alias)(a)) +}