From be575f4c9495e2b74391541137e1661dedcfbe59 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Wed, 16 Apr 2025 09:21:36 +0000 Subject: [PATCH 1/2] Generate observability --- services/observability/api_default.go | 1003 +++++++++++++++-- services/observability/api_default_test.go | 286 +++++ .../model_create_logs_alertgroups_payload.go | 222 ++++ .../model_update_logs_alertgroup_payload.go | 177 +++ 4 files changed, 1579 insertions(+), 109 deletions(-) create mode 100644 services/observability/model_create_logs_alertgroups_payload.go create mode 100644 services/observability/model_update_logs_alertgroup_payload.go diff --git a/services/observability/api_default.go b/services/observability/api_default.go index 6cdd9dda2..0c1205dbd 100644 --- a/services/observability/api_default.go +++ b/services/observability/api_default.go @@ -928,6 +928,160 @@ func (a *APIClient) CreateInstanceExecute(ctx context.Context, projectId string) return r.Execute() } +type ApiCreateLogsAlertgroupsRequest struct { + ctx context.Context + apiService *DefaultApiService + instanceId string + projectId string + createLogsAlertgroupsPayload *CreateLogsAlertgroupsPayload +} + +func (r ApiCreateLogsAlertgroupsRequest) CreateLogsAlertgroupsPayload(createLogsAlertgroupsPayload CreateLogsAlertgroupsPayload) ApiCreateLogsAlertgroupsRequest { + r.createLogsAlertgroupsPayload = &createLogsAlertgroupsPayload + return r +} + +func (r ApiCreateLogsAlertgroupsRequest) Execute() (*AlertGroupsResponse, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *AlertGroupsResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.CreateLogsAlertgroups") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups" + localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.createLogsAlertgroupsPayload == nil { + return localVarReturnValue, fmt.Errorf("createLogsAlertgroupsPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.createLogsAlertgroupsPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v PermissionDenied + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +CreateLogsAlertgroups: Method for CreateLogsAlertgroups + +Create logs alert group config. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param instanceId + @param projectId + @return ApiCreateLogsAlertgroupsRequest +*/ +func (a *APIClient) CreateLogsAlertgroups(ctx context.Context, instanceId string, projectId string) ApiCreateLogsAlertgroupsRequest { + return ApiCreateLogsAlertgroupsRequest{ + apiService: a.defaultApi, + ctx: ctx, + instanceId: instanceId, + projectId: projectId, + } +} + +func (a *APIClient) CreateLogsAlertgroupsExecute(ctx context.Context, instanceId string, projectId string) (*AlertGroupsResponse, error) { + r := ApiCreateLogsAlertgroupsRequest{ + apiService: a.defaultApi, + ctx: ctx, + instanceId: instanceId, + projectId: projectId, + } + return r.Execute() +} + type ApiCreateScrapeConfigRequest struct { ctx context.Context apiService *DefaultApiService @@ -2291,30 +2445,30 @@ func (a *APIClient) DeleteInstanceExecute(ctx context.Context, instanceId string return r.Execute() } -type ApiDeleteScrapeConfigRequest struct { +type ApiDeleteLogsAlertgroupRequest struct { ctx context.Context apiService *DefaultApiService + groupName string instanceId string - jobName string projectId string } -func (r ApiDeleteScrapeConfigRequest) Execute() (*DeleteScrapeConfigResponse, error) { +func (r ApiDeleteLogsAlertgroupRequest) Execute() (*AlertGroupsResponse, error) { var ( localVarHTTPMethod = http.MethodDelete localVarPostBody interface{} formFiles []formFile - localVarReturnValue *DeleteScrapeConfigResponse + localVarReturnValue *AlertGroupsResponse ) a := r.apiService - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteScrapeConfig") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteLogsAlertgroup") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/scrapeconfigs/{jobName}" + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups/{groupName}" + localVarPath = strings.Replace(localVarPath, "{"+"groupName"+"}", url.PathEscape(ParameterValueToString(r.groupName, "groupName")), -1) localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"jobName"+"}", url.PathEscape(ParameterValueToString(r.jobName, "jobName")), -1) localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) localVarHeaderParams := make(map[string]string) @@ -2370,6 +2524,17 @@ func (r ApiDeleteScrapeConfigRequest) Execute() (*DeleteScrapeConfigResponse, er Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 400 { + var v Message + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } if localVarHTTPResponse.StatusCode == 403 { var v PermissionDenied err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) @@ -2408,62 +2573,62 @@ func (r ApiDeleteScrapeConfigRequest) Execute() (*DeleteScrapeConfigResponse, er } /* -DeleteScrapeConfig: Method for DeleteScrapeConfig +DeleteLogsAlertgroup: Method for DeleteLogsAlertgroup -Delete scrape config. +Delete logs alert group config. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param groupName @param instanceId - @param jobName @param projectId - @return ApiDeleteScrapeConfigRequest + @return ApiDeleteLogsAlertgroupRequest */ -func (a *APIClient) DeleteScrapeConfig(ctx context.Context, instanceId string, jobName string, projectId string) ApiDeleteScrapeConfigRequest { - return ApiDeleteScrapeConfigRequest{ +func (a *APIClient) DeleteLogsAlertgroup(ctx context.Context, groupName string, instanceId string, projectId string) ApiDeleteLogsAlertgroupRequest { + return ApiDeleteLogsAlertgroupRequest{ apiService: a.defaultApi, ctx: ctx, + groupName: groupName, instanceId: instanceId, - jobName: jobName, projectId: projectId, } } -func (a *APIClient) DeleteScrapeConfigExecute(ctx context.Context, instanceId string, jobName string, projectId string) (*DeleteScrapeConfigResponse, error) { - r := ApiDeleteScrapeConfigRequest{ +func (a *APIClient) DeleteLogsAlertgroupExecute(ctx context.Context, groupName string, instanceId string, projectId string) (*AlertGroupsResponse, error) { + r := ApiDeleteLogsAlertgroupRequest{ apiService: a.defaultApi, ctx: ctx, + groupName: groupName, instanceId: instanceId, - jobName: jobName, projectId: projectId, } return r.Execute() } -type ApiGetAlertConfigReceiverRequest struct { +type ApiDeleteScrapeConfigRequest struct { ctx context.Context apiService *DefaultApiService instanceId string + jobName string projectId string - receiver string } -func (r ApiGetAlertConfigReceiverRequest) Execute() (*Receiver, error) { +func (r ApiDeleteScrapeConfigRequest) Execute() (*DeleteScrapeConfigResponse, error) { var ( - localVarHTTPMethod = http.MethodGet + localVarHTTPMethod = http.MethodDelete localVarPostBody interface{} formFiles []formFile - localVarReturnValue *Receiver + localVarReturnValue *DeleteScrapeConfigResponse ) a := r.apiService - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetAlertConfigReceiver") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.DeleteScrapeConfig") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/alertconfigs/receivers/{receiver}" + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/scrapeconfigs/{jobName}" localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"jobName"+"}", url.PathEscape(ParameterValueToString(r.jobName, "jobName")), -1) localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"receiver"+"}", url.PathEscape(ParameterValueToString(r.receiver, "receiver")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -2556,38 +2721,38 @@ func (r ApiGetAlertConfigReceiverRequest) Execute() (*Receiver, error) { } /* -GetAlertConfigReceiver: Method for GetAlertConfigReceiver +DeleteScrapeConfig: Method for DeleteScrapeConfig -Get alert config receivers. +Delete scrape config. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param instanceId + @param jobName @param projectId - @param receiver - @return ApiGetAlertConfigReceiverRequest + @return ApiDeleteScrapeConfigRequest */ -func (a *APIClient) GetAlertConfigReceiver(ctx context.Context, instanceId string, projectId string, receiver string) ApiGetAlertConfigReceiverRequest { - return ApiGetAlertConfigReceiverRequest{ +func (a *APIClient) DeleteScrapeConfig(ctx context.Context, instanceId string, jobName string, projectId string) ApiDeleteScrapeConfigRequest { + return ApiDeleteScrapeConfigRequest{ apiService: a.defaultApi, ctx: ctx, instanceId: instanceId, + jobName: jobName, projectId: projectId, - receiver: receiver, } } -func (a *APIClient) GetAlertConfigReceiverExecute(ctx context.Context, instanceId string, projectId string, receiver string) (*Receiver, error) { - r := ApiGetAlertConfigReceiverRequest{ +func (a *APIClient) DeleteScrapeConfigExecute(ctx context.Context, instanceId string, jobName string, projectId string) (*DeleteScrapeConfigResponse, error) { + r := ApiDeleteScrapeConfigRequest{ apiService: a.defaultApi, ctx: ctx, instanceId: instanceId, + jobName: jobName, projectId: projectId, - receiver: receiver, } return r.Execute() } -type ApiGetAlertConfigRouteRequest struct { +type ApiGetAlertConfigReceiverRequest struct { ctx context.Context apiService *DefaultApiService instanceId string @@ -2595,20 +2760,20 @@ type ApiGetAlertConfigRouteRequest struct { receiver string } -func (r ApiGetAlertConfigRouteRequest) Execute() (*AlertConfigRouteResponse, error) { +func (r ApiGetAlertConfigReceiverRequest) Execute() (*Receiver, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *AlertConfigRouteResponse + localVarReturnValue *Receiver ) a := r.apiService - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetAlertConfigRoute") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetAlertConfigReceiver") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/alertconfigs/routes/{receiver}" + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/alertconfigs/receivers/{receiver}" localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) localVarPath = strings.Replace(localVarPath, "{"+"receiver"+"}", url.PathEscape(ParameterValueToString(r.receiver, "receiver")), -1) @@ -2675,6 +2840,17 @@ func (r ApiGetAlertConfigRouteRequest) Execute() (*AlertConfigRouteResponse, err } newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Message + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v } return localVarReturnValue, newErr } @@ -2693,18 +2869,18 @@ func (r ApiGetAlertConfigRouteRequest) Execute() (*AlertConfigRouteResponse, err } /* -GetAlertConfigRoute: Method for GetAlertConfigRoute +GetAlertConfigReceiver: Method for GetAlertConfigReceiver -Get alert receiver for route. +Get alert config receivers. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param instanceId @param projectId @param receiver - @return ApiGetAlertConfigRouteRequest + @return ApiGetAlertConfigReceiverRequest */ -func (a *APIClient) GetAlertConfigRoute(ctx context.Context, instanceId string, projectId string, receiver string) ApiGetAlertConfigRouteRequest { - return ApiGetAlertConfigRouteRequest{ +func (a *APIClient) GetAlertConfigReceiver(ctx context.Context, instanceId string, projectId string, receiver string) ApiGetAlertConfigReceiverRequest { + return ApiGetAlertConfigReceiverRequest{ apiService: a.defaultApi, ctx: ctx, instanceId: instanceId, @@ -2713,8 +2889,8 @@ func (a *APIClient) GetAlertConfigRoute(ctx context.Context, instanceId string, } } -func (a *APIClient) GetAlertConfigRouteExecute(ctx context.Context, instanceId string, projectId string, receiver string) (*AlertConfigRouteResponse, error) { - r := ApiGetAlertConfigRouteRequest{ +func (a *APIClient) GetAlertConfigReceiverExecute(ctx context.Context, instanceId string, projectId string, receiver string) (*Receiver, error) { + r := ApiGetAlertConfigReceiverRequest{ apiService: a.defaultApi, ctx: ctx, instanceId: instanceId, @@ -2724,29 +2900,31 @@ func (a *APIClient) GetAlertConfigRouteExecute(ctx context.Context, instanceId s return r.Execute() } -type ApiGetAlertConfigsRequest struct { +type ApiGetAlertConfigRouteRequest struct { ctx context.Context apiService *DefaultApiService instanceId string projectId string + receiver string } -func (r ApiGetAlertConfigsRequest) Execute() (*GetAlertConfigsResponse, error) { +func (r ApiGetAlertConfigRouteRequest) Execute() (*AlertConfigRouteResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *GetAlertConfigsResponse + localVarReturnValue *AlertConfigRouteResponse ) a := r.apiService - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetAlertConfigs") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetAlertConfigRoute") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/alertconfigs" + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/alertconfigs/routes/{receiver}" localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"receiver"+"}", url.PathEscape(ParameterValueToString(r.receiver, "receiver")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -2828,15 +3006,150 @@ func (r ApiGetAlertConfigsRequest) Execute() (*GetAlertConfigsResponse, error) { } /* -GetAlertConfigs: Method for GetAlertConfigs +GetAlertConfigRoute: Method for GetAlertConfigRoute -Get alert config. +Get alert receiver for route. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param instanceId @param projectId - @return ApiGetAlertConfigsRequest -*/ + @param receiver + @return ApiGetAlertConfigRouteRequest +*/ +func (a *APIClient) GetAlertConfigRoute(ctx context.Context, instanceId string, projectId string, receiver string) ApiGetAlertConfigRouteRequest { + return ApiGetAlertConfigRouteRequest{ + apiService: a.defaultApi, + ctx: ctx, + instanceId: instanceId, + projectId: projectId, + receiver: receiver, + } +} + +func (a *APIClient) GetAlertConfigRouteExecute(ctx context.Context, instanceId string, projectId string, receiver string) (*AlertConfigRouteResponse, error) { + r := ApiGetAlertConfigRouteRequest{ + apiService: a.defaultApi, + ctx: ctx, + instanceId: instanceId, + projectId: projectId, + receiver: receiver, + } + return r.Execute() +} + +type ApiGetAlertConfigsRequest struct { + ctx context.Context + apiService *DefaultApiService + instanceId string + projectId string +} + +func (r ApiGetAlertConfigsRequest) Execute() (*GetAlertConfigsResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetAlertConfigsResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetAlertConfigs") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/alertconfigs" + localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 { + var v PermissionDenied + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +GetAlertConfigs: Method for GetAlertConfigs + +Get alert config. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param instanceId + @param projectId + @return ApiGetAlertConfigsRequest +*/ func (a *APIClient) GetAlertConfigs(ctx context.Context, instanceId string, projectId string) ApiGetAlertConfigsRequest { return ApiGetAlertConfigsRequest{ apiService: a.defaultApi, @@ -3586,6 +3899,165 @@ func (a *APIClient) GetInstanceExecute(ctx context.Context, instanceId string, p return r.Execute() } +type ApiGetLogsAlertgroupRequest struct { + ctx context.Context + apiService *DefaultApiService + groupName string + instanceId string + projectId string +} + +func (r ApiGetLogsAlertgroupRequest) Execute() (*AlertGroupResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *AlertGroupResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.GetLogsAlertgroup") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups/{groupName}" + localVarPath = strings.Replace(localVarPath, "{"+"groupName"+"}", url.PathEscape(ParameterValueToString(r.groupName, "groupName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Message + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v PermissionDenied + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Message + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +GetLogsAlertgroup: Method for GetLogsAlertgroup + +Get logs alert group config. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param groupName + @param instanceId + @param projectId + @return ApiGetLogsAlertgroupRequest +*/ +func (a *APIClient) GetLogsAlertgroup(ctx context.Context, groupName string, instanceId string, projectId string) ApiGetLogsAlertgroupRequest { + return ApiGetLogsAlertgroupRequest{ + apiService: a.defaultApi, + ctx: ctx, + groupName: groupName, + instanceId: instanceId, + projectId: projectId, + } +} + +func (a *APIClient) GetLogsAlertgroupExecute(ctx context.Context, groupName string, instanceId string, projectId string) (*AlertGroupResponse, error) { + r := ApiGetLogsAlertgroupRequest{ + apiService: a.defaultApi, + ctx: ctx, + groupName: groupName, + instanceId: instanceId, + projectId: projectId, + } + return r.Execute() +} + type ApiGetMetricsStorageRetentionRequest struct { ctx context.Context apiService *DefaultApiService @@ -4366,57 +4838,192 @@ func (r ApiListAlertgroupsRequest) Execute() (*AlertGroupsResponse, error) { } /* -ListAlertgroups: Method for ListAlertgroups +ListAlertgroups: Method for ListAlertgroups + +Get alert groups. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param instanceId + @param projectId + @return ApiListAlertgroupsRequest +*/ +func (a *APIClient) ListAlertgroups(ctx context.Context, instanceId string, projectId string) ApiListAlertgroupsRequest { + return ApiListAlertgroupsRequest{ + apiService: a.defaultApi, + ctx: ctx, + instanceId: instanceId, + projectId: projectId, + } +} + +func (a *APIClient) ListAlertgroupsExecute(ctx context.Context, instanceId string, projectId string) (*AlertGroupsResponse, error) { + r := ApiListAlertgroupsRequest{ + apiService: a.defaultApi, + ctx: ctx, + instanceId: instanceId, + projectId: projectId, + } + return r.Execute() +} + +type ApiListAlertrulesRequest struct { + ctx context.Context + apiService *DefaultApiService + groupName string + instanceId string + projectId string +} + +func (r ApiListAlertrulesRequest) Execute() (*AlertRulesResponse, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *AlertRulesResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListAlertrules") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/alertgroups/{groupName}/alertrules" + localVarPath = strings.Replace(localVarPath, "{"+"groupName"+"}", url.PathEscape(ParameterValueToString(r.groupName, "groupName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 { + var v PermissionDenied + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +ListAlertrules: Method for ListAlertrules -Get alert groups. +Get alert rules. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param groupName @param instanceId @param projectId - @return ApiListAlertgroupsRequest + @return ApiListAlertrulesRequest */ -func (a *APIClient) ListAlertgroups(ctx context.Context, instanceId string, projectId string) ApiListAlertgroupsRequest { - return ApiListAlertgroupsRequest{ +func (a *APIClient) ListAlertrules(ctx context.Context, groupName string, instanceId string, projectId string) ApiListAlertrulesRequest { + return ApiListAlertrulesRequest{ apiService: a.defaultApi, ctx: ctx, + groupName: groupName, instanceId: instanceId, projectId: projectId, } } -func (a *APIClient) ListAlertgroupsExecute(ctx context.Context, instanceId string, projectId string) (*AlertGroupsResponse, error) { - r := ApiListAlertgroupsRequest{ +func (a *APIClient) ListAlertrulesExecute(ctx context.Context, groupName string, instanceId string, projectId string) (*AlertRulesResponse, error) { + r := ApiListAlertrulesRequest{ apiService: a.defaultApi, ctx: ctx, + groupName: groupName, instanceId: instanceId, projectId: projectId, } return r.Execute() } -type ApiListAlertrulesRequest struct { +type ApiListCredentialsRequest struct { ctx context.Context apiService *DefaultApiService - groupName string instanceId string projectId string } -func (r ApiListAlertrulesRequest) Execute() (*AlertRulesResponse, error) { +func (r ApiListCredentialsRequest) Execute() (*ListCredentialsResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *AlertRulesResponse + localVarReturnValue *ListCredentialsResponse ) a := r.apiService - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListAlertrules") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCredentials") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/alertgroups/{groupName}/alertrules" - localVarPath = strings.Replace(localVarPath, "{"+"groupName"+"}", url.PathEscape(ParameterValueToString(r.groupName, "groupName")), -1) + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/credentials" localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) @@ -4500,59 +5107,54 @@ func (r ApiListAlertrulesRequest) Execute() (*AlertRulesResponse, error) { } /* -ListAlertrules: Method for ListAlertrules +ListCredentials: Method for ListCredentials -Get alert rules. +Get all technical user credentials. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param groupName @param instanceId @param projectId - @return ApiListAlertrulesRequest + @return ApiListCredentialsRequest */ -func (a *APIClient) ListAlertrules(ctx context.Context, groupName string, instanceId string, projectId string) ApiListAlertrulesRequest { - return ApiListAlertrulesRequest{ +func (a *APIClient) ListCredentials(ctx context.Context, instanceId string, projectId string) ApiListCredentialsRequest { + return ApiListCredentialsRequest{ apiService: a.defaultApi, ctx: ctx, - groupName: groupName, instanceId: instanceId, projectId: projectId, } } -func (a *APIClient) ListAlertrulesExecute(ctx context.Context, groupName string, instanceId string, projectId string) (*AlertRulesResponse, error) { - r := ApiListAlertrulesRequest{ +func (a *APIClient) ListCredentialsExecute(ctx context.Context, instanceId string, projectId string) (*ListCredentialsResponse, error) { + r := ApiListCredentialsRequest{ apiService: a.defaultApi, ctx: ctx, - groupName: groupName, instanceId: instanceId, projectId: projectId, } return r.Execute() } -type ApiListCredentialsRequest struct { +type ApiListInstancesRequest struct { ctx context.Context apiService *DefaultApiService - instanceId string projectId string } -func (r ApiListCredentialsRequest) Execute() (*ListCredentialsResponse, error) { +func (r ApiListInstancesRequest) Execute() (*ListInstancesResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *ListCredentialsResponse + localVarReturnValue *ListInstancesResponse ) a := r.apiService - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListCredentials") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListInstances") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/credentials" - localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) + localVarPath := localBasePath + "/v1/projects/{projectId}/instances" localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) localVarHeaderParams := make(map[string]string) @@ -4635,54 +5237,53 @@ func (r ApiListCredentialsRequest) Execute() (*ListCredentialsResponse, error) { } /* -ListCredentials: Method for ListCredentials +ListInstances: Method for ListInstances -Get all technical user credentials. +Get all instances for a project. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param instanceId @param projectId - @return ApiListCredentialsRequest + @return ApiListInstancesRequest */ -func (a *APIClient) ListCredentials(ctx context.Context, instanceId string, projectId string) ApiListCredentialsRequest { - return ApiListCredentialsRequest{ +func (a *APIClient) ListInstances(ctx context.Context, projectId string) ApiListInstancesRequest { + return ApiListInstancesRequest{ apiService: a.defaultApi, ctx: ctx, - instanceId: instanceId, projectId: projectId, } } -func (a *APIClient) ListCredentialsExecute(ctx context.Context, instanceId string, projectId string) (*ListCredentialsResponse, error) { - r := ApiListCredentialsRequest{ +func (a *APIClient) ListInstancesExecute(ctx context.Context, projectId string) (*ListInstancesResponse, error) { + r := ApiListInstancesRequest{ apiService: a.defaultApi, ctx: ctx, - instanceId: instanceId, projectId: projectId, } return r.Execute() } -type ApiListInstancesRequest struct { +type ApiListLogsAlertgroupsRequest struct { ctx context.Context apiService *DefaultApiService + instanceId string projectId string } -func (r ApiListInstancesRequest) Execute() (*ListInstancesResponse, error) { +func (r ApiListLogsAlertgroupsRequest) Execute() (*AlertGroupsResponse, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue *ListInstancesResponse + localVarReturnValue *AlertGroupsResponse ) a := r.apiService - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListInstances") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.ListLogsAlertgroups") if err != nil { return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/v1/projects/{projectId}/instances" + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups" + localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) localVarHeaderParams := make(map[string]string) @@ -4738,6 +5339,17 @@ func (r ApiListInstancesRequest) Execute() (*ListInstancesResponse, error) { Body: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } + if localVarHTTPResponse.StatusCode == 400 { + var v Error + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } if localVarHTTPResponse.StatusCode == 403 { var v PermissionDenied err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) @@ -4765,26 +5377,29 @@ func (r ApiListInstancesRequest) Execute() (*ListInstancesResponse, error) { } /* -ListInstances: Method for ListInstances +ListLogsAlertgroups: Method for ListLogsAlertgroups -Get all instances for a project. +Get logs alert groups config. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param instanceId @param projectId - @return ApiListInstancesRequest + @return ApiListLogsAlertgroupsRequest */ -func (a *APIClient) ListInstances(ctx context.Context, projectId string) ApiListInstancesRequest { - return ApiListInstancesRequest{ +func (a *APIClient) ListLogsAlertgroups(ctx context.Context, instanceId string, projectId string) ApiListLogsAlertgroupsRequest { + return ApiListLogsAlertgroupsRequest{ apiService: a.defaultApi, ctx: ctx, + instanceId: instanceId, projectId: projectId, } } -func (a *APIClient) ListInstancesExecute(ctx context.Context, projectId string) (*ListInstancesResponse, error) { - r := ApiListInstancesRequest{ +func (a *APIClient) ListLogsAlertgroupsExecute(ctx context.Context, instanceId string, projectId string) (*AlertGroupsResponse, error) { + r := ApiListLogsAlertgroupsRequest{ apiService: a.defaultApi, ctx: ctx, + instanceId: instanceId, projectId: projectId, } return r.Execute() @@ -6820,6 +7435,176 @@ func (a *APIClient) UpdateInstanceExecute(ctx context.Context, instanceId string return r.Execute() } +type ApiUpdateLogsAlertgroupRequest struct { + ctx context.Context + apiService *DefaultApiService + groupName string + instanceId string + projectId string + updateLogsAlertgroupPayload *UpdateLogsAlertgroupPayload +} + +func (r ApiUpdateLogsAlertgroupRequest) UpdateLogsAlertgroupPayload(updateLogsAlertgroupPayload UpdateLogsAlertgroupPayload) ApiUpdateLogsAlertgroupRequest { + r.updateLogsAlertgroupPayload = &updateLogsAlertgroupPayload + return r +} + +func (r ApiUpdateLogsAlertgroupRequest) Execute() (*AlertGroupsResponse, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *AlertGroupsResponse + ) + a := r.apiService + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultApiService.UpdateLogsAlertgroup") + if err != nil { + return localVarReturnValue, &oapierror.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups/{groupName}" + localVarPath = strings.Replace(localVarPath, "{"+"groupName"+"}", url.PathEscape(ParameterValueToString(r.groupName, "groupName")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(r.instanceId, "instanceId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.updateLogsAlertgroupPayload == nil { + return localVarReturnValue, fmt.Errorf("updateLogsAlertgroupPayload is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.updateLogsAlertgroupPayload + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, err + } + + contextHTTPRequest, ok := r.ctx.Value(config.ContextHTTPRequest).(**http.Request) + if ok { + *contextHTTPRequest = req + } + + localVarHTTPResponse, err := a.client.callAPI(req) + contextHTTPResponse, ok := r.ctx.Value(config.ContextHTTPResponse).(**http.Response) + if ok { + *contextHTTPResponse = localVarHTTPResponse + } + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v Message + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v PermissionDenied + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + return localVarReturnValue, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v Message + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.ErrorMessage = err.Error() + return localVarReturnValue, newErr + } + newErr.ErrorMessage = oapierror.FormatErrorMessage(localVarHTTPResponse.Status, &v) + newErr.Model = v + } + return localVarReturnValue, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &oapierror.GenericOpenAPIError{ + StatusCode: localVarHTTPResponse.StatusCode, + Body: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, newErr + } + + return localVarReturnValue, nil +} + +/* +UpdateLogsAlertgroup: Method for UpdateLogsAlertgroup + +Update logs alert group config. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param groupName + @param instanceId + @param projectId + @return ApiUpdateLogsAlertgroupRequest +*/ +func (a *APIClient) UpdateLogsAlertgroup(ctx context.Context, groupName string, instanceId string, projectId string) ApiUpdateLogsAlertgroupRequest { + return ApiUpdateLogsAlertgroupRequest{ + apiService: a.defaultApi, + ctx: ctx, + groupName: groupName, + instanceId: instanceId, + projectId: projectId, + } +} + +func (a *APIClient) UpdateLogsAlertgroupExecute(ctx context.Context, groupName string, instanceId string, projectId string) (*AlertGroupsResponse, error) { + r := ApiUpdateLogsAlertgroupRequest{ + apiService: a.defaultApi, + ctx: ctx, + groupName: groupName, + instanceId: instanceId, + projectId: projectId, + } + return r.Execute() +} + type ApiUpdateMetricsStorageRetentionRequest struct { ctx context.Context apiService *DefaultApiService diff --git a/services/observability/api_default_test.go b/services/observability/api_default_test.go index 7c6e68955..5e82b82c7 100644 --- a/services/observability/api_default_test.go +++ b/services/observability/api_default_test.go @@ -358,6 +358,62 @@ func Test_observability_DefaultApiService(t *testing.T) { } }) + t.Run("Test DefaultApiService CreateLogsAlertgroups", func(t *testing.T) { + _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups" + instanceIdValue := "instanceId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := AlertGroupsResponse{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for observability_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + instanceId := instanceIdValue + projectId := projectIdValue + createLogsAlertgroupsPayload := CreateLogsAlertgroupsPayload{} + + resp, reqErr := apiClient.CreateLogsAlertgroups(context.Background(), instanceId, projectId).CreateLogsAlertgroupsPayload(createLogsAlertgroupsPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + t.Run("Test DefaultApiService CreateScrapeConfig", func(t *testing.T) { _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/scrapeconfigs" instanceIdValue := "instanceId" @@ -874,6 +930,64 @@ func Test_observability_DefaultApiService(t *testing.T) { } }) + t.Run("Test DefaultApiService DeleteLogsAlertgroup", func(t *testing.T) { + _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups/{groupName}" + groupNameValue := "groupName" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"groupName"+"}", url.PathEscape(ParameterValueToString(groupNameValue, "groupName")), -1) + instanceIdValue := "instanceId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := AlertGroupsResponse{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for observability_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + groupName := groupNameValue + instanceId := instanceIdValue + projectId := projectIdValue + + resp, reqErr := apiClient.DeleteLogsAlertgroup(context.Background(), groupName, instanceId, projectId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + t.Run("Test DefaultApiService DeleteScrapeConfig", func(t *testing.T) { _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/scrapeconfigs/{jobName}" instanceIdValue := "instanceId" @@ -1387,6 +1501,64 @@ func Test_observability_DefaultApiService(t *testing.T) { } }) + t.Run("Test DefaultApiService GetLogsAlertgroup", func(t *testing.T) { + _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups/{groupName}" + groupNameValue := "groupName" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"groupName"+"}", url.PathEscape(ParameterValueToString(groupNameValue, "groupName")), -1) + instanceIdValue := "instanceId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := AlertGroupResponse{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for observability_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + groupName := groupNameValue + instanceId := instanceIdValue + projectId := projectIdValue + + resp, reqErr := apiClient.GetLogsAlertgroup(context.Background(), groupName, instanceId, projectId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + t.Run("Test DefaultApiService GetMetricsStorageRetention", func(t *testing.T) { _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/metrics-storage-retentions" instanceIdValue := "instanceId" @@ -1885,6 +2057,61 @@ func Test_observability_DefaultApiService(t *testing.T) { } }) + t.Run("Test DefaultApiService ListLogsAlertgroups", func(t *testing.T) { + _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups" + instanceIdValue := "instanceId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := AlertGroupsResponse{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for observability_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + instanceId := instanceIdValue + projectId := projectIdValue + + resp, reqErr := apiClient.ListLogsAlertgroups(context.Background(), instanceId, projectId).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + t.Run("Test DefaultApiService ListPlans", func(t *testing.T) { _apiUrlPath := "/v1/projects/{projectId}/plans" projectIdValue := "projectId" @@ -2622,6 +2849,65 @@ func Test_observability_DefaultApiService(t *testing.T) { } }) + t.Run("Test DefaultApiService UpdateLogsAlertgroup", func(t *testing.T) { + _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/logs-alertgroups/{groupName}" + groupNameValue := "groupName" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"groupName"+"}", url.PathEscape(ParameterValueToString(groupNameValue, "groupName")), -1) + instanceIdValue := "instanceId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"instanceId"+"}", url.PathEscape(ParameterValueToString(instanceIdValue, "instanceId")), -1) + projectIdValue := "projectId" + _apiUrlPath = strings.Replace(_apiUrlPath, "{"+"projectId"+"}", url.PathEscape(ParameterValueToString(projectIdValue, "projectId")), -1) + + testDefaultApiServeMux := http.NewServeMux() + testDefaultApiServeMux.HandleFunc(_apiUrlPath, func(w http.ResponseWriter, req *http.Request) { + data := AlertGroupsResponse{} + w.Header().Add("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) + }) + testServer := httptest.NewServer(testDefaultApiServeMux) + defer testServer.Close() + + configuration := &config.Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Region: "test_region", + Servers: config.ServerConfigurations{ + { + URL: testServer.URL, + Description: "Localhost for observability_DefaultApi", + Variables: map[string]config.ServerVariable{ + "region": { + DefaultValue: "test_region.", + EnumValues: []string{ + "test_region.", + }, + }, + }, + }, + }, + OperationServers: map[string]config.ServerConfigurations{}, + } + apiClient, err := NewAPIClient(config.WithCustomConfiguration(configuration), config.WithoutAuthentication()) + if err != nil { + t.Fatalf("creating API client: %v", err) + } + + groupName := groupNameValue + instanceId := instanceIdValue + projectId := projectIdValue + updateLogsAlertgroupPayload := UpdateLogsAlertgroupPayload{} + + resp, reqErr := apiClient.UpdateLogsAlertgroup(context.Background(), groupName, instanceId, projectId).UpdateLogsAlertgroupPayload(updateLogsAlertgroupPayload).Execute() + + if reqErr != nil { + t.Fatalf("error in call: %v", reqErr) + } + if IsNil(resp) { + t.Fatalf("response not present") + } + }) + t.Run("Test DefaultApiService UpdateMetricsStorageRetention", func(t *testing.T) { _apiUrlPath := "/v1/projects/{projectId}/instances/{instanceId}/metrics-storage-retentions" instanceIdValue := "instanceId" diff --git a/services/observability/model_create_logs_alertgroups_payload.go b/services/observability/model_create_logs_alertgroups_payload.go new file mode 100644 index 000000000..f4f02e157 --- /dev/null +++ b/services/observability/model_create_logs_alertgroups_payload.go @@ -0,0 +1,222 @@ +/* +STACKIT Observability API + +API endpoints for Observability on STACKIT + +API version: 1.1.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package observability + +import ( + "encoding/json" +) + +// checks if the CreateLogsAlertgroupsPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &CreateLogsAlertgroupsPayload{} + +/* + types and functions for interval +*/ + +// isNotNullableString +type CreateLogsAlertgroupsPayloadGetIntervalAttributeType = *string + +func getCreateLogsAlertgroupsPayloadGetIntervalAttributeTypeOk(arg CreateLogsAlertgroupsPayloadGetIntervalAttributeType) (ret CreateLogsAlertgroupsPayloadGetIntervalRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateLogsAlertgroupsPayloadGetIntervalAttributeType(arg *CreateLogsAlertgroupsPayloadGetIntervalAttributeType, val CreateLogsAlertgroupsPayloadGetIntervalRetType) { + *arg = &val +} + +type CreateLogsAlertgroupsPayloadGetIntervalArgType = string +type CreateLogsAlertgroupsPayloadGetIntervalRetType = string + +/* + types and functions for name +*/ + +// isNotNullableString +type CreateLogsAlertgroupsPayloadGetNameAttributeType = *string + +func getCreateLogsAlertgroupsPayloadGetNameAttributeTypeOk(arg CreateLogsAlertgroupsPayloadGetNameAttributeType) (ret CreateLogsAlertgroupsPayloadGetNameRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateLogsAlertgroupsPayloadGetNameAttributeType(arg *CreateLogsAlertgroupsPayloadGetNameAttributeType, val CreateLogsAlertgroupsPayloadGetNameRetType) { + *arg = &val +} + +type CreateLogsAlertgroupsPayloadGetNameArgType = string +type CreateLogsAlertgroupsPayloadGetNameRetType = string + +/* + types and functions for rules +*/ + +// isArray +type CreateLogsAlertgroupsPayloadGetRulesAttributeType = *[]UpdateAlertgroupsRequestInnerRulesInner +type CreateLogsAlertgroupsPayloadGetRulesArgType = []UpdateAlertgroupsRequestInnerRulesInner +type CreateLogsAlertgroupsPayloadGetRulesRetType = []UpdateAlertgroupsRequestInnerRulesInner + +func getCreateLogsAlertgroupsPayloadGetRulesAttributeTypeOk(arg CreateLogsAlertgroupsPayloadGetRulesAttributeType) (ret CreateLogsAlertgroupsPayloadGetRulesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setCreateLogsAlertgroupsPayloadGetRulesAttributeType(arg *CreateLogsAlertgroupsPayloadGetRulesAttributeType, val CreateLogsAlertgroupsPayloadGetRulesRetType) { + *arg = &val +} + +// CreateLogsAlertgroupsPayload Alert group that should be created or updated `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. +type CreateLogsAlertgroupsPayload struct { + // How often rules in the group are evaluated. `Additional Validators:` * must be a valid time string * should be >=60s + Interval CreateLogsAlertgroupsPayloadGetIntervalAttributeType `json:"interval,omitempty"` + // The name of the group. Must be unique. `Additional Validators:` * is the identifier and so unique * should only include the characters: a-zA-Z0-9- + // REQUIRED + Name CreateLogsAlertgroupsPayloadGetNameAttributeType `json:"name"` + // rules for the alert group + // REQUIRED + Rules CreateLogsAlertgroupsPayloadGetRulesAttributeType `json:"rules"` +} + +type _CreateLogsAlertgroupsPayload CreateLogsAlertgroupsPayload + +// NewCreateLogsAlertgroupsPayload instantiates a new CreateLogsAlertgroupsPayload object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewCreateLogsAlertgroupsPayload(name CreateLogsAlertgroupsPayloadGetNameArgType, rules CreateLogsAlertgroupsPayloadGetRulesArgType) *CreateLogsAlertgroupsPayload { + this := CreateLogsAlertgroupsPayload{} + setCreateLogsAlertgroupsPayloadGetNameAttributeType(&this.Name, name) + setCreateLogsAlertgroupsPayloadGetRulesAttributeType(&this.Rules, rules) + return &this +} + +// NewCreateLogsAlertgroupsPayloadWithDefaults instantiates a new CreateLogsAlertgroupsPayload object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewCreateLogsAlertgroupsPayloadWithDefaults() *CreateLogsAlertgroupsPayload { + this := CreateLogsAlertgroupsPayload{} + var interval string = "60s" + this.Interval = &interval + return &this +} + +// GetInterval returns the Interval field value if set, zero value otherwise. +func (o *CreateLogsAlertgroupsPayload) GetInterval() (res CreateLogsAlertgroupsPayloadGetIntervalRetType) { + res, _ = o.GetIntervalOk() + return +} + +// GetIntervalOk returns a tuple with the Interval field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateLogsAlertgroupsPayload) GetIntervalOk() (ret CreateLogsAlertgroupsPayloadGetIntervalRetType, ok bool) { + return getCreateLogsAlertgroupsPayloadGetIntervalAttributeTypeOk(o.Interval) +} + +// HasInterval returns a boolean if a field has been set. +func (o *CreateLogsAlertgroupsPayload) HasInterval() bool { + _, ok := o.GetIntervalOk() + return ok +} + +// SetInterval gets a reference to the given string and assigns it to the Interval field. +func (o *CreateLogsAlertgroupsPayload) SetInterval(v CreateLogsAlertgroupsPayloadGetIntervalRetType) { + setCreateLogsAlertgroupsPayloadGetIntervalAttributeType(&o.Interval, v) +} + +// GetName returns the Name field value +func (o *CreateLogsAlertgroupsPayload) GetName() (ret CreateLogsAlertgroupsPayloadGetNameRetType) { + ret, _ = o.GetNameOk() + return ret +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *CreateLogsAlertgroupsPayload) GetNameOk() (ret CreateLogsAlertgroupsPayloadGetNameRetType, ok bool) { + return getCreateLogsAlertgroupsPayloadGetNameAttributeTypeOk(o.Name) +} + +// SetName sets field value +func (o *CreateLogsAlertgroupsPayload) SetName(v CreateLogsAlertgroupsPayloadGetNameRetType) { + setCreateLogsAlertgroupsPayloadGetNameAttributeType(&o.Name, v) +} + +// GetRules returns the Rules field value +func (o *CreateLogsAlertgroupsPayload) GetRules() (ret CreateLogsAlertgroupsPayloadGetRulesRetType) { + ret, _ = o.GetRulesOk() + return ret +} + +// GetRulesOk returns a tuple with the Rules field value +// and a boolean to check if the value has been set. +func (o *CreateLogsAlertgroupsPayload) GetRulesOk() (ret CreateLogsAlertgroupsPayloadGetRulesRetType, ok bool) { + return getCreateLogsAlertgroupsPayloadGetRulesAttributeTypeOk(o.Rules) +} + +// SetRules sets field value +func (o *CreateLogsAlertgroupsPayload) SetRules(v CreateLogsAlertgroupsPayloadGetRulesRetType) { + setCreateLogsAlertgroupsPayloadGetRulesAttributeType(&o.Rules, v) +} + +func (o CreateLogsAlertgroupsPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getCreateLogsAlertgroupsPayloadGetIntervalAttributeTypeOk(o.Interval); ok { + toSerialize["Interval"] = val + } + if val, ok := getCreateLogsAlertgroupsPayloadGetNameAttributeTypeOk(o.Name); ok { + toSerialize["Name"] = val + } + if val, ok := getCreateLogsAlertgroupsPayloadGetRulesAttributeTypeOk(o.Rules); ok { + toSerialize["Rules"] = val + } + return toSerialize, nil +} + +type NullableCreateLogsAlertgroupsPayload struct { + value *CreateLogsAlertgroupsPayload + isSet bool +} + +func (v NullableCreateLogsAlertgroupsPayload) Get() *CreateLogsAlertgroupsPayload { + return v.value +} + +func (v *NullableCreateLogsAlertgroupsPayload) Set(val *CreateLogsAlertgroupsPayload) { + v.value = val + v.isSet = true +} + +func (v NullableCreateLogsAlertgroupsPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableCreateLogsAlertgroupsPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableCreateLogsAlertgroupsPayload(val *CreateLogsAlertgroupsPayload) *NullableCreateLogsAlertgroupsPayload { + return &NullableCreateLogsAlertgroupsPayload{value: val, isSet: true} +} + +func (v NullableCreateLogsAlertgroupsPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableCreateLogsAlertgroupsPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/services/observability/model_update_logs_alertgroup_payload.go b/services/observability/model_update_logs_alertgroup_payload.go new file mode 100644 index 000000000..e45c33005 --- /dev/null +++ b/services/observability/model_update_logs_alertgroup_payload.go @@ -0,0 +1,177 @@ +/* +STACKIT Observability API + +API endpoints for Observability on STACKIT + +API version: 1.1.1 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package observability + +import ( + "encoding/json" +) + +// checks if the UpdateLogsAlertgroupPayload type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &UpdateLogsAlertgroupPayload{} + +/* + types and functions for interval +*/ + +// isNotNullableString +type UpdateLogsAlertgroupPayloadGetIntervalAttributeType = *string + +func getUpdateLogsAlertgroupPayloadGetIntervalAttributeTypeOk(arg UpdateLogsAlertgroupPayloadGetIntervalAttributeType) (ret UpdateLogsAlertgroupPayloadGetIntervalRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setUpdateLogsAlertgroupPayloadGetIntervalAttributeType(arg *UpdateLogsAlertgroupPayloadGetIntervalAttributeType, val UpdateLogsAlertgroupPayloadGetIntervalRetType) { + *arg = &val +} + +type UpdateLogsAlertgroupPayloadGetIntervalArgType = string +type UpdateLogsAlertgroupPayloadGetIntervalRetType = string + +/* + types and functions for rules +*/ + +// isArray +type UpdateLogsAlertgroupPayloadGetRulesAttributeType = *[]UpdateAlertgroupsRequestInnerRulesInner +type UpdateLogsAlertgroupPayloadGetRulesArgType = []UpdateAlertgroupsRequestInnerRulesInner +type UpdateLogsAlertgroupPayloadGetRulesRetType = []UpdateAlertgroupsRequestInnerRulesInner + +func getUpdateLogsAlertgroupPayloadGetRulesAttributeTypeOk(arg UpdateLogsAlertgroupPayloadGetRulesAttributeType) (ret UpdateLogsAlertgroupPayloadGetRulesRetType, ok bool) { + if arg == nil { + return ret, false + } + return *arg, true +} + +func setUpdateLogsAlertgroupPayloadGetRulesAttributeType(arg *UpdateLogsAlertgroupPayloadGetRulesAttributeType, val UpdateLogsAlertgroupPayloadGetRulesRetType) { + *arg = &val +} + +// UpdateLogsAlertgroupPayload Alert group that should be created or updated `Additional Validators:` * total config should not be bigger than 500000 characters as string since this the limitation of prometheus. +type UpdateLogsAlertgroupPayload struct { + // How often rules in the group are evaluated. `Additional Validators:` * must be a valid time string * should be >=60s + Interval UpdateLogsAlertgroupPayloadGetIntervalAttributeType `json:"interval,omitempty"` + // rules for the alert group + // REQUIRED + Rules UpdateLogsAlertgroupPayloadGetRulesAttributeType `json:"rules"` +} + +type _UpdateLogsAlertgroupPayload UpdateLogsAlertgroupPayload + +// NewUpdateLogsAlertgroupPayload instantiates a new UpdateLogsAlertgroupPayload object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewUpdateLogsAlertgroupPayload(rules UpdateLogsAlertgroupPayloadGetRulesArgType) *UpdateLogsAlertgroupPayload { + this := UpdateLogsAlertgroupPayload{} + setUpdateLogsAlertgroupPayloadGetRulesAttributeType(&this.Rules, rules) + return &this +} + +// NewUpdateLogsAlertgroupPayloadWithDefaults instantiates a new UpdateLogsAlertgroupPayload object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewUpdateLogsAlertgroupPayloadWithDefaults() *UpdateLogsAlertgroupPayload { + this := UpdateLogsAlertgroupPayload{} + var interval string = "60s" + this.Interval = &interval + return &this +} + +// GetInterval returns the Interval field value if set, zero value otherwise. +func (o *UpdateLogsAlertgroupPayload) GetInterval() (res UpdateLogsAlertgroupPayloadGetIntervalRetType) { + res, _ = o.GetIntervalOk() + return +} + +// GetIntervalOk returns a tuple with the Interval field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpdateLogsAlertgroupPayload) GetIntervalOk() (ret UpdateLogsAlertgroupPayloadGetIntervalRetType, ok bool) { + return getUpdateLogsAlertgroupPayloadGetIntervalAttributeTypeOk(o.Interval) +} + +// HasInterval returns a boolean if a field has been set. +func (o *UpdateLogsAlertgroupPayload) HasInterval() bool { + _, ok := o.GetIntervalOk() + return ok +} + +// SetInterval gets a reference to the given string and assigns it to the Interval field. +func (o *UpdateLogsAlertgroupPayload) SetInterval(v UpdateLogsAlertgroupPayloadGetIntervalRetType) { + setUpdateLogsAlertgroupPayloadGetIntervalAttributeType(&o.Interval, v) +} + +// GetRules returns the Rules field value +func (o *UpdateLogsAlertgroupPayload) GetRules() (ret UpdateLogsAlertgroupPayloadGetRulesRetType) { + ret, _ = o.GetRulesOk() + return ret +} + +// GetRulesOk returns a tuple with the Rules field value +// and a boolean to check if the value has been set. +func (o *UpdateLogsAlertgroupPayload) GetRulesOk() (ret UpdateLogsAlertgroupPayloadGetRulesRetType, ok bool) { + return getUpdateLogsAlertgroupPayloadGetRulesAttributeTypeOk(o.Rules) +} + +// SetRules sets field value +func (o *UpdateLogsAlertgroupPayload) SetRules(v UpdateLogsAlertgroupPayloadGetRulesRetType) { + setUpdateLogsAlertgroupPayloadGetRulesAttributeType(&o.Rules, v) +} + +func (o UpdateLogsAlertgroupPayload) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if val, ok := getUpdateLogsAlertgroupPayloadGetIntervalAttributeTypeOk(o.Interval); ok { + toSerialize["Interval"] = val + } + if val, ok := getUpdateLogsAlertgroupPayloadGetRulesAttributeTypeOk(o.Rules); ok { + toSerialize["Rules"] = val + } + return toSerialize, nil +} + +type NullableUpdateLogsAlertgroupPayload struct { + value *UpdateLogsAlertgroupPayload + isSet bool +} + +func (v NullableUpdateLogsAlertgroupPayload) Get() *UpdateLogsAlertgroupPayload { + return v.value +} + +func (v *NullableUpdateLogsAlertgroupPayload) Set(val *UpdateLogsAlertgroupPayload) { + v.value = val + v.isSet = true +} + +func (v NullableUpdateLogsAlertgroupPayload) IsSet() bool { + return v.isSet +} + +func (v *NullableUpdateLogsAlertgroupPayload) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableUpdateLogsAlertgroupPayload(val *UpdateLogsAlertgroupPayload) *NullableUpdateLogsAlertgroupPayload { + return &NullableUpdateLogsAlertgroupPayload{value: val, isSet: true} +} + +func (v NullableUpdateLogsAlertgroupPayload) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableUpdateLogsAlertgroupPayload) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} From 4964e3628be4e2529ee144ffe9ac377be7e5417a Mon Sep 17 00:00:00 2001 From: Marcel Jacek Date: Wed, 16 Apr 2025 12:16:30 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ services/observability/CHANGELOG.md | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8240fc587..e8ff75217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - **New**: STACKIT Git module can be used to manage STACKIT Git - [v0.2.0](services/git/CHANGELOG.md#v020-2025-04-16) - **Features**: Add new methods to manage the STACKIT Git: `CreateInstance`, `DeleteInstance`, `GetInstance` +- `observability`: [v0.5.0](services/observability/CHANGELOG.md#v050-2025-04-16) + - **Feature:** Add new methods `ListLogsAlertgroups`, `CreateLogsAlertgroups`, `GetLogsAlertgroup`, `UpdateLogsAlertgroup`, `DeleteLogsAlertgroup` ## Release (2025-04-09) - `cdn`: [v0.3.0](services/cdn/CHANGELOG.md#v030-2025-04-04) diff --git a/services/observability/CHANGELOG.md b/services/observability/CHANGELOG.md index c21d619e3..6a6620e45 100644 --- a/services/observability/CHANGELOG.md +++ b/services/observability/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.5.0 (2025-04-16) +- **Feature:** Add new methods `ListLogsAlertgroups`, `CreateLogsAlertgroups`, `GetLogsAlertgroup`, `UpdateLogsAlertgroup`, `DeleteLogsAlertgroup` + ## v0.4.0 (2025-03-27) - **New:** Support for alert groups