diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 16572dbd871..a218e8cf8ce 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -16842,6 +16842,78 @@ components: required: - data type: object + DeletedSuiteResponseData: + properties: + attributes: + $ref: '#/components/schemas/DeletedSuiteResponseDataAttributes' + id: + type: string + type: + $ref: '#/components/schemas/DeletedSuiteType' + type: object + DeletedSuiteResponseDataAttributes: + properties: + deleted_at: + description: Deletion timestamp of the Synthetic suite ID. + type: string + public_id: + description: The Synthetic suite ID deleted. + type: string + type: object + DeletedSuiteType: + default: suites + enum: + - suites + example: suites + type: string + x-enum-varnames: + - SUITES + DeletedSuitesRequestDelete: + properties: + attributes: + $ref: '#/components/schemas/DeletedSuitesRequestDeleteAttributes' + id: + type: string + type: + $ref: '#/components/schemas/DeletedSuitesRequestType' + required: + - attributes + type: object + DeletedSuitesRequestDeleteAttributes: + properties: + force_delete_dependencies: + type: boolean + public_ids: + example: + - '' + items: + type: string + type: array + required: + - public_ids + type: object + DeletedSuitesRequestDeleteRequest: + properties: + data: + $ref: '#/components/schemas/DeletedSuitesRequestDelete' + required: + - data + type: object + DeletedSuitesRequestType: + default: delete_suites_request + enum: + - delete_suites_request + example: delete_suites_request + type: string + x-enum-varnames: + - DELETE_SUITES_REQUEST + DeletedSuitesResponse: + properties: + data: + items: + $ref: '#/components/schemas/DeletedSuiteResponseData' + type: array + type: object DependencyLocation: description: Static library vulnerability location. properties: @@ -52614,6 +52686,153 @@ components: format: double type: number type: object + SuiteCreateEdit: + properties: + attributes: + $ref: '#/components/schemas/SyntheticsSuite' + type: + $ref: '#/components/schemas/SyntheticsSuiteType' + required: + - attributes + - type + type: object + SuiteCreateEditRequest: + properties: + data: + $ref: '#/components/schemas/SuiteCreateEdit' + required: + - data + type: object + SuiteSearchResponseType: + default: suites_search + enum: + - suites_search + example: suites_search + type: string + x-enum-varnames: + - SUITES_SEARCH + SyntheticsSuite: + description: Object containing details about a Synthetic suite. + properties: + message: + description: Notification message associated with the suite. + example: Notification message + type: string + name: + description: Name of the suite. + example: Example suite name + type: string + options: + $ref: '#/components/schemas/SyntheticsSuiteOptions' + public_id: + description: The public ID for the test. + example: 123-abc-456 + readOnly: true + type: string + tags: + description: Array of tags attached to the suite. + example: + - env:production + items: + description: A tag attached to the suite. + type: string + type: array + tests: + items: + $ref: '#/components/schemas/SyntheticsSuiteTest' + type: array + type: + $ref: '#/components/schemas/SyntheticsSuiteType' + required: + - name + - message + - type + - tests + - options + type: object + SyntheticsSuiteOptions: + description: Object describing the extra options for a Synthetic suite. + properties: + alerting_threshold: + description: Percentage of critical tests failure needed for a suite to + fail. + format: double + maximum: 1 + minimum: 0 + type: number + type: object + SyntheticsSuiteResponse: + description: Synthetics suite response + properties: + data: + $ref: '#/components/schemas/SyntheticsSuiteResponseData' + type: object + SyntheticsSuiteResponseData: + description: Synthetics suite response data + properties: + attributes: + $ref: '#/components/schemas/SyntheticsSuite' + type: object + SyntheticsSuiteSearchResponse: + description: Synthetics suite search response + properties: + data: + $ref: '#/components/schemas/SyntheticsSuiteSearchResponseData' + type: object + SyntheticsSuiteSearchResponseData: + description: Synthetics suite search response data + properties: + attributes: + $ref: '#/components/schemas/SyntheticsSuiteSearchResponseDataAttributes' + id: + format: uuid + type: string + type: + $ref: '#/components/schemas/SuiteSearchResponseType' + type: object + SyntheticsSuiteSearchResponseDataAttributes: + description: Synthetics suite search response data attributes + properties: + suites: + items: + $ref: '#/components/schemas/SyntheticsSuite' + type: array + total: + format: int32 + maximum: 2147483647 + type: integer + type: object + SyntheticsSuiteTest: + description: Object containing details about a Synthetic test included in a + Synthetic suite. + properties: + alerting_criticality: + $ref: '#/components/schemas/SyntheticsSuiteTestAlertingCriticality' + public_id: + example: '' + type: string + required: + - public_id + type: object + SyntheticsSuiteTestAlertingCriticality: + description: Alerting criticality for each the test. + enum: + - ignore + - critical + example: critical + type: string + x-enum-varnames: + - IGNORE + - CRITICAL + SyntheticsSuiteType: + default: suite + description: Type of the Synthetic suite, `suite`. + enum: + - suite + example: suite + type: string + x-enum-varnames: + - SUITE TableResultV2: description: A reference table resource containing its full configuration and state. @@ -84162,6 +84381,227 @@ paths: operator: OR permissions: - billing_edit + /api/v2/synthetics/suites: + post: + operationId: CreateSyntheticsSuite + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SuiteCreateEditRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsSuiteResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_write + summary: 'Synthetics: Create a test suite' + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_write + - synthetics_create_edit_trigger + /api/v2/synthetics/suites/bulk-delete: + post: + operationId: DeleteSyntheticsSuites + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedSuitesRequestDeleteRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedSuitesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_write + summary: 'Synthetics: Bulk delete suites' + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_write + /api/v2/synthetics/suites/search: + get: + description: Search for Synthetics suites. + operationId: SearchSuites + parameters: + - description: The search query. + in: query + name: query + required: false + schema: + type: string + - description: The sort order for the results (e.g., `name,asc` or `name,desc`). + in: query + name: sort + required: false + schema: + default: name,asc + type: string + - description: If true, return only facets instead of full test details. + in: query + name: facets_only + required: false + schema: + default: false + type: boolean + - description: The offset from which to start returning results. + in: query + name: start + required: false + schema: + default: 0 + format: int64 + type: integer + - description: The maximum number of results to return. + in: query + name: count + required: false + schema: + default: 50 + format: int64 + type: integer + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsSuiteSearchResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_read + summary: Search Synthetics suites + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_read + /api/v2/synthetics/suites/{public_id}: + get: + operationId: GetSyntheticsSuite + parameters: + - description: The public ID of the suite to get details from. + in: path + name: public_id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsSuiteResponse' + description: OK + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_read + summary: 'Synthetics: Get a suite' + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_read + put: + operationId: EditSyntheticsSuite + parameters: + - description: The public ID of the suite to edit. + in: path + name: public_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SuiteCreateEditRequest' + description: New suite details to be saved. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsSuiteResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - synthetics_write + summary: 'Synthetics: edit a test suite' + tags: + - Synthetics + x-permission: + operator: OR + permissions: + - synthetics_write /api/v2/tags/enrichment: get: description: List all tag pipeline rulesets - Retrieve a list of all tag pipeline diff --git a/api/datadogV2/api_synthetics.go b/api/datadogV2/api_synthetics.go index 3c3fed060c9..3ac2188bd38 100644 --- a/api/datadogV2/api_synthetics.go +++ b/api/datadogV2/api_synthetics.go @@ -15,6 +15,247 @@ import ( // SyntheticsApi service type type SyntheticsApi datadog.Service +// CreateSyntheticsSuite Synthetics: Create a test suite. + +func (a *SyntheticsApi) CreateSyntheticsSuite(ctx _context.Context, body SuiteCreateEditRequest) (SyntheticsSuiteResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue SyntheticsSuiteResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.CreateSyntheticsSuite") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/suites" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// DeleteSyntheticsSuites Synthetics: Bulk delete suites. + +func (a *SyntheticsApi) DeleteSyntheticsSuites(ctx _context.Context, body DeletedSuitesRequestDeleteRequest) (DeletedSuitesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue DeletedSuitesResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.DeleteSyntheticsSuites") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/suites/bulk-delete" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// EditSyntheticsSuite Synthetics: edit a test suite. + +func (a *SyntheticsApi) EditSyntheticsSuite(ctx _context.Context, publicId string, body SuiteCreateEditRequest) (SyntheticsSuiteResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue SyntheticsSuiteResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.EditSyntheticsSuite") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/suites/{public_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{public_id}", _neturl.PathEscape(datadog.ParameterToString(publicId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // GetOnDemandConcurrencyCap Get the on-demand concurrency cap. // Get the on-demand concurrency cap. func (a *SyntheticsApi) GetOnDemandConcurrencyCap(ctx _context.Context) (OnDemandConcurrencyCapResponse, *_nethttp.Response, error) { @@ -92,6 +333,229 @@ func (a *SyntheticsApi) GetOnDemandConcurrencyCap(ctx _context.Context) (OnDeman return localVarReturnValue, localVarHTTPResponse, nil } +// GetSyntheticsSuite Synthetics: Get a suite. + +func (a *SyntheticsApi) GetSyntheticsSuite(ctx _context.Context, publicId string) (SyntheticsSuiteResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue SyntheticsSuiteResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.GetSyntheticsSuite") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/suites/{public_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{public_id}", _neturl.PathEscape(datadog.ParameterToString(publicId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// SearchSuitesOptionalParameters holds optional parameters for SearchSuites. +type SearchSuitesOptionalParameters struct { + Query *string + Sort *string + FacetsOnly *bool + Start *int64 + Count *int64 +} + +// NewSearchSuitesOptionalParameters creates an empty struct for parameters. +func NewSearchSuitesOptionalParameters() *SearchSuitesOptionalParameters { + this := SearchSuitesOptionalParameters{} + return &this +} + +// WithQuery sets the corresponding parameter name and returns the struct. +func (r *SearchSuitesOptionalParameters) WithQuery(query string) *SearchSuitesOptionalParameters { + r.Query = &query + return r +} + +// WithSort sets the corresponding parameter name and returns the struct. +func (r *SearchSuitesOptionalParameters) WithSort(sort string) *SearchSuitesOptionalParameters { + r.Sort = &sort + return r +} + +// WithFacetsOnly sets the corresponding parameter name and returns the struct. +func (r *SearchSuitesOptionalParameters) WithFacetsOnly(facetsOnly bool) *SearchSuitesOptionalParameters { + r.FacetsOnly = &facetsOnly + return r +} + +// WithStart sets the corresponding parameter name and returns the struct. +func (r *SearchSuitesOptionalParameters) WithStart(start int64) *SearchSuitesOptionalParameters { + r.Start = &start + return r +} + +// WithCount sets the corresponding parameter name and returns the struct. +func (r *SearchSuitesOptionalParameters) WithCount(count int64) *SearchSuitesOptionalParameters { + r.Count = &count + return r +} + +// SearchSuites Search Synthetics suites. +// Search for Synthetics suites. +func (a *SyntheticsApi) SearchSuites(ctx _context.Context, o ...SearchSuitesOptionalParameters) (SyntheticsSuiteSearchResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue SyntheticsSuiteSearchResponse + optionalParams SearchSuitesOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type SearchSuitesOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SyntheticsApi.SearchSuites") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/synthetics/suites/search" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Query != nil { + localVarQueryParams.Add("query", datadog.ParameterToString(*optionalParams.Query, "")) + } + if optionalParams.Sort != nil { + localVarQueryParams.Add("sort", datadog.ParameterToString(*optionalParams.Sort, "")) + } + if optionalParams.FacetsOnly != nil { + localVarQueryParams.Add("facets_only", datadog.ParameterToString(*optionalParams.FacetsOnly, "")) + } + if optionalParams.Start != nil { + localVarQueryParams.Add("start", datadog.ParameterToString(*optionalParams.Start, "")) + } + if optionalParams.Count != nil { + localVarQueryParams.Add("count", datadog.ParameterToString(*optionalParams.Count, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // SetOnDemandConcurrencyCap Save new value for on-demand concurrency cap. // Save new value for on-demand concurrency cap. func (a *SyntheticsApi) SetOnDemandConcurrencyCap(ctx _context.Context, body OnDemandConcurrencyCapAttributes) (OnDemandConcurrencyCapResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 07c9a1a3dc8..88e7ec7451b 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -640,7 +640,12 @@ // - [SpansMetricsApi.UpdateSpansMetric] // - [StaticAnalysisApi.CreateSCAResolveVulnerableSymbols] // - [StaticAnalysisApi.CreateSCAResult] +// - [SyntheticsApi.CreateSyntheticsSuite] +// - [SyntheticsApi.DeleteSyntheticsSuites] +// - [SyntheticsApi.EditSyntheticsSuite] // - [SyntheticsApi.GetOnDemandConcurrencyCap] +// - [SyntheticsApi.GetSyntheticsSuite] +// - [SyntheticsApi.SearchSuites] // - [SyntheticsApi.SetOnDemandConcurrencyCap] // - [TeamsApi.AddMemberTeam] // - [TeamsApi.AddTeamHierarchyLink] diff --git a/api/datadogV2/model_deleted_suite_response_data.go b/api/datadogV2/model_deleted_suite_response_data.go new file mode 100644 index 00000000000..9fb40dfbfdc --- /dev/null +++ b/api/datadogV2/model_deleted_suite_response_data.go @@ -0,0 +1,189 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeletedSuiteResponseData +type DeletedSuiteResponseData struct { + // + Attributes *DeletedSuiteResponseDataAttributes `json:"attributes,omitempty"` + // + Id *string `json:"id,omitempty"` + // + Type *DeletedSuiteType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeletedSuiteResponseData instantiates a new DeletedSuiteResponseData 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 NewDeletedSuiteResponseData() *DeletedSuiteResponseData { + this := DeletedSuiteResponseData{} + var typeVar DeletedSuiteType = DELETEDSUITETYPE_SUITES + this.Type = &typeVar + return &this +} + +// NewDeletedSuiteResponseDataWithDefaults instantiates a new DeletedSuiteResponseData 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 NewDeletedSuiteResponseDataWithDefaults() *DeletedSuiteResponseData { + this := DeletedSuiteResponseData{} + var typeVar DeletedSuiteType = DELETEDSUITETYPE_SUITES + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *DeletedSuiteResponseData) GetAttributes() DeletedSuiteResponseDataAttributes { + if o == nil || o.Attributes == nil { + var ret DeletedSuiteResponseDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeletedSuiteResponseData) GetAttributesOk() (*DeletedSuiteResponseDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *DeletedSuiteResponseData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given DeletedSuiteResponseDataAttributes and assigns it to the Attributes field. +func (o *DeletedSuiteResponseData) SetAttributes(v DeletedSuiteResponseDataAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *DeletedSuiteResponseData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeletedSuiteResponseData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *DeletedSuiteResponseData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *DeletedSuiteResponseData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *DeletedSuiteResponseData) GetType() DeletedSuiteType { + if o == nil || o.Type == nil { + var ret DeletedSuiteType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeletedSuiteResponseData) GetTypeOk() (*DeletedSuiteType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *DeletedSuiteResponseData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given DeletedSuiteType and assigns it to the Type field. +func (o *DeletedSuiteResponseData) SetType(v DeletedSuiteType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeletedSuiteResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeletedSuiteResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *DeletedSuiteResponseDataAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *DeletedSuiteType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_deleted_suite_response_data_attributes.go b/api/datadogV2/model_deleted_suite_response_data_attributes.go new file mode 100644 index 00000000000..c9dbfd65f0a --- /dev/null +++ b/api/datadogV2/model_deleted_suite_response_data_attributes.go @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeletedSuiteResponseDataAttributes +type DeletedSuiteResponseDataAttributes struct { + // Deletion timestamp of the Synthetic suite ID. + DeletedAt *string `json:"deleted_at,omitempty"` + // The Synthetic suite ID deleted. + PublicId *string `json:"public_id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeletedSuiteResponseDataAttributes instantiates a new DeletedSuiteResponseDataAttributes 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 NewDeletedSuiteResponseDataAttributes() *DeletedSuiteResponseDataAttributes { + this := DeletedSuiteResponseDataAttributes{} + return &this +} + +// NewDeletedSuiteResponseDataAttributesWithDefaults instantiates a new DeletedSuiteResponseDataAttributes 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 NewDeletedSuiteResponseDataAttributesWithDefaults() *DeletedSuiteResponseDataAttributes { + this := DeletedSuiteResponseDataAttributes{} + return &this +} + +// GetDeletedAt returns the DeletedAt field value if set, zero value otherwise. +func (o *DeletedSuiteResponseDataAttributes) GetDeletedAt() string { + if o == nil || o.DeletedAt == nil { + var ret string + return ret + } + return *o.DeletedAt +} + +// GetDeletedAtOk returns a tuple with the DeletedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeletedSuiteResponseDataAttributes) GetDeletedAtOk() (*string, bool) { + if o == nil || o.DeletedAt == nil { + return nil, false + } + return o.DeletedAt, true +} + +// HasDeletedAt returns a boolean if a field has been set. +func (o *DeletedSuiteResponseDataAttributes) HasDeletedAt() bool { + return o != nil && o.DeletedAt != nil +} + +// SetDeletedAt gets a reference to the given string and assigns it to the DeletedAt field. +func (o *DeletedSuiteResponseDataAttributes) SetDeletedAt(v string) { + o.DeletedAt = &v +} + +// GetPublicId returns the PublicId field value if set, zero value otherwise. +func (o *DeletedSuiteResponseDataAttributes) GetPublicId() string { + if o == nil || o.PublicId == nil { + var ret string + return ret + } + return *o.PublicId +} + +// GetPublicIdOk returns a tuple with the PublicId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeletedSuiteResponseDataAttributes) GetPublicIdOk() (*string, bool) { + if o == nil || o.PublicId == nil { + return nil, false + } + return o.PublicId, true +} + +// HasPublicId returns a boolean if a field has been set. +func (o *DeletedSuiteResponseDataAttributes) HasPublicId() bool { + return o != nil && o.PublicId != nil +} + +// SetPublicId gets a reference to the given string and assigns it to the PublicId field. +func (o *DeletedSuiteResponseDataAttributes) SetPublicId(v string) { + o.PublicId = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeletedSuiteResponseDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.DeletedAt != nil { + toSerialize["deleted_at"] = o.DeletedAt + } + if o.PublicId != nil { + toSerialize["public_id"] = o.PublicId + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeletedSuiteResponseDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DeletedAt *string `json:"deleted_at,omitempty"` + PublicId *string `json:"public_id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"deleted_at", "public_id"}) + } else { + return err + } + o.DeletedAt = all.DeletedAt + o.PublicId = all.PublicId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_deleted_suite_type.go b/api/datadogV2/model_deleted_suite_type.go new file mode 100644 index 00000000000..0b1cca774d7 --- /dev/null +++ b/api/datadogV2/model_deleted_suite_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeletedSuiteType +type DeletedSuiteType string + +// List of DeletedSuiteType. +const ( + DELETEDSUITETYPE_SUITES DeletedSuiteType = "suites" +) + +var allowedDeletedSuiteTypeEnumValues = []DeletedSuiteType{ + DELETEDSUITETYPE_SUITES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *DeletedSuiteType) GetAllowedValues() []DeletedSuiteType { + return allowedDeletedSuiteTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *DeletedSuiteType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = DeletedSuiteType(value) + return nil +} + +// NewDeletedSuiteTypeFromValue returns a pointer to a valid DeletedSuiteType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewDeletedSuiteTypeFromValue(v string) (*DeletedSuiteType, error) { + ev := DeletedSuiteType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for DeletedSuiteType: valid values are %v", v, allowedDeletedSuiteTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v DeletedSuiteType) IsValid() bool { + for _, existing := range allowedDeletedSuiteTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DeletedSuiteType value. +func (v DeletedSuiteType) Ptr() *DeletedSuiteType { + return &v +} diff --git a/api/datadogV2/model_deleted_suites_request_delete.go b/api/datadogV2/model_deleted_suites_request_delete.go new file mode 100644 index 00000000000..534807a43e5 --- /dev/null +++ b/api/datadogV2/model_deleted_suites_request_delete.go @@ -0,0 +1,188 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeletedSuitesRequestDelete +type DeletedSuitesRequestDelete struct { + // + Attributes DeletedSuitesRequestDeleteAttributes `json:"attributes"` + // + Id *string `json:"id,omitempty"` + // + Type *DeletedSuitesRequestType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeletedSuitesRequestDelete instantiates a new DeletedSuitesRequestDelete 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 NewDeletedSuitesRequestDelete(attributes DeletedSuitesRequestDeleteAttributes) *DeletedSuitesRequestDelete { + this := DeletedSuitesRequestDelete{} + this.Attributes = attributes + var typeVar DeletedSuitesRequestType = DELETEDSUITESREQUESTTYPE_DELETE_SUITES_REQUEST + this.Type = &typeVar + return &this +} + +// NewDeletedSuitesRequestDeleteWithDefaults instantiates a new DeletedSuitesRequestDelete 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 NewDeletedSuitesRequestDeleteWithDefaults() *DeletedSuitesRequestDelete { + this := DeletedSuitesRequestDelete{} + var typeVar DeletedSuitesRequestType = DELETEDSUITESREQUESTTYPE_DELETE_SUITES_REQUEST + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *DeletedSuitesRequestDelete) GetAttributes() DeletedSuitesRequestDeleteAttributes { + if o == nil { + var ret DeletedSuitesRequestDeleteAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *DeletedSuitesRequestDelete) GetAttributesOk() (*DeletedSuitesRequestDeleteAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *DeletedSuitesRequestDelete) SetAttributes(v DeletedSuitesRequestDeleteAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *DeletedSuitesRequestDelete) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeletedSuitesRequestDelete) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *DeletedSuitesRequestDelete) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *DeletedSuitesRequestDelete) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *DeletedSuitesRequestDelete) GetType() DeletedSuitesRequestType { + if o == nil || o.Type == nil { + var ret DeletedSuitesRequestType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeletedSuitesRequestDelete) GetTypeOk() (*DeletedSuitesRequestType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *DeletedSuitesRequestDelete) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given DeletedSuitesRequestType and assigns it to the Type field. +func (o *DeletedSuitesRequestDelete) SetType(v DeletedSuitesRequestType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeletedSuitesRequestDelete) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeletedSuitesRequestDelete) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *DeletedSuitesRequestDeleteAttributes `json:"attributes"` + Id *string `json:"id,omitempty"` + Type *DeletedSuitesRequestType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = all.Id + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_deleted_suites_request_delete_attributes.go b/api/datadogV2/model_deleted_suites_request_delete_attributes.go new file mode 100644 index 00000000000..548b9c41d6c --- /dev/null +++ b/api/datadogV2/model_deleted_suites_request_delete_attributes.go @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeletedSuitesRequestDeleteAttributes +type DeletedSuitesRequestDeleteAttributes struct { + // + ForceDeleteDependencies *bool `json:"force_delete_dependencies,omitempty"` + // + PublicIds []string `json:"public_ids"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeletedSuitesRequestDeleteAttributes instantiates a new DeletedSuitesRequestDeleteAttributes 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 NewDeletedSuitesRequestDeleteAttributes(publicIds []string) *DeletedSuitesRequestDeleteAttributes { + this := DeletedSuitesRequestDeleteAttributes{} + this.PublicIds = publicIds + return &this +} + +// NewDeletedSuitesRequestDeleteAttributesWithDefaults instantiates a new DeletedSuitesRequestDeleteAttributes 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 NewDeletedSuitesRequestDeleteAttributesWithDefaults() *DeletedSuitesRequestDeleteAttributes { + this := DeletedSuitesRequestDeleteAttributes{} + return &this +} + +// GetForceDeleteDependencies returns the ForceDeleteDependencies field value if set, zero value otherwise. +func (o *DeletedSuitesRequestDeleteAttributes) GetForceDeleteDependencies() bool { + if o == nil || o.ForceDeleteDependencies == nil { + var ret bool + return ret + } + return *o.ForceDeleteDependencies +} + +// GetForceDeleteDependenciesOk returns a tuple with the ForceDeleteDependencies field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeletedSuitesRequestDeleteAttributes) GetForceDeleteDependenciesOk() (*bool, bool) { + if o == nil || o.ForceDeleteDependencies == nil { + return nil, false + } + return o.ForceDeleteDependencies, true +} + +// HasForceDeleteDependencies returns a boolean if a field has been set. +func (o *DeletedSuitesRequestDeleteAttributes) HasForceDeleteDependencies() bool { + return o != nil && o.ForceDeleteDependencies != nil +} + +// SetForceDeleteDependencies gets a reference to the given bool and assigns it to the ForceDeleteDependencies field. +func (o *DeletedSuitesRequestDeleteAttributes) SetForceDeleteDependencies(v bool) { + o.ForceDeleteDependencies = &v +} + +// GetPublicIds returns the PublicIds field value. +func (o *DeletedSuitesRequestDeleteAttributes) GetPublicIds() []string { + if o == nil { + var ret []string + return ret + } + return o.PublicIds +} + +// GetPublicIdsOk returns a tuple with the PublicIds field value +// and a boolean to check if the value has been set. +func (o *DeletedSuitesRequestDeleteAttributes) GetPublicIdsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.PublicIds, true +} + +// SetPublicIds sets field value. +func (o *DeletedSuitesRequestDeleteAttributes) SetPublicIds(v []string) { + o.PublicIds = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeletedSuitesRequestDeleteAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ForceDeleteDependencies != nil { + toSerialize["force_delete_dependencies"] = o.ForceDeleteDependencies + } + toSerialize["public_ids"] = o.PublicIds + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeletedSuitesRequestDeleteAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ForceDeleteDependencies *bool `json:"force_delete_dependencies,omitempty"` + PublicIds *[]string `json:"public_ids"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.PublicIds == nil { + return fmt.Errorf("required field public_ids missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"force_delete_dependencies", "public_ids"}) + } else { + return err + } + o.ForceDeleteDependencies = all.ForceDeleteDependencies + o.PublicIds = *all.PublicIds + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_deleted_suites_request_delete_request.go b/api/datadogV2/model_deleted_suites_request_delete_request.go new file mode 100644 index 00000000000..a9b75c8b89f --- /dev/null +++ b/api/datadogV2/model_deleted_suites_request_delete_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeletedSuitesRequestDeleteRequest +type DeletedSuitesRequestDeleteRequest struct { + // + Data DeletedSuitesRequestDelete `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeletedSuitesRequestDeleteRequest instantiates a new DeletedSuitesRequestDeleteRequest 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 NewDeletedSuitesRequestDeleteRequest(data DeletedSuitesRequestDelete) *DeletedSuitesRequestDeleteRequest { + this := DeletedSuitesRequestDeleteRequest{} + this.Data = data + return &this +} + +// NewDeletedSuitesRequestDeleteRequestWithDefaults instantiates a new DeletedSuitesRequestDeleteRequest 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 NewDeletedSuitesRequestDeleteRequestWithDefaults() *DeletedSuitesRequestDeleteRequest { + this := DeletedSuitesRequestDeleteRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *DeletedSuitesRequestDeleteRequest) GetData() DeletedSuitesRequestDelete { + if o == nil { + var ret DeletedSuitesRequestDelete + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *DeletedSuitesRequestDeleteRequest) GetDataOk() (*DeletedSuitesRequestDelete, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *DeletedSuitesRequestDeleteRequest) SetData(v DeletedSuitesRequestDelete) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeletedSuitesRequestDeleteRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeletedSuitesRequestDeleteRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DeletedSuitesRequestDelete `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_deleted_suites_request_type.go b/api/datadogV2/model_deleted_suites_request_type.go new file mode 100644 index 00000000000..b0403ecb08d --- /dev/null +++ b/api/datadogV2/model_deleted_suites_request_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeletedSuitesRequestType +type DeletedSuitesRequestType string + +// List of DeletedSuitesRequestType. +const ( + DELETEDSUITESREQUESTTYPE_DELETE_SUITES_REQUEST DeletedSuitesRequestType = "delete_suites_request" +) + +var allowedDeletedSuitesRequestTypeEnumValues = []DeletedSuitesRequestType{ + DELETEDSUITESREQUESTTYPE_DELETE_SUITES_REQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *DeletedSuitesRequestType) GetAllowedValues() []DeletedSuitesRequestType { + return allowedDeletedSuitesRequestTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *DeletedSuitesRequestType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = DeletedSuitesRequestType(value) + return nil +} + +// NewDeletedSuitesRequestTypeFromValue returns a pointer to a valid DeletedSuitesRequestType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewDeletedSuitesRequestTypeFromValue(v string) (*DeletedSuitesRequestType, error) { + ev := DeletedSuitesRequestType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for DeletedSuitesRequestType: valid values are %v", v, allowedDeletedSuitesRequestTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v DeletedSuitesRequestType) IsValid() bool { + for _, existing := range allowedDeletedSuitesRequestTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DeletedSuitesRequestType value. +func (v DeletedSuitesRequestType) Ptr() *DeletedSuitesRequestType { + return &v +} diff --git a/api/datadogV2/model_deleted_suites_response.go b/api/datadogV2/model_deleted_suites_response.go new file mode 100644 index 00000000000..f8f4e43aa2c --- /dev/null +++ b/api/datadogV2/model_deleted_suites_response.go @@ -0,0 +1,102 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeletedSuitesResponse +type DeletedSuitesResponse struct { + // + Data []DeletedSuiteResponseData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeletedSuitesResponse instantiates a new DeletedSuitesResponse 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 NewDeletedSuitesResponse() *DeletedSuitesResponse { + this := DeletedSuitesResponse{} + return &this +} + +// NewDeletedSuitesResponseWithDefaults instantiates a new DeletedSuitesResponse 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 NewDeletedSuitesResponseWithDefaults() *DeletedSuitesResponse { + this := DeletedSuitesResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *DeletedSuitesResponse) GetData() []DeletedSuiteResponseData { + if o == nil || o.Data == nil { + var ret []DeletedSuiteResponseData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeletedSuitesResponse) GetDataOk() (*[]DeletedSuiteResponseData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return &o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *DeletedSuitesResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []DeletedSuiteResponseData and assigns it to the Data field. +func (o *DeletedSuitesResponse) SetData(v []DeletedSuiteResponseData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeletedSuitesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeletedSuitesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []DeletedSuiteResponseData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_suite_create_edit.go b/api/datadogV2/model_suite_create_edit.go new file mode 100644 index 00000000000..187a9789943 --- /dev/null +++ b/api/datadogV2/model_suite_create_edit.go @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SuiteCreateEdit +type SuiteCreateEdit struct { + // Object containing details about a Synthetic suite. + Attributes SyntheticsSuite `json:"attributes"` + // Type of the Synthetic suite, `suite`. + Type SyntheticsSuiteType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSuiteCreateEdit instantiates a new SuiteCreateEdit 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 NewSuiteCreateEdit(attributes SyntheticsSuite, typeVar SyntheticsSuiteType) *SuiteCreateEdit { + this := SuiteCreateEdit{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewSuiteCreateEditWithDefaults instantiates a new SuiteCreateEdit 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 NewSuiteCreateEditWithDefaults() *SuiteCreateEdit { + this := SuiteCreateEdit{} + var typeVar SyntheticsSuiteType = SYNTHETICSSUITETYPE_SUITE + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *SuiteCreateEdit) GetAttributes() SyntheticsSuite { + if o == nil { + var ret SyntheticsSuite + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *SuiteCreateEdit) GetAttributesOk() (*SyntheticsSuite, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *SuiteCreateEdit) SetAttributes(v SyntheticsSuite) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *SuiteCreateEdit) GetType() SyntheticsSuiteType { + if o == nil { + var ret SyntheticsSuiteType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SuiteCreateEdit) GetTypeOk() (*SyntheticsSuiteType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SuiteCreateEdit) SetType(v SyntheticsSuiteType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SuiteCreateEdit) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SuiteCreateEdit) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SyntheticsSuite `json:"attributes"` + Type *SyntheticsSuiteType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_suite_create_edit_request.go b/api/datadogV2/model_suite_create_edit_request.go new file mode 100644 index 00000000000..1e464164a9f --- /dev/null +++ b/api/datadogV2/model_suite_create_edit_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SuiteCreateEditRequest +type SuiteCreateEditRequest struct { + // + Data SuiteCreateEdit `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSuiteCreateEditRequest instantiates a new SuiteCreateEditRequest 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 NewSuiteCreateEditRequest(data SuiteCreateEdit) *SuiteCreateEditRequest { + this := SuiteCreateEditRequest{} + this.Data = data + return &this +} + +// NewSuiteCreateEditRequestWithDefaults instantiates a new SuiteCreateEditRequest 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 NewSuiteCreateEditRequestWithDefaults() *SuiteCreateEditRequest { + this := SuiteCreateEditRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *SuiteCreateEditRequest) GetData() SuiteCreateEdit { + if o == nil { + var ret SuiteCreateEdit + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *SuiteCreateEditRequest) GetDataOk() (*SuiteCreateEdit, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *SuiteCreateEditRequest) SetData(v SuiteCreateEdit) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SuiteCreateEditRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SuiteCreateEditRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *SuiteCreateEdit `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_suite_search_response_type.go b/api/datadogV2/model_suite_search_response_type.go new file mode 100644 index 00000000000..a3e02929054 --- /dev/null +++ b/api/datadogV2/model_suite_search_response_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SuiteSearchResponseType +type SuiteSearchResponseType string + +// List of SuiteSearchResponseType. +const ( + SUITESEARCHRESPONSETYPE_SUITES_SEARCH SuiteSearchResponseType = "suites_search" +) + +var allowedSuiteSearchResponseTypeEnumValues = []SuiteSearchResponseType{ + SUITESEARCHRESPONSETYPE_SUITES_SEARCH, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SuiteSearchResponseType) GetAllowedValues() []SuiteSearchResponseType { + return allowedSuiteSearchResponseTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SuiteSearchResponseType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SuiteSearchResponseType(value) + return nil +} + +// NewSuiteSearchResponseTypeFromValue returns a pointer to a valid SuiteSearchResponseType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSuiteSearchResponseTypeFromValue(v string) (*SuiteSearchResponseType, error) { + ev := SuiteSearchResponseType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SuiteSearchResponseType: valid values are %v", v, allowedSuiteSearchResponseTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SuiteSearchResponseType) IsValid() bool { + for _, existing := range allowedSuiteSearchResponseTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SuiteSearchResponseType value. +func (v SuiteSearchResponseType) Ptr() *SuiteSearchResponseType { + return &v +} diff --git a/api/datadogV2/model_synthetics_suite.go b/api/datadogV2/model_synthetics_suite.go new file mode 100644 index 00000000000..08ab68c1e6e --- /dev/null +++ b/api/datadogV2/model_synthetics_suite.go @@ -0,0 +1,314 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuite Object containing details about a Synthetic suite. +type SyntheticsSuite struct { + // Notification message associated with the suite. + Message string `json:"message"` + // Name of the suite. + Name string `json:"name"` + // Object describing the extra options for a Synthetic suite. + Options SyntheticsSuiteOptions `json:"options"` + // The public ID for the test. + PublicId *string `json:"public_id,omitempty"` + // Array of tags attached to the suite. + Tags []string `json:"tags,omitempty"` + // + Tests []SyntheticsSuiteTest `json:"tests"` + // Type of the Synthetic suite, `suite`. + Type SyntheticsSuiteType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsSuite instantiates a new SyntheticsSuite 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 NewSyntheticsSuite(message string, name string, options SyntheticsSuiteOptions, tests []SyntheticsSuiteTest, typeVar SyntheticsSuiteType) *SyntheticsSuite { + this := SyntheticsSuite{} + this.Message = message + this.Name = name + this.Options = options + this.Tests = tests + this.Type = typeVar + return &this +} + +// NewSyntheticsSuiteWithDefaults instantiates a new SyntheticsSuite 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 NewSyntheticsSuiteWithDefaults() *SyntheticsSuite { + this := SyntheticsSuite{} + var typeVar SyntheticsSuiteType = SYNTHETICSSUITETYPE_SUITE + this.Type = typeVar + return &this +} + +// GetMessage returns the Message field value. +func (o *SyntheticsSuite) GetMessage() string { + if o == nil { + var ret string + return ret + } + return o.Message +} + +// GetMessageOk returns a tuple with the Message field value +// and a boolean to check if the value has been set. +func (o *SyntheticsSuite) GetMessageOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Message, true +} + +// SetMessage sets field value. +func (o *SyntheticsSuite) SetMessage(v string) { + o.Message = v +} + +// GetName returns the Name field value. +func (o *SyntheticsSuite) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *SyntheticsSuite) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *SyntheticsSuite) SetName(v string) { + o.Name = v +} + +// GetOptions returns the Options field value. +func (o *SyntheticsSuite) GetOptions() SyntheticsSuiteOptions { + if o == nil { + var ret SyntheticsSuiteOptions + return ret + } + return o.Options +} + +// GetOptionsOk returns a tuple with the Options field value +// and a boolean to check if the value has been set. +func (o *SyntheticsSuite) GetOptionsOk() (*SyntheticsSuiteOptions, bool) { + if o == nil { + return nil, false + } + return &o.Options, true +} + +// SetOptions sets field value. +func (o *SyntheticsSuite) SetOptions(v SyntheticsSuiteOptions) { + o.Options = v +} + +// GetPublicId returns the PublicId field value if set, zero value otherwise. +func (o *SyntheticsSuite) GetPublicId() string { + if o == nil || o.PublicId == nil { + var ret string + return ret + } + return *o.PublicId +} + +// GetPublicIdOk returns a tuple with the PublicId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuite) GetPublicIdOk() (*string, bool) { + if o == nil || o.PublicId == nil { + return nil, false + } + return o.PublicId, true +} + +// HasPublicId returns a boolean if a field has been set. +func (o *SyntheticsSuite) HasPublicId() bool { + return o != nil && o.PublicId != nil +} + +// SetPublicId gets a reference to the given string and assigns it to the PublicId field. +func (o *SyntheticsSuite) SetPublicId(v string) { + o.PublicId = &v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *SyntheticsSuite) GetTags() []string { + if o == nil || o.Tags == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuite) GetTagsOk() (*[]string, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return &o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *SyntheticsSuite) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given []string and assigns it to the Tags field. +func (o *SyntheticsSuite) SetTags(v []string) { + o.Tags = v +} + +// GetTests returns the Tests field value. +func (o *SyntheticsSuite) GetTests() []SyntheticsSuiteTest { + if o == nil { + var ret []SyntheticsSuiteTest + return ret + } + return o.Tests +} + +// GetTestsOk returns a tuple with the Tests field value +// and a boolean to check if the value has been set. +func (o *SyntheticsSuite) GetTestsOk() (*[]SyntheticsSuiteTest, bool) { + if o == nil { + return nil, false + } + return &o.Tests, true +} + +// SetTests sets field value. +func (o *SyntheticsSuite) SetTests(v []SyntheticsSuiteTest) { + o.Tests = v +} + +// GetType returns the Type field value. +func (o *SyntheticsSuite) GetType() SyntheticsSuiteType { + if o == nil { + var ret SyntheticsSuiteType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SyntheticsSuite) GetTypeOk() (*SyntheticsSuiteType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SyntheticsSuite) SetType(v SyntheticsSuiteType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsSuite) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["message"] = o.Message + toSerialize["name"] = o.Name + toSerialize["options"] = o.Options + if o.PublicId != nil { + toSerialize["public_id"] = o.PublicId + } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + toSerialize["tests"] = o.Tests + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsSuite) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Message *string `json:"message"` + Name *string `json:"name"` + Options *SyntheticsSuiteOptions `json:"options"` + PublicId *string `json:"public_id,omitempty"` + Tags []string `json:"tags,omitempty"` + Tests *[]SyntheticsSuiteTest `json:"tests"` + Type *SyntheticsSuiteType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Message == nil { + return fmt.Errorf("required field message missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Options == nil { + return fmt.Errorf("required field options missing") + } + if all.Tests == nil { + return fmt.Errorf("required field tests missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"message", "name", "options", "public_id", "tags", "tests", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Message = *all.Message + o.Name = *all.Name + if all.Options.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Options = *all.Options + o.PublicId = all.PublicId + o.Tags = all.Tags + o.Tests = *all.Tests + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_suite_options.go b/api/datadogV2/model_synthetics_suite_options.go new file mode 100644 index 00000000000..b798f7c37df --- /dev/null +++ b/api/datadogV2/model_synthetics_suite_options.go @@ -0,0 +1,102 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuiteOptions Object describing the extra options for a Synthetic suite. +type SyntheticsSuiteOptions struct { + // Percentage of critical tests failure needed for a suite to fail. + AlertingThreshold *float64 `json:"alerting_threshold,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsSuiteOptions instantiates a new SyntheticsSuiteOptions 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 NewSyntheticsSuiteOptions() *SyntheticsSuiteOptions { + this := SyntheticsSuiteOptions{} + return &this +} + +// NewSyntheticsSuiteOptionsWithDefaults instantiates a new SyntheticsSuiteOptions 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 NewSyntheticsSuiteOptionsWithDefaults() *SyntheticsSuiteOptions { + this := SyntheticsSuiteOptions{} + return &this +} + +// GetAlertingThreshold returns the AlertingThreshold field value if set, zero value otherwise. +func (o *SyntheticsSuiteOptions) GetAlertingThreshold() float64 { + if o == nil || o.AlertingThreshold == nil { + var ret float64 + return ret + } + return *o.AlertingThreshold +} + +// GetAlertingThresholdOk returns a tuple with the AlertingThreshold field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteOptions) GetAlertingThresholdOk() (*float64, bool) { + if o == nil || o.AlertingThreshold == nil { + return nil, false + } + return o.AlertingThreshold, true +} + +// HasAlertingThreshold returns a boolean if a field has been set. +func (o *SyntheticsSuiteOptions) HasAlertingThreshold() bool { + return o != nil && o.AlertingThreshold != nil +} + +// SetAlertingThreshold gets a reference to the given float64 and assigns it to the AlertingThreshold field. +func (o *SyntheticsSuiteOptions) SetAlertingThreshold(v float64) { + o.AlertingThreshold = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsSuiteOptions) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AlertingThreshold != nil { + toSerialize["alerting_threshold"] = o.AlertingThreshold + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsSuiteOptions) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AlertingThreshold *float64 `json:"alerting_threshold,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"alerting_threshold"}) + } else { + return err + } + o.AlertingThreshold = all.AlertingThreshold + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_suite_response.go b/api/datadogV2/model_synthetics_suite_response.go new file mode 100644 index 00000000000..da449c26198 --- /dev/null +++ b/api/datadogV2/model_synthetics_suite_response.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuiteResponse Synthetics suite response +type SyntheticsSuiteResponse struct { + // Synthetics suite response data + Data *SyntheticsSuiteResponseData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsSuiteResponse instantiates a new SyntheticsSuiteResponse 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 NewSyntheticsSuiteResponse() *SyntheticsSuiteResponse { + this := SyntheticsSuiteResponse{} + return &this +} + +// NewSyntheticsSuiteResponseWithDefaults instantiates a new SyntheticsSuiteResponse 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 NewSyntheticsSuiteResponseWithDefaults() *SyntheticsSuiteResponse { + this := SyntheticsSuiteResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *SyntheticsSuiteResponse) GetData() SyntheticsSuiteResponseData { + if o == nil || o.Data == nil { + var ret SyntheticsSuiteResponseData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteResponse) GetDataOk() (*SyntheticsSuiteResponseData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *SyntheticsSuiteResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given SyntheticsSuiteResponseData and assigns it to the Data field. +func (o *SyntheticsSuiteResponse) SetData(v SyntheticsSuiteResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsSuiteResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsSuiteResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *SyntheticsSuiteResponseData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_suite_response_data.go b/api/datadogV2/model_synthetics_suite_response_data.go new file mode 100644 index 00000000000..0b34996538f --- /dev/null +++ b/api/datadogV2/model_synthetics_suite_response_data.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuiteResponseData Synthetics suite response data +type SyntheticsSuiteResponseData struct { + // Object containing details about a Synthetic suite. + Attributes *SyntheticsSuite `json:"attributes,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsSuiteResponseData instantiates a new SyntheticsSuiteResponseData 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 NewSyntheticsSuiteResponseData() *SyntheticsSuiteResponseData { + this := SyntheticsSuiteResponseData{} + return &this +} + +// NewSyntheticsSuiteResponseDataWithDefaults instantiates a new SyntheticsSuiteResponseData 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 NewSyntheticsSuiteResponseDataWithDefaults() *SyntheticsSuiteResponseData { + this := SyntheticsSuiteResponseData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *SyntheticsSuiteResponseData) GetAttributes() SyntheticsSuite { + if o == nil || o.Attributes == nil { + var ret SyntheticsSuite + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteResponseData) GetAttributesOk() (*SyntheticsSuite, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *SyntheticsSuiteResponseData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given SyntheticsSuite and assigns it to the Attributes field. +func (o *SyntheticsSuiteResponseData) SetAttributes(v SyntheticsSuite) { + o.Attributes = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsSuiteResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsSuiteResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SyntheticsSuite `json:"attributes,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_suite_search_response.go b/api/datadogV2/model_synthetics_suite_search_response.go new file mode 100644 index 00000000000..98f73e1d557 --- /dev/null +++ b/api/datadogV2/model_synthetics_suite_search_response.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuiteSearchResponse Synthetics suite search response +type SyntheticsSuiteSearchResponse struct { + // Synthetics suite search response data + Data *SyntheticsSuiteSearchResponseData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsSuiteSearchResponse instantiates a new SyntheticsSuiteSearchResponse 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 NewSyntheticsSuiteSearchResponse() *SyntheticsSuiteSearchResponse { + this := SyntheticsSuiteSearchResponse{} + return &this +} + +// NewSyntheticsSuiteSearchResponseWithDefaults instantiates a new SyntheticsSuiteSearchResponse 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 NewSyntheticsSuiteSearchResponseWithDefaults() *SyntheticsSuiteSearchResponse { + this := SyntheticsSuiteSearchResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *SyntheticsSuiteSearchResponse) GetData() SyntheticsSuiteSearchResponseData { + if o == nil || o.Data == nil { + var ret SyntheticsSuiteSearchResponseData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteSearchResponse) GetDataOk() (*SyntheticsSuiteSearchResponseData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *SyntheticsSuiteSearchResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given SyntheticsSuiteSearchResponseData and assigns it to the Data field. +func (o *SyntheticsSuiteSearchResponse) SetData(v SyntheticsSuiteSearchResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsSuiteSearchResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsSuiteSearchResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *SyntheticsSuiteSearchResponseData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_suite_search_response_data.go b/api/datadogV2/model_synthetics_suite_search_response_data.go new file mode 100644 index 00000000000..0e91be0e722 --- /dev/null +++ b/api/datadogV2/model_synthetics_suite_search_response_data.go @@ -0,0 +1,191 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuiteSearchResponseData Synthetics suite search response data +type SyntheticsSuiteSearchResponseData struct { + // Synthetics suite search response data attributes + Attributes *SyntheticsSuiteSearchResponseDataAttributes `json:"attributes,omitempty"` + // + Id *uuid.UUID `json:"id,omitempty"` + // + Type *SuiteSearchResponseType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsSuiteSearchResponseData instantiates a new SyntheticsSuiteSearchResponseData 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 NewSyntheticsSuiteSearchResponseData() *SyntheticsSuiteSearchResponseData { + this := SyntheticsSuiteSearchResponseData{} + var typeVar SuiteSearchResponseType = SUITESEARCHRESPONSETYPE_SUITES_SEARCH + this.Type = &typeVar + return &this +} + +// NewSyntheticsSuiteSearchResponseDataWithDefaults instantiates a new SyntheticsSuiteSearchResponseData 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 NewSyntheticsSuiteSearchResponseDataWithDefaults() *SyntheticsSuiteSearchResponseData { + this := SyntheticsSuiteSearchResponseData{} + var typeVar SuiteSearchResponseType = SUITESEARCHRESPONSETYPE_SUITES_SEARCH + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *SyntheticsSuiteSearchResponseData) GetAttributes() SyntheticsSuiteSearchResponseDataAttributes { + if o == nil || o.Attributes == nil { + var ret SyntheticsSuiteSearchResponseDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteSearchResponseData) GetAttributesOk() (*SyntheticsSuiteSearchResponseDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *SyntheticsSuiteSearchResponseData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given SyntheticsSuiteSearchResponseDataAttributes and assigns it to the Attributes field. +func (o *SyntheticsSuiteSearchResponseData) SetAttributes(v SyntheticsSuiteSearchResponseDataAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *SyntheticsSuiteSearchResponseData) GetId() uuid.UUID { + if o == nil || o.Id == nil { + var ret uuid.UUID + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteSearchResponseData) GetIdOk() (*uuid.UUID, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *SyntheticsSuiteSearchResponseData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given uuid.UUID and assigns it to the Id field. +func (o *SyntheticsSuiteSearchResponseData) SetId(v uuid.UUID) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *SyntheticsSuiteSearchResponseData) GetType() SuiteSearchResponseType { + if o == nil || o.Type == nil { + var ret SuiteSearchResponseType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteSearchResponseData) GetTypeOk() (*SuiteSearchResponseType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *SyntheticsSuiteSearchResponseData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given SuiteSearchResponseType and assigns it to the Type field. +func (o *SyntheticsSuiteSearchResponseData) SetType(v SuiteSearchResponseType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsSuiteSearchResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsSuiteSearchResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SyntheticsSuiteSearchResponseDataAttributes `json:"attributes,omitempty"` + Id *uuid.UUID `json:"id,omitempty"` + Type *SuiteSearchResponseType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_suite_search_response_data_attributes.go b/api/datadogV2/model_synthetics_suite_search_response_data_attributes.go new file mode 100644 index 00000000000..ec7a51dbdae --- /dev/null +++ b/api/datadogV2/model_synthetics_suite_search_response_data_attributes.go @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuiteSearchResponseDataAttributes Synthetics suite search response data attributes +type SyntheticsSuiteSearchResponseDataAttributes struct { + // + Suites []SyntheticsSuite `json:"suites,omitempty"` + // + Total *int32 `json:"total,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsSuiteSearchResponseDataAttributes instantiates a new SyntheticsSuiteSearchResponseDataAttributes 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 NewSyntheticsSuiteSearchResponseDataAttributes() *SyntheticsSuiteSearchResponseDataAttributes { + this := SyntheticsSuiteSearchResponseDataAttributes{} + return &this +} + +// NewSyntheticsSuiteSearchResponseDataAttributesWithDefaults instantiates a new SyntheticsSuiteSearchResponseDataAttributes 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 NewSyntheticsSuiteSearchResponseDataAttributesWithDefaults() *SyntheticsSuiteSearchResponseDataAttributes { + this := SyntheticsSuiteSearchResponseDataAttributes{} + return &this +} + +// GetSuites returns the Suites field value if set, zero value otherwise. +func (o *SyntheticsSuiteSearchResponseDataAttributes) GetSuites() []SyntheticsSuite { + if o == nil || o.Suites == nil { + var ret []SyntheticsSuite + return ret + } + return o.Suites +} + +// GetSuitesOk returns a tuple with the Suites field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteSearchResponseDataAttributes) GetSuitesOk() (*[]SyntheticsSuite, bool) { + if o == nil || o.Suites == nil { + return nil, false + } + return &o.Suites, true +} + +// HasSuites returns a boolean if a field has been set. +func (o *SyntheticsSuiteSearchResponseDataAttributes) HasSuites() bool { + return o != nil && o.Suites != nil +} + +// SetSuites gets a reference to the given []SyntheticsSuite and assigns it to the Suites field. +func (o *SyntheticsSuiteSearchResponseDataAttributes) SetSuites(v []SyntheticsSuite) { + o.Suites = v +} + +// GetTotal returns the Total field value if set, zero value otherwise. +func (o *SyntheticsSuiteSearchResponseDataAttributes) GetTotal() int32 { + if o == nil || o.Total == nil { + var ret int32 + return ret + } + return *o.Total +} + +// GetTotalOk returns a tuple with the Total field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteSearchResponseDataAttributes) GetTotalOk() (*int32, bool) { + if o == nil || o.Total == nil { + return nil, false + } + return o.Total, true +} + +// HasTotal returns a boolean if a field has been set. +func (o *SyntheticsSuiteSearchResponseDataAttributes) HasTotal() bool { + return o != nil && o.Total != nil +} + +// SetTotal gets a reference to the given int32 and assigns it to the Total field. +func (o *SyntheticsSuiteSearchResponseDataAttributes) SetTotal(v int32) { + o.Total = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsSuiteSearchResponseDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Suites != nil { + toSerialize["suites"] = o.Suites + } + if o.Total != nil { + toSerialize["total"] = o.Total + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsSuiteSearchResponseDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Suites []SyntheticsSuite `json:"suites,omitempty"` + Total *int32 `json:"total,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"suites", "total"}) + } else { + return err + } + o.Suites = all.Suites + o.Total = all.Total + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_suite_test_.go b/api/datadogV2/model_synthetics_suite_test_.go new file mode 100644 index 00000000000..62d945a03aa --- /dev/null +++ b/api/datadogV2/model_synthetics_suite_test_.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuiteTest Object containing details about a Synthetic test included in a Synthetic suite. +type SyntheticsSuiteTest struct { + // Alerting criticality for each the test. + AlertingCriticality *SyntheticsSuiteTestAlertingCriticality `json:"alerting_criticality,omitempty"` + // + PublicId string `json:"public_id"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSyntheticsSuiteTest instantiates a new SyntheticsSuiteTest 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 NewSyntheticsSuiteTest(publicId string) *SyntheticsSuiteTest { + this := SyntheticsSuiteTest{} + this.PublicId = publicId + return &this +} + +// NewSyntheticsSuiteTestWithDefaults instantiates a new SyntheticsSuiteTest 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 NewSyntheticsSuiteTestWithDefaults() *SyntheticsSuiteTest { + this := SyntheticsSuiteTest{} + return &this +} + +// GetAlertingCriticality returns the AlertingCriticality field value if set, zero value otherwise. +func (o *SyntheticsSuiteTest) GetAlertingCriticality() SyntheticsSuiteTestAlertingCriticality { + if o == nil || o.AlertingCriticality == nil { + var ret SyntheticsSuiteTestAlertingCriticality + return ret + } + return *o.AlertingCriticality +} + +// GetAlertingCriticalityOk returns a tuple with the AlertingCriticality field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteTest) GetAlertingCriticalityOk() (*SyntheticsSuiteTestAlertingCriticality, bool) { + if o == nil || o.AlertingCriticality == nil { + return nil, false + } + return o.AlertingCriticality, true +} + +// HasAlertingCriticality returns a boolean if a field has been set. +func (o *SyntheticsSuiteTest) HasAlertingCriticality() bool { + return o != nil && o.AlertingCriticality != nil +} + +// SetAlertingCriticality gets a reference to the given SyntheticsSuiteTestAlertingCriticality and assigns it to the AlertingCriticality field. +func (o *SyntheticsSuiteTest) SetAlertingCriticality(v SyntheticsSuiteTestAlertingCriticality) { + o.AlertingCriticality = &v +} + +// GetPublicId returns the PublicId field value. +func (o *SyntheticsSuiteTest) GetPublicId() string { + if o == nil { + var ret string + return ret + } + return o.PublicId +} + +// GetPublicIdOk returns a tuple with the PublicId field value +// and a boolean to check if the value has been set. +func (o *SyntheticsSuiteTest) GetPublicIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PublicId, true +} + +// SetPublicId sets field value. +func (o *SyntheticsSuiteTest) SetPublicId(v string) { + o.PublicId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SyntheticsSuiteTest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AlertingCriticality != nil { + toSerialize["alerting_criticality"] = o.AlertingCriticality + } + toSerialize["public_id"] = o.PublicId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SyntheticsSuiteTest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AlertingCriticality *SyntheticsSuiteTestAlertingCriticality `json:"alerting_criticality,omitempty"` + PublicId *string `json:"public_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.PublicId == nil { + return fmt.Errorf("required field public_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"alerting_criticality", "public_id"}) + } else { + return err + } + + hasInvalidField := false + if all.AlertingCriticality != nil && !all.AlertingCriticality.IsValid() { + hasInvalidField = true + } else { + o.AlertingCriticality = all.AlertingCriticality + } + o.PublicId = *all.PublicId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_synthetics_suite_test_alerting_criticality.go b/api/datadogV2/model_synthetics_suite_test_alerting_criticality.go new file mode 100644 index 00000000000..ec834d708c5 --- /dev/null +++ b/api/datadogV2/model_synthetics_suite_test_alerting_criticality.go @@ -0,0 +1,66 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuiteTestAlertingCriticality Alerting criticality for each the test. +type SyntheticsSuiteTestAlertingCriticality string + +// List of SyntheticsSuiteTestAlertingCriticality. +const ( + SYNTHETICSSUITETESTALERTINGCRITICALITY_IGNORE SyntheticsSuiteTestAlertingCriticality = "ignore" + SYNTHETICSSUITETESTALERTINGCRITICALITY_CRITICAL SyntheticsSuiteTestAlertingCriticality = "critical" +) + +var allowedSyntheticsSuiteTestAlertingCriticalityEnumValues = []SyntheticsSuiteTestAlertingCriticality{ + SYNTHETICSSUITETESTALERTINGCRITICALITY_IGNORE, + SYNTHETICSSUITETESTALERTINGCRITICALITY_CRITICAL, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SyntheticsSuiteTestAlertingCriticality) GetAllowedValues() []SyntheticsSuiteTestAlertingCriticality { + return allowedSyntheticsSuiteTestAlertingCriticalityEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SyntheticsSuiteTestAlertingCriticality) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SyntheticsSuiteTestAlertingCriticality(value) + return nil +} + +// NewSyntheticsSuiteTestAlertingCriticalityFromValue returns a pointer to a valid SyntheticsSuiteTestAlertingCriticality +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSyntheticsSuiteTestAlertingCriticalityFromValue(v string) (*SyntheticsSuiteTestAlertingCriticality, error) { + ev := SyntheticsSuiteTestAlertingCriticality(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SyntheticsSuiteTestAlertingCriticality: valid values are %v", v, allowedSyntheticsSuiteTestAlertingCriticalityEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SyntheticsSuiteTestAlertingCriticality) IsValid() bool { + for _, existing := range allowedSyntheticsSuiteTestAlertingCriticalityEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SyntheticsSuiteTestAlertingCriticality value. +func (v SyntheticsSuiteTestAlertingCriticality) Ptr() *SyntheticsSuiteTestAlertingCriticality { + return &v +} diff --git a/api/datadogV2/model_synthetics_suite_type.go b/api/datadogV2/model_synthetics_suite_type.go new file mode 100644 index 00000000000..fa261cefb2a --- /dev/null +++ b/api/datadogV2/model_synthetics_suite_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SyntheticsSuiteType Type of the Synthetic suite, `suite`. +type SyntheticsSuiteType string + +// List of SyntheticsSuiteType. +const ( + SYNTHETICSSUITETYPE_SUITE SyntheticsSuiteType = "suite" +) + +var allowedSyntheticsSuiteTypeEnumValues = []SyntheticsSuiteType{ + SYNTHETICSSUITETYPE_SUITE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SyntheticsSuiteType) GetAllowedValues() []SyntheticsSuiteType { + return allowedSyntheticsSuiteTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SyntheticsSuiteType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SyntheticsSuiteType(value) + return nil +} + +// NewSyntheticsSuiteTypeFromValue returns a pointer to a valid SyntheticsSuiteType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSyntheticsSuiteTypeFromValue(v string) (*SyntheticsSuiteType, error) { + ev := SyntheticsSuiteType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SyntheticsSuiteType: valid values are %v", v, allowedSyntheticsSuiteTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SyntheticsSuiteType) IsValid() bool { + for _, existing := range allowedSyntheticsSuiteTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SyntheticsSuiteType value. +func (v SyntheticsSuiteType) Ptr() *SyntheticsSuiteType { + return &v +} diff --git a/examples/v2/synthetics/CreateSyntheticsSuite.go b/examples/v2/synthetics/CreateSyntheticsSuite.go new file mode 100644 index 00000000000..41c71eb52c1 --- /dev/null +++ b/examples/v2/synthetics/CreateSyntheticsSuite.go @@ -0,0 +1,44 @@ +// Synthetics: Create a test suite returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.SuiteCreateEditRequest{ + Data: datadogV2.SuiteCreateEdit{ + Attributes: datadogV2.SyntheticsSuite{ + Message: "Notification message", + Name: "Example suite name", + Options: datadogV2.SyntheticsSuiteOptions{}, + Tags: []string{ + "env:production", + }, + Tests: []datadogV2.SyntheticsSuiteTest{}, + Type: datadogV2.SYNTHETICSSUITETYPE_SUITE, + }, + Type: datadogV2.SYNTHETICSSUITETYPE_SUITE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.CreateSyntheticsSuite(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateSyntheticsSuite`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateSyntheticsSuite`:\n%s\n", responseContent) +} diff --git a/examples/v2/synthetics/DeleteSyntheticsSuites.go b/examples/v2/synthetics/DeleteSyntheticsSuites.go new file mode 100644 index 00000000000..2d45b580abf --- /dev/null +++ b/examples/v2/synthetics/DeleteSyntheticsSuites.go @@ -0,0 +1,39 @@ +// Synthetics: Bulk delete suites returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.DeletedSuitesRequestDeleteRequest{ + Data: datadogV2.DeletedSuitesRequestDelete{ + Attributes: datadogV2.DeletedSuitesRequestDeleteAttributes{ + PublicIds: []string{ + "", + }, + }, + Type: datadogV2.DELETEDSUITESREQUESTTYPE_DELETE_SUITES_REQUEST.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.DeleteSyntheticsSuites(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.DeleteSyntheticsSuites`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.DeleteSyntheticsSuites`:\n%s\n", responseContent) +} diff --git a/examples/v2/synthetics/EditSyntheticsSuite.go b/examples/v2/synthetics/EditSyntheticsSuite.go new file mode 100644 index 00000000000..9702b3c5d55 --- /dev/null +++ b/examples/v2/synthetics/EditSyntheticsSuite.go @@ -0,0 +1,49 @@ +// Synthetics: edit a test suite returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.SuiteCreateEditRequest{ + Data: datadogV2.SuiteCreateEdit{ + Attributes: datadogV2.SyntheticsSuite{ + Message: "Notification message", + Name: "Example suite name", + Options: datadogV2.SyntheticsSuiteOptions{}, + Tags: []string{ + "env:production", + }, + Tests: []datadogV2.SyntheticsSuiteTest{ + { + AlertingCriticality: datadogV2.SYNTHETICSSUITETESTALERTINGCRITICALITY_CRITICAL.Ptr(), + PublicId: "", + }, + }, + Type: datadogV2.SYNTHETICSSUITETYPE_SUITE, + }, + Type: datadogV2.SYNTHETICSSUITETYPE_SUITE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.EditSyntheticsSuite(ctx, "public_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.EditSyntheticsSuite`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.EditSyntheticsSuite`:\n%s\n", responseContent) +} diff --git a/examples/v2/synthetics/GetSyntheticsSuite.go b/examples/v2/synthetics/GetSyntheticsSuite.go new file mode 100644 index 00000000000..12abbdf9423 --- /dev/null +++ b/examples/v2/synthetics/GetSyntheticsSuite.go @@ -0,0 +1,29 @@ +// Synthetics: Get a suite returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.GetSyntheticsSuite(ctx, "public_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.GetSyntheticsSuite`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.GetSyntheticsSuite`:\n%s\n", responseContent) +} diff --git a/examples/v2/synthetics/SearchSuites.go b/examples/v2/synthetics/SearchSuites.go new file mode 100644 index 00000000000..317f3ce1f82 --- /dev/null +++ b/examples/v2/synthetics/SearchSuites.go @@ -0,0 +1,29 @@ +// Search Synthetics suites returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSyntheticsApi(apiClient) + resp, r, err := api.SearchSuites(ctx, *datadogV2.NewSearchSuitesOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.SearchSuites`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.SearchSuites`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/synthetics.feature b/tests/scenarios/features/v2/synthetics.feature index 73efa73ec29..4df8a547f68 100644 --- a/tests/scenarios/features/v2/synthetics.feature +++ b/tests/scenarios/features/v2/synthetics.feature @@ -27,3 +27,73 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK And the response "data.attributes.on_demand_concurrency_cap" is equal to 20 + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Search Synthetics suites returns "API error response." response + Given new "SearchSuites" request + When the request is sent + Then the response status is 400 API error response. + + @team:DataDog/synthetics-managing + Scenario: Search Synthetics suites returns "OK" response + Given new "SearchSuites" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Bulk delete suites returns "API error response." response + Given new "DeleteSyntheticsSuites" request + And body with value {"data": {"attributes": {"public_ids": [""]}, "type": "delete_suites_request"}} + When the request is sent + Then the response status is 400 API error response. + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Bulk delete suites returns "OK" response + Given new "DeleteSyntheticsSuites" request + And body with value {"data": {"attributes": {"public_ids": [""]}, "type": "delete_suites_request"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Create a test suite returns "API error response." response + Given new "CreateSyntheticsSuite" request + And body with value {"data": {"attributes": {"message": "Notification message", "name": "Example suite name", "options": {}, "tags": ["env:production"], "tests": [{"alerting_criticality": "critical", "public_id": ""}], "type": "suite"}, "type": "suite"}} + When the request is sent + Then the response status is 400 API error response. + + @team:DataDog/synthetics-managing + Scenario: Synthetics: Create a test suite returns "OK" response + Given new "CreateSyntheticsSuite" request + And body with value {"data": {"attributes": {"message": "Notification message", "name": "Example suite name", "options": {}, "tags": ["env:production"], "tests": [], "type": "suite"}, "type": "suite"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Get a suite returns "API error response." response + Given new "GetSyntheticsSuite" request + And request contains "public_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 API error response. + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: Get a suite returns "OK" response + Given new "GetSyntheticsSuite" request + And request contains "public_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: edit a test suite returns "API error response." response + Given new "EditSyntheticsSuite" request + And request contains "public_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"message": "Notification message", "name": "Example suite name", "options": {}, "tags": ["env:production"], "tests": [{"alerting_criticality": "critical", "public_id": ""}], "type": "suite"}, "type": "suite"}} + When the request is sent + Then the response status is 400 API error response. + + @generated @skip @team:DataDog/synthetics-managing + Scenario: Synthetics: edit a test suite returns "OK" response + Given new "EditSyntheticsSuite" request + And request contains "public_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"message": "Notification message", "name": "Example suite name", "options": {}, "tags": ["env:production"], "tests": [{"alerting_criticality": "critical", "public_id": ""}], "type": "suite"}, "type": "suite"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 98885927ff9..1fbea5365c2 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4413,6 +4413,43 @@ "type": "safe" } }, + "CreateSyntheticsSuite": { + "tag": "Synthetics", + "undo": { + "operationId": "DeleteSyntheticsSuites", + "parameters": [ + { + "name": "body", + "template": "{\"data\": {\"type\": \"delete_suites_request\", \"attributes\": {\"public_ids\": [\"{{ public_id }}\"]}}" + } + ], + "type": "unsafe" + } + }, + "DeleteSyntheticsSuites": { + "tag": "Synthetics", + "undo": { + "type": "idempotent" + } + }, + "SearchSuites": { + "tag": "Synthetics", + "undo": { + "type": "safe" + } + }, + "GetSyntheticsSuite": { + "tag": "Synthetics", + "undo": { + "type": "safe" + } + }, + "EditSyntheticsSuite": { + "tag": "Synthetics", + "undo": { + "type": "idempotent" + } + }, "ListTagPipelinesRulesets": { "tag": "Cloud Cost Management", "undo": {