diff --git a/.apigentools-info b/.apigentools-info index fdc8bacfa52..6ee28a42d8b 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-03-12 18:41:32.257003", - "spec_repo_commit": "32fcfc91" + "regenerated": "2024-03-13 14:23:25.916188", + "spec_repo_commit": "113614d8" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-03-12 18:41:32.284410", - "spec_repo_commit": "32fcfc91" + "regenerated": "2024-03-13 14:23:25.943035", + "spec_repo_commit": "113614d8" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 90fbd2bfc1b..f1c186a8563 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -195,6 +195,13 @@ components: required: true schema: type: string + CustomDestinationId: + description: The ID of the custom destination. + in: path + name: custom_destination_id + required: true + schema: + type: string FastlyAccountID: description: Fastly Account id. in: path @@ -5341,6 +5348,621 @@ components: nullable: true type: string type: object + CustomDestinationAttributeTagsRestrictionListType: + default: ALLOW_LIST + description: 'How `forward_tags_restriction_list` parameter should be interpreted. + + If `ALLOW_LIST`, then only tags whose keys on the forwarded logs match the + ones on the restriction list + + are forwarded. + + + `BLOCK_LIST` works the opposite way. It does not forward the tags matching + the ones on the list.' + enum: + - ALLOW_LIST + - BLOCK_LIST + example: ALLOW_LIST + type: string + x-enum-varnames: + - ALLOW_LIST + - BLOCK_LIST + CustomDestinationCreateRequest: + description: The custom destination. + properties: + data: + $ref: '#/components/schemas/CustomDestinationCreateRequestDefinition' + type: object + CustomDestinationCreateRequestAttributes: + description: The attributes associated with the custom destination. + properties: + enabled: + default: true + description: Whether logs matching this custom destination should be forwarded + or not. + example: true + type: boolean + forward_tags: + default: true + description: Whether tags from the forwarded logs should be forwarded or + not. + example: true + type: boolean + forward_tags_restriction_list: + default: [] + description: 'List of [keys of tags](https://docs.datadoghq.com/getting_started/tagging/#define-tags) + to be filtered. + + + An empty list represents no restriction is in place and either all or + no tags will be + + forwarded depending on `forward_tags_restriction_list_type` parameter.' + example: + - datacenter + - host + items: + description: The [key part of a tag](https://docs.datadoghq.com/getting_started/tagging/#define-tags). + type: string + maxItems: 10 + minItems: 0 + type: array + forward_tags_restriction_list_type: + $ref: '#/components/schemas/CustomDestinationAttributeTagsRestrictionListType' + forwarder_destination: + $ref: '#/components/schemas/CustomDestinationForwardDestination' + name: + description: The custom destination name. + example: Nginx logs + type: string + query: + default: '' + description: The custom destination query and filter. Logs matching this + query are forwarded to the destination. + example: source:nginx + type: string + required: + - name + - forwarder_destination + type: object + CustomDestinationCreateRequestDefinition: + description: The definition of a custom destination. + properties: + attributes: + $ref: '#/components/schemas/CustomDestinationCreateRequestAttributes' + type: + $ref: '#/components/schemas/CustomDestinationType' + required: + - type + - attributes + type: object + CustomDestinationElasticsearchDestinationAuth: + description: Basic access authentication. + properties: + password: + description: The password of the authentication. This field is not returned + by the API. + example: datadog-custom-destination-password + type: string + writeOnly: true + username: + description: The username of the authentication. This field is not returned + by the API. + example: datadog-custom-destination-username + type: string + writeOnly: true + required: + - username + - password + type: object + CustomDestinationForwardDestination: + description: A custom destination's location to forward logs. + oneOf: + - $ref: '#/components/schemas/CustomDestinationForwardDestinationHttp' + - $ref: '#/components/schemas/CustomDestinationForwardDestinationSplunk' + - $ref: '#/components/schemas/CustomDestinationForwardDestinationElasticsearch' + type: object + CustomDestinationForwardDestinationElasticsearch: + description: The Elasticsearch destination. + properties: + auth: + $ref: '#/components/schemas/CustomDestinationElasticsearchDestinationAuth' + endpoint: + description: 'The destination for which logs will be forwarded to. + + Must have HTTPS scheme and forwarding back to Datadog is not allowed.' + example: https://example.com + type: string + index_name: + description: Name of the Elasticsearch index (must follow [Elasticsearch's + criteria](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/indices-create-index.html#indices-create-api-path-params)). + example: nginx-logs + type: string + index_rotation: + description: 'Date pattern with US locale and UTC timezone to be appended + to the index name after adding `-` + + (that is, `${index_name}-${indexPattern}`). + + You can customize the index rotation naming pattern by choosing one of + these options: + + - Hourly: `yyyy-MM-dd-HH` (as an example, it would render: `2022-10-19-09`) + + - Daily: `yyyy-MM-dd` (as an example, it would render: `2022-10-19`) + + - Weekly: `yyyy-''W''ww` (as an example, it would render: `2022-W42`) + + - Monthly: `yyyy-MM` (as an example, it would render: `2022-10`) + + + If this field is missing or is blank, it means that the index name will + always be the same + + (that is, no rotation).' + example: yyyy-MM-dd + type: string + type: + $ref: '#/components/schemas/CustomDestinationForwardDestinationElasticsearchType' + required: + - type + - endpoint + - auth + - index_name + type: object + CustomDestinationForwardDestinationElasticsearchType: + default: elasticsearch + description: Type of the Elasticsearch destination. + enum: + - elasticsearch + example: elasticsearch + type: string + x-enum-varnames: + - ELASTICSEARCH + CustomDestinationForwardDestinationHttp: + description: The HTTP destination. + properties: + auth: + $ref: '#/components/schemas/CustomDestinationHttpDestinationAuth' + endpoint: + description: 'The destination for which logs will be forwarded to. + + Must have HTTPS scheme and forwarding back to Datadog is not allowed.' + example: https://example.com + type: string + type: + $ref: '#/components/schemas/CustomDestinationForwardDestinationHttpType' + required: + - type + - endpoint + - auth + type: object + CustomDestinationForwardDestinationHttpType: + default: http + description: Type of the HTTP destination. + enum: + - http + example: http + type: string + x-enum-varnames: + - HTTP + CustomDestinationForwardDestinationSplunk: + description: The Splunk HTTP Event Collector (HEC) destination. + properties: + access_token: + description: Access token of the Splunk HTTP Event Collector. This field + is not returned by the API. + example: splunk_access_token + type: string + writeOnly: true + endpoint: + description: 'The destination for which logs will be forwarded to. + + Must have HTTPS scheme and forwarding back to Datadog is not allowed.' + example: https://example.com + type: string + type: + $ref: '#/components/schemas/CustomDestinationForwardDestinationSplunkType' + required: + - type + - endpoint + - access_token + type: object + CustomDestinationForwardDestinationSplunkType: + default: splunk_hec + description: Type of the Splunk HTTP Event Collector (HEC) destination. + enum: + - splunk_hec + example: splunk_hec + type: string + x-enum-varnames: + - SPLUNK_HEC + CustomDestinationHttpDestinationAuth: + description: Authentication method of the HTTP requests. + oneOf: + - $ref: '#/components/schemas/CustomDestinationHttpDestinationAuthBasic' + - $ref: '#/components/schemas/CustomDestinationHttpDestinationAuthCustomHeader' + type: object + CustomDestinationHttpDestinationAuthBasic: + description: Basic access authentication. + properties: + password: + description: The password of the authentication. This field is not returned + by the API. + example: datadog-custom-destination-password + type: string + writeOnly: true + type: + $ref: '#/components/schemas/CustomDestinationHttpDestinationAuthBasicType' + username: + description: The username of the authentication. This field is not returned + by the API. + example: datadog-custom-destination-username + type: string + writeOnly: true + required: + - type + - username + - password + type: object + CustomDestinationHttpDestinationAuthBasicType: + default: basic + description: Type of the basic access authentication. + enum: + - basic + example: basic + type: string + x-enum-varnames: + - BASIC + CustomDestinationHttpDestinationAuthCustomHeader: + description: Custom header access authentication. + properties: + header_name: + description: The header name of the authentication. + example: CUSTOM-HEADER-NAME + type: string + header_value: + description: The header value of the authentication. This field is not returned + by the API. + example: CUSTOM-HEADER-AUTHENTICATION-VALUE + type: string + writeOnly: true + type: + $ref: '#/components/schemas/CustomDestinationHttpDestinationAuthCustomHeaderType' + required: + - type + - header_name + - header_value + type: object + CustomDestinationHttpDestinationAuthCustomHeaderType: + default: custom_header + description: Type of the custom header access authentication. + enum: + - custom_header + example: custom_header + type: string + x-enum-varnames: + - CUSTOM_HEADER + CustomDestinationResponse: + description: The custom destination. + properties: + data: + $ref: '#/components/schemas/CustomDestinationResponseDefinition' + type: object + CustomDestinationResponseAttributes: + description: The attributes associated with the custom destination. + properties: + enabled: + default: true + description: Whether logs matching this custom destination should be forwarded + or not. + example: true + type: boolean + forward_tags: + default: true + description: Whether tags from the forwarded logs should be forwarded or + not. + example: true + type: boolean + forward_tags_restriction_list: + default: [] + description: 'List of [keys of tags](https://docs.datadoghq.com/getting_started/tagging/#define-tags) + to be filtered. + + + An empty list represents no restriction is in place and either all or + no tags will be + + forwarded depending on `forward_tags_restriction_list_type` parameter.' + example: + - datacenter + - host + items: + description: The [key part of a tag](https://docs.datadoghq.com/getting_started/tagging/#define-tags). + type: string + maxItems: 10 + minItems: 0 + type: array + forward_tags_restriction_list_type: + $ref: '#/components/schemas/CustomDestinationAttributeTagsRestrictionListType' + forwarder_destination: + $ref: '#/components/schemas/CustomDestinationResponseForwardDestination' + name: + description: The custom destination name. + example: Nginx logs + type: string + query: + default: '' + description: The custom destination query filter. Logs matching this query + are forwarded to the destination. + example: source:nginx + type: string + type: object + CustomDestinationResponseDefinition: + description: The definition of a custom destination. + properties: + attributes: + $ref: '#/components/schemas/CustomDestinationResponseAttributes' + id: + description: The custom destination ID. + example: be5d7a69-d0c8-4d4d-8ee8-bba292d98139 + readOnly: true + type: string + type: + $ref: '#/components/schemas/CustomDestinationType' + type: object + CustomDestinationResponseElasticsearchDestinationAuth: + additionalProperties: + description: Basic access authentication. + description: Basic access authentication. + type: object + CustomDestinationResponseForwardDestination: + description: A custom destination's location to forward logs. + oneOf: + - $ref: '#/components/schemas/CustomDestinationResponseForwardDestinationHttp' + - $ref: '#/components/schemas/CustomDestinationResponseForwardDestinationSplunk' + - $ref: '#/components/schemas/CustomDestinationResponseForwardDestinationElasticsearch' + type: object + CustomDestinationResponseForwardDestinationElasticsearch: + description: The Elasticsearch destination. + properties: + auth: + $ref: '#/components/schemas/CustomDestinationResponseElasticsearchDestinationAuth' + endpoint: + description: 'The destination for which logs will be forwarded to. + + Must have HTTPS scheme and forwarding back to Datadog is not allowed.' + example: https://example.com + type: string + index_name: + description: Name of the Elasticsearch index (must follow [Elasticsearch's + criteria](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/indices-create-index.html#indices-create-api-path-params)). + example: nginx-logs + type: string + index_rotation: + description: 'Date pattern with US locale and UTC timezone to be appended + to the index name after adding `-` + + (that is, `${index_name}-${indexPattern}`). + + You can customize the index rotation naming pattern by choosing one of + these options: + + - Hourly: `yyyy-MM-dd-HH` (as an example, it would render: `2022-10-19-09`) + + - Daily: `yyyy-MM-dd` (as an example, it would render: `2022-10-19`) + + - Weekly: `yyyy-''W''ww` (as an example, it would render: `2022-W42`) + + - Monthly: `yyyy-MM` (as an example, it would render: `2022-10`) + + + If this field is missing or is blank, it means that the index name will + always be the same + + (that is, no rotation).' + example: yyyy-MM-dd + type: string + type: + $ref: '#/components/schemas/CustomDestinationResponseForwardDestinationElasticsearchType' + required: + - type + - endpoint + - auth + - index_name + type: object + CustomDestinationResponseForwardDestinationElasticsearchType: + default: elasticsearch + description: Type of the Elasticsearch destination. + enum: + - elasticsearch + example: elasticsearch + type: string + x-enum-varnames: + - ELASTICSEARCH + CustomDestinationResponseForwardDestinationHttp: + description: The HTTP destination. + properties: + auth: + $ref: '#/components/schemas/CustomDestinationResponseHttpDestinationAuth' + endpoint: + description: 'The destination for which logs will be forwarded to. + + Must have HTTPS scheme and forwarding back to Datadog is not allowed.' + example: https://example.com + type: string + type: + $ref: '#/components/schemas/CustomDestinationResponseForwardDestinationHttpType' + required: + - type + - endpoint + - auth + type: object + CustomDestinationResponseForwardDestinationHttpType: + default: http + description: Type of the HTTP destination. + enum: + - http + example: http + type: string + x-enum-varnames: + - HTTP + CustomDestinationResponseForwardDestinationSplunk: + description: The Splunk HTTP Event Collector (HEC) destination. + properties: + endpoint: + description: 'The destination for which logs will be forwarded to. + + Must have HTTPS scheme and forwarding back to Datadog is not allowed.' + example: https://example.com + type: string + type: + $ref: '#/components/schemas/CustomDestinationResponseForwardDestinationSplunkType' + required: + - type + - endpoint + type: object + CustomDestinationResponseForwardDestinationSplunkType: + default: splunk_hec + description: Type of the Splunk HTTP Event Collector (HEC) destination. + enum: + - splunk_hec + example: splunk_hec + type: string + x-enum-varnames: + - SPLUNK_HEC + CustomDestinationResponseHttpDestinationAuth: + description: Authentication method of the HTTP requests. + oneOf: + - $ref: '#/components/schemas/CustomDestinationResponseHttpDestinationAuthBasic' + - $ref: '#/components/schemas/CustomDestinationResponseHttpDestinationAuthCustomHeader' + type: object + CustomDestinationResponseHttpDestinationAuthBasic: + description: Basic access authentication. + properties: + type: + $ref: '#/components/schemas/CustomDestinationResponseHttpDestinationAuthBasicType' + required: + - type + type: object + CustomDestinationResponseHttpDestinationAuthBasicType: + default: basic + description: Type of the basic access authentication. + enum: + - basic + example: basic + type: string + x-enum-varnames: + - BASIC + CustomDestinationResponseHttpDestinationAuthCustomHeader: + description: Custom header access authentication. + properties: + header_name: + description: The header name of the authentication. + example: CUSTOM-HEADER-NAME + type: string + type: + $ref: '#/components/schemas/CustomDestinationResponseHttpDestinationAuthCustomHeaderType' + required: + - type + - header_name + type: object + CustomDestinationResponseHttpDestinationAuthCustomHeaderType: + default: custom_header + description: Type of the custom header access authentication. + enum: + - custom_header + example: custom_header + type: string + x-enum-varnames: + - CUSTOM_HEADER + CustomDestinationType: + default: custom_destination + description: The type of the resource. The value should always be `custom_destination`. + enum: + - custom_destination + example: custom_destination + type: string + x-enum-varnames: + - custom_destination + CustomDestinationUpdateRequest: + description: The custom destination. + properties: + data: + $ref: '#/components/schemas/CustomDestinationUpdateRequestDefinition' + type: object + CustomDestinationUpdateRequestAttributes: + description: The attributes associated with the custom destination. + properties: + enabled: + default: true + description: Whether logs matching this custom destination should be forwarded + or not. + example: true + type: boolean + forward_tags: + default: true + description: Whether tags from the forwarded logs should be forwarded or + not. + example: true + type: boolean + forward_tags_restriction_list: + default: [] + description: 'List of [keys of tags](https://docs.datadoghq.com/getting_started/tagging/#define-tags) + to be restricted from being forwarded. + + An empty list represents no restriction is in place and either all or + no tags will be forwarded depending on `forward_tags_restriction_list_type` + parameter.' + example: + - datacenter + - host + items: + description: The [key part of a tag](https://docs.datadoghq.com/getting_started/tagging/#define-tags). + type: string + maxItems: 10 + minItems: 0 + type: array + forward_tags_restriction_list_type: + $ref: '#/components/schemas/CustomDestinationAttributeTagsRestrictionListType' + forwarder_destination: + $ref: '#/components/schemas/CustomDestinationForwardDestination' + name: + description: The custom destination name. + example: Nginx logs + type: string + query: + default: '' + description: The custom destination query and filter. Logs matching this + query are forwarded to the destination. + example: source:nginx + type: string + type: object + CustomDestinationUpdateRequestDefinition: + description: The definition of a custom destination. + properties: + attributes: + $ref: '#/components/schemas/CustomDestinationUpdateRequestAttributes' + id: + description: The custom destination ID. + example: be5d7a69-d0c8-4d4d-8ee8-bba292d98139 + type: string + type: + $ref: '#/components/schemas/CustomDestinationType' + required: + - type + - id + type: object + CustomDestinationsResponse: + description: The available custom destinations. + properties: + data: + description: A list of custom destinations. + items: + $ref: '#/components/schemas/CustomDestinationResponseDefinition' + type: array + type: object DORADeploymentRequest: description: Request to create a DORA deployment event. properties: @@ -27752,6 +28374,135 @@ paths: tags: - Logs Archives x-codegen-request-body-name: body + /api/v2/logs/config/custom-destinations: + get: + description: Get the list of configured custom destinations in your organization + with their definitions. + operationId: ListLogsCustomDestinations + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomDestinationsResponse' + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get all custom destinations + tags: + - Logs Custom Destinations + post: + description: Create a custom destination in your organization. + operationId: CreateLogsCustomDestination + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CustomDestinationCreateRequest' + description: The definition of the new custom destination. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomDestinationResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create a custom destination + tags: + - Logs Custom Destinations + x-codegen-request-body-name: body + /api/v2/logs/config/custom-destinations/{custom_destination_id}: + delete: + description: Delete a specific custom destination in your organization. + operationId: DeleteLogsCustomDestination + parameters: + - $ref: '#/components/parameters/CustomDestinationId' + responses: + '204': + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete a custom destination + tags: + - Logs Custom Destinations + get: + description: Get a specific custom destination in your organization. + operationId: GetLogsCustomDestination + parameters: + - $ref: '#/components/parameters/CustomDestinationId' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomDestinationResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a custom destination + tags: + - Logs Custom Destinations + patch: + description: Update the given fields of a specific custom destination in your + organization. + operationId: UpdateLogsCustomDestination + parameters: + - $ref: '#/components/parameters/CustomDestinationId' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CustomDestinationUpdateRequest' + description: New definition of the custom destination's fields. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomDestinationResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update a custom destination + tags: + - Logs Custom Destinations + x-codegen-request-body-name: body /api/v2/logs/config/metrics: get: description: Get the list of configured log-based metrics with their definitions. @@ -35114,6 +35865,16 @@ tags: description: Find out more at url: https://docs.datadoghq.com/logs/archives/ name: Logs Archives +- description: 'Custom Destinations forward all the logs ingested to an external destination. + + + See the [Custom Destinations Page](https://app.datadoghq.com/logs/pipelines/log-forwarding/custom-destinations) + + for a list of the custom destinations currently configured in web UI.' + externalDocs: + description: Find out more at + url: https://docs.datadoghq.com/logs/log_configuration/forwarding_custom_destinations/ + name: Logs Custom Destinations - description: Manage configuration of [log-based metrics](https://app.datadoghq.com/logs/pipelines/generate-metrics) for your organization. externalDocs: diff --git a/api/datadogV2/api_logs_custom_destinations.go b/api/datadogV2/api_logs_custom_destinations.go new file mode 100644 index 00000000000..7f9e63db644 --- /dev/null +++ b/api/datadogV2/api_logs_custom_destinations.go @@ -0,0 +1,373 @@ +// 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 ( + _context "context" + _nethttp "net/http" + _neturl "net/url" + "strings" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// LogsCustomDestinationsApi service type +type LogsCustomDestinationsApi datadog.Service + +// CreateLogsCustomDestination Create a custom destination. +// Create a custom destination in your organization. +func (a *LogsCustomDestinationsApi) CreateLogsCustomDestination(ctx _context.Context, body CustomDestinationCreateRequest) (CustomDestinationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue CustomDestinationResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsCustomDestinationsApi.CreateLogsCustomDestination") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/custom-destinations" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + 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 == 403 || localVarHTTPResponse.StatusCode == 409 || 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 +} + +// DeleteLogsCustomDestination Delete a custom destination. +// Delete a specific custom destination in your organization. +func (a *LogsCustomDestinationsApi) DeleteLogsCustomDestination(ctx _context.Context, customDestinationId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsCustomDestinationsApi.DeleteLogsCustomDestination") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/custom-destinations/{custom_destination_id}" + localVarPath = strings.Replace(localVarPath, "{"+"custom_destination_id"+"}", _neturl.PathEscape(datadog.ParameterToString(customDestinationId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// GetLogsCustomDestination Get a custom destination. +// Get a specific custom destination in your organization. +func (a *LogsCustomDestinationsApi) GetLogsCustomDestination(ctx _context.Context, customDestinationId string) (CustomDestinationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue CustomDestinationResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsCustomDestinationsApi.GetLogsCustomDestination") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/custom-destinations/{custom_destination_id}" + localVarPath = strings.Replace(localVarPath, "{"+"custom_destination_id"+"}", _neturl.PathEscape(datadog.ParameterToString(customDestinationId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + 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 == 403 || 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 +} + +// ListLogsCustomDestinations Get all custom destinations. +// Get the list of configured custom destinations in your organization with their definitions. +func (a *LogsCustomDestinationsApi) ListLogsCustomDestinations(ctx _context.Context) (CustomDestinationsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue CustomDestinationsResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsCustomDestinationsApi.ListLogsCustomDestinations") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/custom-destinations" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + 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 == 403 || 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 +} + +// UpdateLogsCustomDestination Update a custom destination. +// Update the given fields of a specific custom destination in your organization. +func (a *LogsCustomDestinationsApi) UpdateLogsCustomDestination(ctx _context.Context, customDestinationId string, body CustomDestinationUpdateRequest) (CustomDestinationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue CustomDestinationResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsCustomDestinationsApi.UpdateLogsCustomDestination") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/custom-destinations/{custom_destination_id}" + localVarPath = strings.Replace(localVarPath, "{"+"custom_destination_id"+"}", _neturl.PathEscape(datadog.ParameterToString(customDestinationId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + 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 == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || 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 +} + +// NewLogsCustomDestinationsApi Returns NewLogsCustomDestinationsApi. +func NewLogsCustomDestinationsApi(client *datadog.APIClient) *LogsCustomDestinationsApi { + return &LogsCustomDestinationsApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 5f029182e8a..84f0f1d129d 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -167,6 +167,11 @@ // - [LogsArchivesApi.RemoveRoleFromArchive] // - [LogsArchivesApi.UpdateLogsArchive] // - [LogsArchivesApi.UpdateLogsArchiveOrder] +// - [LogsCustomDestinationsApi.CreateLogsCustomDestination] +// - [LogsCustomDestinationsApi.DeleteLogsCustomDestination] +// - [LogsCustomDestinationsApi.GetLogsCustomDestination] +// - [LogsCustomDestinationsApi.ListLogsCustomDestinations] +// - [LogsCustomDestinationsApi.UpdateLogsCustomDestination] // - [LogsMetricsApi.CreateLogsMetric] // - [LogsMetricsApi.DeleteLogsMetric] // - [LogsMetricsApi.GetLogsMetric] diff --git a/api/datadogV2/model_custom_destination_attribute_tags_restriction_list_type.go b/api/datadogV2/model_custom_destination_attribute_tags_restriction_list_type.go new file mode 100644 index 00000000000..f180a797f9a --- /dev/null +++ b/api/datadogV2/model_custom_destination_attribute_tags_restriction_list_type.go @@ -0,0 +1,70 @@ +// 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" +) + +// CustomDestinationAttributeTagsRestrictionListType How `forward_tags_restriction_list` parameter should be interpreted. +// If `ALLOW_LIST`, then only tags whose keys on the forwarded logs match the ones on the restriction list +// are forwarded. +// +// `BLOCK_LIST` works the opposite way. It does not forward the tags matching the ones on the list. +type CustomDestinationAttributeTagsRestrictionListType string + +// List of CustomDestinationAttributeTagsRestrictionListType. +const ( + CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST CustomDestinationAttributeTagsRestrictionListType = "ALLOW_LIST" + CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_BLOCK_LIST CustomDestinationAttributeTagsRestrictionListType = "BLOCK_LIST" +) + +var allowedCustomDestinationAttributeTagsRestrictionListTypeEnumValues = []CustomDestinationAttributeTagsRestrictionListType{ + CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST, + CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_BLOCK_LIST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationAttributeTagsRestrictionListType) GetAllowedValues() []CustomDestinationAttributeTagsRestrictionListType { + return allowedCustomDestinationAttributeTagsRestrictionListTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationAttributeTagsRestrictionListType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationAttributeTagsRestrictionListType(value) + return nil +} + +// NewCustomDestinationAttributeTagsRestrictionListTypeFromValue returns a pointer to a valid CustomDestinationAttributeTagsRestrictionListType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationAttributeTagsRestrictionListTypeFromValue(v string) (*CustomDestinationAttributeTagsRestrictionListType, error) { + ev := CustomDestinationAttributeTagsRestrictionListType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationAttributeTagsRestrictionListType: valid values are %v", v, allowedCustomDestinationAttributeTagsRestrictionListTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationAttributeTagsRestrictionListType) IsValid() bool { + for _, existing := range allowedCustomDestinationAttributeTagsRestrictionListTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationAttributeTagsRestrictionListType value. +func (v CustomDestinationAttributeTagsRestrictionListType) Ptr() *CustomDestinationAttributeTagsRestrictionListType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_create_request.go b/api/datadogV2/model_custom_destination_create_request.go new file mode 100644 index 00000000000..13c69f9428d --- /dev/null +++ b/api/datadogV2/model_custom_destination_create_request.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" +) + +// CustomDestinationCreateRequest The custom destination. +type CustomDestinationCreateRequest struct { + // The definition of a custom destination. + Data *CustomDestinationCreateRequestDefinition `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{} +} + +// NewCustomDestinationCreateRequest instantiates a new CustomDestinationCreateRequest 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 NewCustomDestinationCreateRequest() *CustomDestinationCreateRequest { + this := CustomDestinationCreateRequest{} + return &this +} + +// NewCustomDestinationCreateRequestWithDefaults instantiates a new CustomDestinationCreateRequest 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 NewCustomDestinationCreateRequestWithDefaults() *CustomDestinationCreateRequest { + this := CustomDestinationCreateRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CustomDestinationCreateRequest) GetData() CustomDestinationCreateRequestDefinition { + if o == nil || o.Data == nil { + var ret CustomDestinationCreateRequestDefinition + 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 *CustomDestinationCreateRequest) GetDataOk() (*CustomDestinationCreateRequestDefinition, 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 *CustomDestinationCreateRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given CustomDestinationCreateRequestDefinition and assigns it to the Data field. +func (o *CustomDestinationCreateRequest) SetData(v CustomDestinationCreateRequestDefinition) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationCreateRequest) 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 *CustomDestinationCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CustomDestinationCreateRequestDefinition `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_custom_destination_create_request_attributes.go b/api/datadogV2/model_custom_destination_create_request_attributes.go new file mode 100644 index 00000000000..29b4e53635f --- /dev/null +++ b/api/datadogV2/model_custom_destination_create_request_attributes.go @@ -0,0 +1,341 @@ +// 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" +) + +// CustomDestinationCreateRequestAttributes The attributes associated with the custom destination. +type CustomDestinationCreateRequestAttributes struct { + // Whether logs matching this custom destination should be forwarded or not. + Enabled *bool `json:"enabled,omitempty"` + // Whether tags from the forwarded logs should be forwarded or not. + ForwardTags *bool `json:"forward_tags,omitempty"` + // List of [keys of tags](https://docs.datadoghq.com/getting_started/tagging/#define-tags) to be filtered. + // + // An empty list represents no restriction is in place and either all or no tags will be + // forwarded depending on `forward_tags_restriction_list_type` parameter. + ForwardTagsRestrictionList []string `json:"forward_tags_restriction_list,omitempty"` + // How `forward_tags_restriction_list` parameter should be interpreted. + // If `ALLOW_LIST`, then only tags whose keys on the forwarded logs match the ones on the restriction list + // are forwarded. + // + // `BLOCK_LIST` works the opposite way. It does not forward the tags matching the ones on the list. + ForwardTagsRestrictionListType *CustomDestinationAttributeTagsRestrictionListType `json:"forward_tags_restriction_list_type,omitempty"` + // A custom destination's location to forward logs. + ForwarderDestination CustomDestinationForwardDestination `json:"forwarder_destination"` + // The custom destination name. + Name string `json:"name"` + // The custom destination query and filter. Logs matching this query are forwarded to the destination. + Query *string `json:"query,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{} +} + +// NewCustomDestinationCreateRequestAttributes instantiates a new CustomDestinationCreateRequestAttributes 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 NewCustomDestinationCreateRequestAttributes(forwarderDestination CustomDestinationForwardDestination, name string) *CustomDestinationCreateRequestAttributes { + this := CustomDestinationCreateRequestAttributes{} + var enabled bool = true + this.Enabled = &enabled + var forwardTags bool = true + this.ForwardTags = &forwardTags + var forwardTagsRestrictionListType CustomDestinationAttributeTagsRestrictionListType = CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST + this.ForwardTagsRestrictionListType = &forwardTagsRestrictionListType + this.ForwarderDestination = forwarderDestination + this.Name = name + var query string = "" + this.Query = &query + return &this +} + +// NewCustomDestinationCreateRequestAttributesWithDefaults instantiates a new CustomDestinationCreateRequestAttributes 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 NewCustomDestinationCreateRequestAttributesWithDefaults() *CustomDestinationCreateRequestAttributes { + this := CustomDestinationCreateRequestAttributes{} + var enabled bool = true + this.Enabled = &enabled + var forwardTags bool = true + this.ForwardTags = &forwardTags + var forwardTagsRestrictionListType CustomDestinationAttributeTagsRestrictionListType = CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST + this.ForwardTagsRestrictionListType = &forwardTagsRestrictionListType + var query string = "" + this.Query = &query + return &this +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *CustomDestinationCreateRequestAttributes) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationCreateRequestAttributes) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *CustomDestinationCreateRequestAttributes) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *CustomDestinationCreateRequestAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetForwardTags returns the ForwardTags field value if set, zero value otherwise. +func (o *CustomDestinationCreateRequestAttributes) GetForwardTags() bool { + if o == nil || o.ForwardTags == nil { + var ret bool + return ret + } + return *o.ForwardTags +} + +// GetForwardTagsOk returns a tuple with the ForwardTags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationCreateRequestAttributes) GetForwardTagsOk() (*bool, bool) { + if o == nil || o.ForwardTags == nil { + return nil, false + } + return o.ForwardTags, true +} + +// HasForwardTags returns a boolean if a field has been set. +func (o *CustomDestinationCreateRequestAttributes) HasForwardTags() bool { + return o != nil && o.ForwardTags != nil +} + +// SetForwardTags gets a reference to the given bool and assigns it to the ForwardTags field. +func (o *CustomDestinationCreateRequestAttributes) SetForwardTags(v bool) { + o.ForwardTags = &v +} + +// GetForwardTagsRestrictionList returns the ForwardTagsRestrictionList field value if set, zero value otherwise. +func (o *CustomDestinationCreateRequestAttributes) GetForwardTagsRestrictionList() []string { + if o == nil || o.ForwardTagsRestrictionList == nil { + var ret []string + return ret + } + return o.ForwardTagsRestrictionList +} + +// GetForwardTagsRestrictionListOk returns a tuple with the ForwardTagsRestrictionList field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationCreateRequestAttributes) GetForwardTagsRestrictionListOk() (*[]string, bool) { + if o == nil || o.ForwardTagsRestrictionList == nil { + return nil, false + } + return &o.ForwardTagsRestrictionList, true +} + +// HasForwardTagsRestrictionList returns a boolean if a field has been set. +func (o *CustomDestinationCreateRequestAttributes) HasForwardTagsRestrictionList() bool { + return o != nil && o.ForwardTagsRestrictionList != nil +} + +// SetForwardTagsRestrictionList gets a reference to the given []string and assigns it to the ForwardTagsRestrictionList field. +func (o *CustomDestinationCreateRequestAttributes) SetForwardTagsRestrictionList(v []string) { + o.ForwardTagsRestrictionList = v +} + +// GetForwardTagsRestrictionListType returns the ForwardTagsRestrictionListType field value if set, zero value otherwise. +func (o *CustomDestinationCreateRequestAttributes) GetForwardTagsRestrictionListType() CustomDestinationAttributeTagsRestrictionListType { + if o == nil || o.ForwardTagsRestrictionListType == nil { + var ret CustomDestinationAttributeTagsRestrictionListType + return ret + } + return *o.ForwardTagsRestrictionListType +} + +// GetForwardTagsRestrictionListTypeOk returns a tuple with the ForwardTagsRestrictionListType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationCreateRequestAttributes) GetForwardTagsRestrictionListTypeOk() (*CustomDestinationAttributeTagsRestrictionListType, bool) { + if o == nil || o.ForwardTagsRestrictionListType == nil { + return nil, false + } + return o.ForwardTagsRestrictionListType, true +} + +// HasForwardTagsRestrictionListType returns a boolean if a field has been set. +func (o *CustomDestinationCreateRequestAttributes) HasForwardTagsRestrictionListType() bool { + return o != nil && o.ForwardTagsRestrictionListType != nil +} + +// SetForwardTagsRestrictionListType gets a reference to the given CustomDestinationAttributeTagsRestrictionListType and assigns it to the ForwardTagsRestrictionListType field. +func (o *CustomDestinationCreateRequestAttributes) SetForwardTagsRestrictionListType(v CustomDestinationAttributeTagsRestrictionListType) { + o.ForwardTagsRestrictionListType = &v +} + +// GetForwarderDestination returns the ForwarderDestination field value. +func (o *CustomDestinationCreateRequestAttributes) GetForwarderDestination() CustomDestinationForwardDestination { + if o == nil { + var ret CustomDestinationForwardDestination + return ret + } + return o.ForwarderDestination +} + +// GetForwarderDestinationOk returns a tuple with the ForwarderDestination field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationCreateRequestAttributes) GetForwarderDestinationOk() (*CustomDestinationForwardDestination, bool) { + if o == nil { + return nil, false + } + return &o.ForwarderDestination, true +} + +// SetForwarderDestination sets field value. +func (o *CustomDestinationCreateRequestAttributes) SetForwarderDestination(v CustomDestinationForwardDestination) { + o.ForwarderDestination = v +} + +// GetName returns the Name field value. +func (o *CustomDestinationCreateRequestAttributes) 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 *CustomDestinationCreateRequestAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *CustomDestinationCreateRequestAttributes) SetName(v string) { + o.Name = v +} + +// GetQuery returns the Query field value if set, zero value otherwise. +func (o *CustomDestinationCreateRequestAttributes) GetQuery() string { + if o == nil || o.Query == nil { + var ret string + return ret + } + return *o.Query +} + +// GetQueryOk returns a tuple with the Query field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationCreateRequestAttributes) GetQueryOk() (*string, bool) { + if o == nil || o.Query == nil { + return nil, false + } + return o.Query, true +} + +// HasQuery returns a boolean if a field has been set. +func (o *CustomDestinationCreateRequestAttributes) HasQuery() bool { + return o != nil && o.Query != nil +} + +// SetQuery gets a reference to the given string and assigns it to the Query field. +func (o *CustomDestinationCreateRequestAttributes) SetQuery(v string) { + o.Query = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationCreateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.ForwardTags != nil { + toSerialize["forward_tags"] = o.ForwardTags + } + if o.ForwardTagsRestrictionList != nil { + toSerialize["forward_tags_restriction_list"] = o.ForwardTagsRestrictionList + } + if o.ForwardTagsRestrictionListType != nil { + toSerialize["forward_tags_restriction_list_type"] = o.ForwardTagsRestrictionListType + } + toSerialize["forwarder_destination"] = o.ForwarderDestination + toSerialize["name"] = o.Name + if o.Query != nil { + toSerialize["query"] = o.Query + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationCreateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Enabled *bool `json:"enabled,omitempty"` + ForwardTags *bool `json:"forward_tags,omitempty"` + ForwardTagsRestrictionList []string `json:"forward_tags_restriction_list,omitempty"` + ForwardTagsRestrictionListType *CustomDestinationAttributeTagsRestrictionListType `json:"forward_tags_restriction_list_type,omitempty"` + ForwarderDestination *CustomDestinationForwardDestination `json:"forwarder_destination"` + Name *string `json:"name"` + Query *string `json:"query,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ForwarderDestination == nil { + return fmt.Errorf("required field forwarder_destination missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"enabled", "forward_tags", "forward_tags_restriction_list", "forward_tags_restriction_list_type", "forwarder_destination", "name", "query"}) + } else { + return err + } + + hasInvalidField := false + o.Enabled = all.Enabled + o.ForwardTags = all.ForwardTags + o.ForwardTagsRestrictionList = all.ForwardTagsRestrictionList + if all.ForwardTagsRestrictionListType != nil && !all.ForwardTagsRestrictionListType.IsValid() { + hasInvalidField = true + } else { + o.ForwardTagsRestrictionListType = all.ForwardTagsRestrictionListType + } + o.ForwarderDestination = *all.ForwarderDestination + o.Name = *all.Name + o.Query = all.Query + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_custom_destination_create_request_definition.go b/api/datadogV2/model_custom_destination_create_request_definition.go new file mode 100644 index 00000000000..4c71e08aa97 --- /dev/null +++ b/api/datadogV2/model_custom_destination_create_request_definition.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" +) + +// CustomDestinationCreateRequestDefinition The definition of a custom destination. +type CustomDestinationCreateRequestDefinition struct { + // The attributes associated with the custom destination. + Attributes CustomDestinationCreateRequestAttributes `json:"attributes"` + // The type of the resource. The value should always be `custom_destination`. + Type CustomDestinationType `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{} +} + +// NewCustomDestinationCreateRequestDefinition instantiates a new CustomDestinationCreateRequestDefinition 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 NewCustomDestinationCreateRequestDefinition(attributes CustomDestinationCreateRequestAttributes, typeVar CustomDestinationType) *CustomDestinationCreateRequestDefinition { + this := CustomDestinationCreateRequestDefinition{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewCustomDestinationCreateRequestDefinitionWithDefaults instantiates a new CustomDestinationCreateRequestDefinition 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 NewCustomDestinationCreateRequestDefinitionWithDefaults() *CustomDestinationCreateRequestDefinition { + this := CustomDestinationCreateRequestDefinition{} + var typeVar CustomDestinationType = CUSTOMDESTINATIONTYPE_custom_destination + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *CustomDestinationCreateRequestDefinition) GetAttributes() CustomDestinationCreateRequestAttributes { + if o == nil { + var ret CustomDestinationCreateRequestAttributes + 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 *CustomDestinationCreateRequestDefinition) GetAttributesOk() (*CustomDestinationCreateRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *CustomDestinationCreateRequestDefinition) SetAttributes(v CustomDestinationCreateRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *CustomDestinationCreateRequestDefinition) GetType() CustomDestinationType { + if o == nil { + var ret CustomDestinationType + 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 *CustomDestinationCreateRequestDefinition) GetTypeOk() (*CustomDestinationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationCreateRequestDefinition) SetType(v CustomDestinationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationCreateRequestDefinition) 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 *CustomDestinationCreateRequestDefinition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CustomDestinationCreateRequestAttributes `json:"attributes"` + Type *CustomDestinationType `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_custom_destination_elasticsearch_destination_auth.go b/api/datadogV2/model_custom_destination_elasticsearch_destination_auth.go new file mode 100644 index 00000000000..53decf48aff --- /dev/null +++ b/api/datadogV2/model_custom_destination_elasticsearch_destination_auth.go @@ -0,0 +1,133 @@ +// 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" +) + +// CustomDestinationElasticsearchDestinationAuth Basic access authentication. +type CustomDestinationElasticsearchDestinationAuth struct { + // The password of the authentication. This field is not returned by the API. + Password string `json:"password"` + // The username of the authentication. This field is not returned by the API. + Username string `json:"username"` + // 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{} +} + +// NewCustomDestinationElasticsearchDestinationAuth instantiates a new CustomDestinationElasticsearchDestinationAuth 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 NewCustomDestinationElasticsearchDestinationAuth(password string, username string) *CustomDestinationElasticsearchDestinationAuth { + this := CustomDestinationElasticsearchDestinationAuth{} + this.Password = password + this.Username = username + return &this +} + +// NewCustomDestinationElasticsearchDestinationAuthWithDefaults instantiates a new CustomDestinationElasticsearchDestinationAuth 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 NewCustomDestinationElasticsearchDestinationAuthWithDefaults() *CustomDestinationElasticsearchDestinationAuth { + this := CustomDestinationElasticsearchDestinationAuth{} + return &this +} + +// GetPassword returns the Password field value. +func (o *CustomDestinationElasticsearchDestinationAuth) GetPassword() string { + if o == nil { + var ret string + return ret + } + return o.Password +} + +// GetPasswordOk returns a tuple with the Password field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationElasticsearchDestinationAuth) GetPasswordOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Password, true +} + +// SetPassword sets field value. +func (o *CustomDestinationElasticsearchDestinationAuth) SetPassword(v string) { + o.Password = v +} + +// GetUsername returns the Username field value. +func (o *CustomDestinationElasticsearchDestinationAuth) GetUsername() string { + if o == nil { + var ret string + return ret + } + return o.Username +} + +// GetUsernameOk returns a tuple with the Username field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationElasticsearchDestinationAuth) GetUsernameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Username, true +} + +// SetUsername sets field value. +func (o *CustomDestinationElasticsearchDestinationAuth) SetUsername(v string) { + o.Username = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationElasticsearchDestinationAuth) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["password"] = o.Password + toSerialize["username"] = o.Username + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationElasticsearchDestinationAuth) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Password *string `json:"password"` + Username *string `json:"username"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Password == nil { + return fmt.Errorf("required field password missing") + } + if all.Username == nil { + return fmt.Errorf("required field username missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"password", "username"}) + } else { + return err + } + o.Password = *all.Password + o.Username = *all.Username + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_custom_destination_forward_destination.go b/api/datadogV2/model_custom_destination_forward_destination.go new file mode 100644 index 00000000000..9151bbe34d0 --- /dev/null +++ b/api/datadogV2/model_custom_destination_forward_destination.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" +) + +// CustomDestinationForwardDestination - A custom destination's location to forward logs. +type CustomDestinationForwardDestination struct { + CustomDestinationForwardDestinationHttp *CustomDestinationForwardDestinationHttp + CustomDestinationForwardDestinationSplunk *CustomDestinationForwardDestinationSplunk + CustomDestinationForwardDestinationElasticsearch *CustomDestinationForwardDestinationElasticsearch + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// CustomDestinationForwardDestinationHttpAsCustomDestinationForwardDestination is a convenience function that returns CustomDestinationForwardDestinationHttp wrapped in CustomDestinationForwardDestination. +func CustomDestinationForwardDestinationHttpAsCustomDestinationForwardDestination(v *CustomDestinationForwardDestinationHttp) CustomDestinationForwardDestination { + return CustomDestinationForwardDestination{CustomDestinationForwardDestinationHttp: v} +} + +// CustomDestinationForwardDestinationSplunkAsCustomDestinationForwardDestination is a convenience function that returns CustomDestinationForwardDestinationSplunk wrapped in CustomDestinationForwardDestination. +func CustomDestinationForwardDestinationSplunkAsCustomDestinationForwardDestination(v *CustomDestinationForwardDestinationSplunk) CustomDestinationForwardDestination { + return CustomDestinationForwardDestination{CustomDestinationForwardDestinationSplunk: v} +} + +// CustomDestinationForwardDestinationElasticsearchAsCustomDestinationForwardDestination is a convenience function that returns CustomDestinationForwardDestinationElasticsearch wrapped in CustomDestinationForwardDestination. +func CustomDestinationForwardDestinationElasticsearchAsCustomDestinationForwardDestination(v *CustomDestinationForwardDestinationElasticsearch) CustomDestinationForwardDestination { + return CustomDestinationForwardDestination{CustomDestinationForwardDestinationElasticsearch: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *CustomDestinationForwardDestination) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into CustomDestinationForwardDestinationHttp + err = datadog.Unmarshal(data, &obj.CustomDestinationForwardDestinationHttp) + if err == nil { + if obj.CustomDestinationForwardDestinationHttp != nil && obj.CustomDestinationForwardDestinationHttp.UnparsedObject == nil { + jsonCustomDestinationForwardDestinationHttp, _ := datadog.Marshal(obj.CustomDestinationForwardDestinationHttp) + if string(jsonCustomDestinationForwardDestinationHttp) == "{}" { // empty struct + obj.CustomDestinationForwardDestinationHttp = nil + } else { + match++ + } + } else { + obj.CustomDestinationForwardDestinationHttp = nil + } + } else { + obj.CustomDestinationForwardDestinationHttp = nil + } + + // try to unmarshal data into CustomDestinationForwardDestinationSplunk + err = datadog.Unmarshal(data, &obj.CustomDestinationForwardDestinationSplunk) + if err == nil { + if obj.CustomDestinationForwardDestinationSplunk != nil && obj.CustomDestinationForwardDestinationSplunk.UnparsedObject == nil { + jsonCustomDestinationForwardDestinationSplunk, _ := datadog.Marshal(obj.CustomDestinationForwardDestinationSplunk) + if string(jsonCustomDestinationForwardDestinationSplunk) == "{}" { // empty struct + obj.CustomDestinationForwardDestinationSplunk = nil + } else { + match++ + } + } else { + obj.CustomDestinationForwardDestinationSplunk = nil + } + } else { + obj.CustomDestinationForwardDestinationSplunk = nil + } + + // try to unmarshal data into CustomDestinationForwardDestinationElasticsearch + err = datadog.Unmarshal(data, &obj.CustomDestinationForwardDestinationElasticsearch) + if err == nil { + if obj.CustomDestinationForwardDestinationElasticsearch != nil && obj.CustomDestinationForwardDestinationElasticsearch.UnparsedObject == nil { + jsonCustomDestinationForwardDestinationElasticsearch, _ := datadog.Marshal(obj.CustomDestinationForwardDestinationElasticsearch) + if string(jsonCustomDestinationForwardDestinationElasticsearch) == "{}" { // empty struct + obj.CustomDestinationForwardDestinationElasticsearch = nil + } else { + match++ + } + } else { + obj.CustomDestinationForwardDestinationElasticsearch = nil + } + } else { + obj.CustomDestinationForwardDestinationElasticsearch = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.CustomDestinationForwardDestinationHttp = nil + obj.CustomDestinationForwardDestinationSplunk = nil + obj.CustomDestinationForwardDestinationElasticsearch = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj CustomDestinationForwardDestination) MarshalJSON() ([]byte, error) { + if obj.CustomDestinationForwardDestinationHttp != nil { + return datadog.Marshal(&obj.CustomDestinationForwardDestinationHttp) + } + + if obj.CustomDestinationForwardDestinationSplunk != nil { + return datadog.Marshal(&obj.CustomDestinationForwardDestinationSplunk) + } + + if obj.CustomDestinationForwardDestinationElasticsearch != nil { + return datadog.Marshal(&obj.CustomDestinationForwardDestinationElasticsearch) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *CustomDestinationForwardDestination) GetActualInstance() interface{} { + if obj.CustomDestinationForwardDestinationHttp != nil { + return obj.CustomDestinationForwardDestinationHttp + } + + if obj.CustomDestinationForwardDestinationSplunk != nil { + return obj.CustomDestinationForwardDestinationSplunk + } + + if obj.CustomDestinationForwardDestinationElasticsearch != nil { + return obj.CustomDestinationForwardDestinationElasticsearch + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_custom_destination_forward_destination_elasticsearch.go b/api/datadogV2/model_custom_destination_forward_destination_elasticsearch.go new file mode 100644 index 00000000000..56c0aa83ca6 --- /dev/null +++ b/api/datadogV2/model_custom_destination_forward_destination_elasticsearch.go @@ -0,0 +1,257 @@ +// 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" +) + +// CustomDestinationForwardDestinationElasticsearch The Elasticsearch destination. +type CustomDestinationForwardDestinationElasticsearch struct { + // Basic access authentication. + Auth CustomDestinationElasticsearchDestinationAuth `json:"auth"` + // The destination for which logs will be forwarded to. + // Must have HTTPS scheme and forwarding back to Datadog is not allowed. + Endpoint string `json:"endpoint"` + // Name of the Elasticsearch index (must follow [Elasticsearch's criteria](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/indices-create-index.html#indices-create-api-path-params)). + IndexName string `json:"index_name"` + // Date pattern with US locale and UTC timezone to be appended to the index name after adding `-` + // (that is, `${index_name}-${indexPattern}`). + // You can customize the index rotation naming pattern by choosing one of these options: + // - Hourly: `yyyy-MM-dd-HH` (as an example, it would render: `2022-10-19-09`) + // - Daily: `yyyy-MM-dd` (as an example, it would render: `2022-10-19`) + // - Weekly: `yyyy-'W'ww` (as an example, it would render: `2022-W42`) + // - Monthly: `yyyy-MM` (as an example, it would render: `2022-10`) + // + // If this field is missing or is blank, it means that the index name will always be the same + // (that is, no rotation). + IndexRotation *string `json:"index_rotation,omitempty"` + // Type of the Elasticsearch destination. + Type CustomDestinationForwardDestinationElasticsearchType `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{} +} + +// NewCustomDestinationForwardDestinationElasticsearch instantiates a new CustomDestinationForwardDestinationElasticsearch 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 NewCustomDestinationForwardDestinationElasticsearch(auth CustomDestinationElasticsearchDestinationAuth, endpoint string, indexName string, typeVar CustomDestinationForwardDestinationElasticsearchType) *CustomDestinationForwardDestinationElasticsearch { + this := CustomDestinationForwardDestinationElasticsearch{} + this.Auth = auth + this.Endpoint = endpoint + this.IndexName = indexName + this.Type = typeVar + return &this +} + +// NewCustomDestinationForwardDestinationElasticsearchWithDefaults instantiates a new CustomDestinationForwardDestinationElasticsearch 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 NewCustomDestinationForwardDestinationElasticsearchWithDefaults() *CustomDestinationForwardDestinationElasticsearch { + this := CustomDestinationForwardDestinationElasticsearch{} + var typeVar CustomDestinationForwardDestinationElasticsearchType = CUSTOMDESTINATIONFORWARDDESTINATIONELASTICSEARCHTYPE_ELASTICSEARCH + this.Type = typeVar + return &this +} + +// GetAuth returns the Auth field value. +func (o *CustomDestinationForwardDestinationElasticsearch) GetAuth() CustomDestinationElasticsearchDestinationAuth { + if o == nil { + var ret CustomDestinationElasticsearchDestinationAuth + return ret + } + return o.Auth +} + +// GetAuthOk returns a tuple with the Auth field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationForwardDestinationElasticsearch) GetAuthOk() (*CustomDestinationElasticsearchDestinationAuth, bool) { + if o == nil { + return nil, false + } + return &o.Auth, true +} + +// SetAuth sets field value. +func (o *CustomDestinationForwardDestinationElasticsearch) SetAuth(v CustomDestinationElasticsearchDestinationAuth) { + o.Auth = v +} + +// GetEndpoint returns the Endpoint field value. +func (o *CustomDestinationForwardDestinationElasticsearch) GetEndpoint() string { + if o == nil { + var ret string + return ret + } + return o.Endpoint +} + +// GetEndpointOk returns a tuple with the Endpoint field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationForwardDestinationElasticsearch) GetEndpointOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Endpoint, true +} + +// SetEndpoint sets field value. +func (o *CustomDestinationForwardDestinationElasticsearch) SetEndpoint(v string) { + o.Endpoint = v +} + +// GetIndexName returns the IndexName field value. +func (o *CustomDestinationForwardDestinationElasticsearch) GetIndexName() string { + if o == nil { + var ret string + return ret + } + return o.IndexName +} + +// GetIndexNameOk returns a tuple with the IndexName field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationForwardDestinationElasticsearch) GetIndexNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.IndexName, true +} + +// SetIndexName sets field value. +func (o *CustomDestinationForwardDestinationElasticsearch) SetIndexName(v string) { + o.IndexName = v +} + +// GetIndexRotation returns the IndexRotation field value if set, zero value otherwise. +func (o *CustomDestinationForwardDestinationElasticsearch) GetIndexRotation() string { + if o == nil || o.IndexRotation == nil { + var ret string + return ret + } + return *o.IndexRotation +} + +// GetIndexRotationOk returns a tuple with the IndexRotation field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationForwardDestinationElasticsearch) GetIndexRotationOk() (*string, bool) { + if o == nil || o.IndexRotation == nil { + return nil, false + } + return o.IndexRotation, true +} + +// HasIndexRotation returns a boolean if a field has been set. +func (o *CustomDestinationForwardDestinationElasticsearch) HasIndexRotation() bool { + return o != nil && o.IndexRotation != nil +} + +// SetIndexRotation gets a reference to the given string and assigns it to the IndexRotation field. +func (o *CustomDestinationForwardDestinationElasticsearch) SetIndexRotation(v string) { + o.IndexRotation = &v +} + +// GetType returns the Type field value. +func (o *CustomDestinationForwardDestinationElasticsearch) GetType() CustomDestinationForwardDestinationElasticsearchType { + if o == nil { + var ret CustomDestinationForwardDestinationElasticsearchType + 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 *CustomDestinationForwardDestinationElasticsearch) GetTypeOk() (*CustomDestinationForwardDestinationElasticsearchType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationForwardDestinationElasticsearch) SetType(v CustomDestinationForwardDestinationElasticsearchType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationForwardDestinationElasticsearch) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["auth"] = o.Auth + toSerialize["endpoint"] = o.Endpoint + toSerialize["index_name"] = o.IndexName + if o.IndexRotation != nil { + toSerialize["index_rotation"] = o.IndexRotation + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationForwardDestinationElasticsearch) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Auth *CustomDestinationElasticsearchDestinationAuth `json:"auth"` + Endpoint *string `json:"endpoint"` + IndexName *string `json:"index_name"` + IndexRotation *string `json:"index_rotation,omitempty"` + Type *CustomDestinationForwardDestinationElasticsearchType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Auth == nil { + return fmt.Errorf("required field auth missing") + } + if all.Endpoint == nil { + return fmt.Errorf("required field endpoint missing") + } + if all.IndexName == nil { + return fmt.Errorf("required field index_name 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{"auth", "endpoint", "index_name", "index_rotation", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Auth.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Auth = *all.Auth + o.Endpoint = *all.Endpoint + o.IndexName = *all.IndexName + o.IndexRotation = all.IndexRotation + 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_custom_destination_forward_destination_elasticsearch_type.go b/api/datadogV2/model_custom_destination_forward_destination_elasticsearch_type.go new file mode 100644 index 00000000000..b9401b166b2 --- /dev/null +++ b/api/datadogV2/model_custom_destination_forward_destination_elasticsearch_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" +) + +// CustomDestinationForwardDestinationElasticsearchType Type of the Elasticsearch destination. +type CustomDestinationForwardDestinationElasticsearchType string + +// List of CustomDestinationForwardDestinationElasticsearchType. +const ( + CUSTOMDESTINATIONFORWARDDESTINATIONELASTICSEARCHTYPE_ELASTICSEARCH CustomDestinationForwardDestinationElasticsearchType = "elasticsearch" +) + +var allowedCustomDestinationForwardDestinationElasticsearchTypeEnumValues = []CustomDestinationForwardDestinationElasticsearchType{ + CUSTOMDESTINATIONFORWARDDESTINATIONELASTICSEARCHTYPE_ELASTICSEARCH, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationForwardDestinationElasticsearchType) GetAllowedValues() []CustomDestinationForwardDestinationElasticsearchType { + return allowedCustomDestinationForwardDestinationElasticsearchTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationForwardDestinationElasticsearchType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationForwardDestinationElasticsearchType(value) + return nil +} + +// NewCustomDestinationForwardDestinationElasticsearchTypeFromValue returns a pointer to a valid CustomDestinationForwardDestinationElasticsearchType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationForwardDestinationElasticsearchTypeFromValue(v string) (*CustomDestinationForwardDestinationElasticsearchType, error) { + ev := CustomDestinationForwardDestinationElasticsearchType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationForwardDestinationElasticsearchType: valid values are %v", v, allowedCustomDestinationForwardDestinationElasticsearchTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationForwardDestinationElasticsearchType) IsValid() bool { + for _, existing := range allowedCustomDestinationForwardDestinationElasticsearchTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationForwardDestinationElasticsearchType value. +func (v CustomDestinationForwardDestinationElasticsearchType) Ptr() *CustomDestinationForwardDestinationElasticsearchType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_forward_destination_http.go b/api/datadogV2/model_custom_destination_forward_destination_http.go new file mode 100644 index 00000000000..6582d1bac19 --- /dev/null +++ b/api/datadogV2/model_custom_destination_forward_destination_http.go @@ -0,0 +1,178 @@ +// 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" +) + +// CustomDestinationForwardDestinationHttp The HTTP destination. +type CustomDestinationForwardDestinationHttp struct { + // Authentication method of the HTTP requests. + Auth CustomDestinationHttpDestinationAuth `json:"auth"` + // The destination for which logs will be forwarded to. + // Must have HTTPS scheme and forwarding back to Datadog is not allowed. + Endpoint string `json:"endpoint"` + // Type of the HTTP destination. + Type CustomDestinationForwardDestinationHttpType `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{} +} + +// NewCustomDestinationForwardDestinationHttp instantiates a new CustomDestinationForwardDestinationHttp 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 NewCustomDestinationForwardDestinationHttp(auth CustomDestinationHttpDestinationAuth, endpoint string, typeVar CustomDestinationForwardDestinationHttpType) *CustomDestinationForwardDestinationHttp { + this := CustomDestinationForwardDestinationHttp{} + this.Auth = auth + this.Endpoint = endpoint + this.Type = typeVar + return &this +} + +// NewCustomDestinationForwardDestinationHttpWithDefaults instantiates a new CustomDestinationForwardDestinationHttp 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 NewCustomDestinationForwardDestinationHttpWithDefaults() *CustomDestinationForwardDestinationHttp { + this := CustomDestinationForwardDestinationHttp{} + var typeVar CustomDestinationForwardDestinationHttpType = CUSTOMDESTINATIONFORWARDDESTINATIONHTTPTYPE_HTTP + this.Type = typeVar + return &this +} + +// GetAuth returns the Auth field value. +func (o *CustomDestinationForwardDestinationHttp) GetAuth() CustomDestinationHttpDestinationAuth { + if o == nil { + var ret CustomDestinationHttpDestinationAuth + return ret + } + return o.Auth +} + +// GetAuthOk returns a tuple with the Auth field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationForwardDestinationHttp) GetAuthOk() (*CustomDestinationHttpDestinationAuth, bool) { + if o == nil { + return nil, false + } + return &o.Auth, true +} + +// SetAuth sets field value. +func (o *CustomDestinationForwardDestinationHttp) SetAuth(v CustomDestinationHttpDestinationAuth) { + o.Auth = v +} + +// GetEndpoint returns the Endpoint field value. +func (o *CustomDestinationForwardDestinationHttp) GetEndpoint() string { + if o == nil { + var ret string + return ret + } + return o.Endpoint +} + +// GetEndpointOk returns a tuple with the Endpoint field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationForwardDestinationHttp) GetEndpointOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Endpoint, true +} + +// SetEndpoint sets field value. +func (o *CustomDestinationForwardDestinationHttp) SetEndpoint(v string) { + o.Endpoint = v +} + +// GetType returns the Type field value. +func (o *CustomDestinationForwardDestinationHttp) GetType() CustomDestinationForwardDestinationHttpType { + if o == nil { + var ret CustomDestinationForwardDestinationHttpType + 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 *CustomDestinationForwardDestinationHttp) GetTypeOk() (*CustomDestinationForwardDestinationHttpType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationForwardDestinationHttp) SetType(v CustomDestinationForwardDestinationHttpType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationForwardDestinationHttp) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["auth"] = o.Auth + toSerialize["endpoint"] = o.Endpoint + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationForwardDestinationHttp) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Auth *CustomDestinationHttpDestinationAuth `json:"auth"` + Endpoint *string `json:"endpoint"` + Type *CustomDestinationForwardDestinationHttpType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Auth == nil { + return fmt.Errorf("required field auth missing") + } + if all.Endpoint == nil { + return fmt.Errorf("required field endpoint 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{"auth", "endpoint", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Auth = *all.Auth + o.Endpoint = *all.Endpoint + 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_custom_destination_forward_destination_http_type.go b/api/datadogV2/model_custom_destination_forward_destination_http_type.go new file mode 100644 index 00000000000..2e3615b5dd8 --- /dev/null +++ b/api/datadogV2/model_custom_destination_forward_destination_http_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" +) + +// CustomDestinationForwardDestinationHttpType Type of the HTTP destination. +type CustomDestinationForwardDestinationHttpType string + +// List of CustomDestinationForwardDestinationHttpType. +const ( + CUSTOMDESTINATIONFORWARDDESTINATIONHTTPTYPE_HTTP CustomDestinationForwardDestinationHttpType = "http" +) + +var allowedCustomDestinationForwardDestinationHttpTypeEnumValues = []CustomDestinationForwardDestinationHttpType{ + CUSTOMDESTINATIONFORWARDDESTINATIONHTTPTYPE_HTTP, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationForwardDestinationHttpType) GetAllowedValues() []CustomDestinationForwardDestinationHttpType { + return allowedCustomDestinationForwardDestinationHttpTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationForwardDestinationHttpType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationForwardDestinationHttpType(value) + return nil +} + +// NewCustomDestinationForwardDestinationHttpTypeFromValue returns a pointer to a valid CustomDestinationForwardDestinationHttpType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationForwardDestinationHttpTypeFromValue(v string) (*CustomDestinationForwardDestinationHttpType, error) { + ev := CustomDestinationForwardDestinationHttpType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationForwardDestinationHttpType: valid values are %v", v, allowedCustomDestinationForwardDestinationHttpTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationForwardDestinationHttpType) IsValid() bool { + for _, existing := range allowedCustomDestinationForwardDestinationHttpTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationForwardDestinationHttpType value. +func (v CustomDestinationForwardDestinationHttpType) Ptr() *CustomDestinationForwardDestinationHttpType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_forward_destination_splunk.go b/api/datadogV2/model_custom_destination_forward_destination_splunk.go new file mode 100644 index 00000000000..14a8f4b9406 --- /dev/null +++ b/api/datadogV2/model_custom_destination_forward_destination_splunk.go @@ -0,0 +1,178 @@ +// 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" +) + +// CustomDestinationForwardDestinationSplunk The Splunk HTTP Event Collector (HEC) destination. +type CustomDestinationForwardDestinationSplunk struct { + // Access token of the Splunk HTTP Event Collector. This field is not returned by the API. + AccessToken string `json:"access_token"` + // The destination for which logs will be forwarded to. + // Must have HTTPS scheme and forwarding back to Datadog is not allowed. + Endpoint string `json:"endpoint"` + // Type of the Splunk HTTP Event Collector (HEC) destination. + Type CustomDestinationForwardDestinationSplunkType `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{} +} + +// NewCustomDestinationForwardDestinationSplunk instantiates a new CustomDestinationForwardDestinationSplunk 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 NewCustomDestinationForwardDestinationSplunk(accessToken string, endpoint string, typeVar CustomDestinationForwardDestinationSplunkType) *CustomDestinationForwardDestinationSplunk { + this := CustomDestinationForwardDestinationSplunk{} + this.AccessToken = accessToken + this.Endpoint = endpoint + this.Type = typeVar + return &this +} + +// NewCustomDestinationForwardDestinationSplunkWithDefaults instantiates a new CustomDestinationForwardDestinationSplunk 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 NewCustomDestinationForwardDestinationSplunkWithDefaults() *CustomDestinationForwardDestinationSplunk { + this := CustomDestinationForwardDestinationSplunk{} + var typeVar CustomDestinationForwardDestinationSplunkType = CUSTOMDESTINATIONFORWARDDESTINATIONSPLUNKTYPE_SPLUNK_HEC + this.Type = typeVar + return &this +} + +// GetAccessToken returns the AccessToken field value. +func (o *CustomDestinationForwardDestinationSplunk) GetAccessToken() string { + if o == nil { + var ret string + return ret + } + return o.AccessToken +} + +// GetAccessTokenOk returns a tuple with the AccessToken field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationForwardDestinationSplunk) GetAccessTokenOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AccessToken, true +} + +// SetAccessToken sets field value. +func (o *CustomDestinationForwardDestinationSplunk) SetAccessToken(v string) { + o.AccessToken = v +} + +// GetEndpoint returns the Endpoint field value. +func (o *CustomDestinationForwardDestinationSplunk) GetEndpoint() string { + if o == nil { + var ret string + return ret + } + return o.Endpoint +} + +// GetEndpointOk returns a tuple with the Endpoint field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationForwardDestinationSplunk) GetEndpointOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Endpoint, true +} + +// SetEndpoint sets field value. +func (o *CustomDestinationForwardDestinationSplunk) SetEndpoint(v string) { + o.Endpoint = v +} + +// GetType returns the Type field value. +func (o *CustomDestinationForwardDestinationSplunk) GetType() CustomDestinationForwardDestinationSplunkType { + if o == nil { + var ret CustomDestinationForwardDestinationSplunkType + 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 *CustomDestinationForwardDestinationSplunk) GetTypeOk() (*CustomDestinationForwardDestinationSplunkType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationForwardDestinationSplunk) SetType(v CustomDestinationForwardDestinationSplunkType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationForwardDestinationSplunk) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["access_token"] = o.AccessToken + toSerialize["endpoint"] = o.Endpoint + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationForwardDestinationSplunk) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AccessToken *string `json:"access_token"` + Endpoint *string `json:"endpoint"` + Type *CustomDestinationForwardDestinationSplunkType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AccessToken == nil { + return fmt.Errorf("required field access_token missing") + } + if all.Endpoint == nil { + return fmt.Errorf("required field endpoint 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{"access_token", "endpoint", "type"}) + } else { + return err + } + + hasInvalidField := false + o.AccessToken = *all.AccessToken + o.Endpoint = *all.Endpoint + 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_custom_destination_forward_destination_splunk_type.go b/api/datadogV2/model_custom_destination_forward_destination_splunk_type.go new file mode 100644 index 00000000000..2617c360314 --- /dev/null +++ b/api/datadogV2/model_custom_destination_forward_destination_splunk_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" +) + +// CustomDestinationForwardDestinationSplunkType Type of the Splunk HTTP Event Collector (HEC) destination. +type CustomDestinationForwardDestinationSplunkType string + +// List of CustomDestinationForwardDestinationSplunkType. +const ( + CUSTOMDESTINATIONFORWARDDESTINATIONSPLUNKTYPE_SPLUNK_HEC CustomDestinationForwardDestinationSplunkType = "splunk_hec" +) + +var allowedCustomDestinationForwardDestinationSplunkTypeEnumValues = []CustomDestinationForwardDestinationSplunkType{ + CUSTOMDESTINATIONFORWARDDESTINATIONSPLUNKTYPE_SPLUNK_HEC, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationForwardDestinationSplunkType) GetAllowedValues() []CustomDestinationForwardDestinationSplunkType { + return allowedCustomDestinationForwardDestinationSplunkTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationForwardDestinationSplunkType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationForwardDestinationSplunkType(value) + return nil +} + +// NewCustomDestinationForwardDestinationSplunkTypeFromValue returns a pointer to a valid CustomDestinationForwardDestinationSplunkType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationForwardDestinationSplunkTypeFromValue(v string) (*CustomDestinationForwardDestinationSplunkType, error) { + ev := CustomDestinationForwardDestinationSplunkType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationForwardDestinationSplunkType: valid values are %v", v, allowedCustomDestinationForwardDestinationSplunkTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationForwardDestinationSplunkType) IsValid() bool { + for _, existing := range allowedCustomDestinationForwardDestinationSplunkTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationForwardDestinationSplunkType value. +func (v CustomDestinationForwardDestinationSplunkType) Ptr() *CustomDestinationForwardDestinationSplunkType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_http_destination_auth.go b/api/datadogV2/model_custom_destination_http_destination_auth.go new file mode 100644 index 00000000000..b6c679c25f7 --- /dev/null +++ b/api/datadogV2/model_custom_destination_http_destination_auth.go @@ -0,0 +1,105 @@ +// 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" +) + +// CustomDestinationHttpDestinationAuth - Authentication method of the HTTP requests. +type CustomDestinationHttpDestinationAuth struct { + CustomDestinationHttpDestinationAuthBasic *CustomDestinationHttpDestinationAuthBasic + CustomDestinationHttpDestinationAuthCustomHeader *CustomDestinationHttpDestinationAuthCustomHeader + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// CustomDestinationHttpDestinationAuthBasicAsCustomDestinationHttpDestinationAuth is a convenience function that returns CustomDestinationHttpDestinationAuthBasic wrapped in CustomDestinationHttpDestinationAuth. +func CustomDestinationHttpDestinationAuthBasicAsCustomDestinationHttpDestinationAuth(v *CustomDestinationHttpDestinationAuthBasic) CustomDestinationHttpDestinationAuth { + return CustomDestinationHttpDestinationAuth{CustomDestinationHttpDestinationAuthBasic: v} +} + +// CustomDestinationHttpDestinationAuthCustomHeaderAsCustomDestinationHttpDestinationAuth is a convenience function that returns CustomDestinationHttpDestinationAuthCustomHeader wrapped in CustomDestinationHttpDestinationAuth. +func CustomDestinationHttpDestinationAuthCustomHeaderAsCustomDestinationHttpDestinationAuth(v *CustomDestinationHttpDestinationAuthCustomHeader) CustomDestinationHttpDestinationAuth { + return CustomDestinationHttpDestinationAuth{CustomDestinationHttpDestinationAuthCustomHeader: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *CustomDestinationHttpDestinationAuth) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into CustomDestinationHttpDestinationAuthBasic + err = datadog.Unmarshal(data, &obj.CustomDestinationHttpDestinationAuthBasic) + if err == nil { + if obj.CustomDestinationHttpDestinationAuthBasic != nil && obj.CustomDestinationHttpDestinationAuthBasic.UnparsedObject == nil { + jsonCustomDestinationHttpDestinationAuthBasic, _ := datadog.Marshal(obj.CustomDestinationHttpDestinationAuthBasic) + if string(jsonCustomDestinationHttpDestinationAuthBasic) == "{}" { // empty struct + obj.CustomDestinationHttpDestinationAuthBasic = nil + } else { + match++ + } + } else { + obj.CustomDestinationHttpDestinationAuthBasic = nil + } + } else { + obj.CustomDestinationHttpDestinationAuthBasic = nil + } + + // try to unmarshal data into CustomDestinationHttpDestinationAuthCustomHeader + err = datadog.Unmarshal(data, &obj.CustomDestinationHttpDestinationAuthCustomHeader) + if err == nil { + if obj.CustomDestinationHttpDestinationAuthCustomHeader != nil && obj.CustomDestinationHttpDestinationAuthCustomHeader.UnparsedObject == nil { + jsonCustomDestinationHttpDestinationAuthCustomHeader, _ := datadog.Marshal(obj.CustomDestinationHttpDestinationAuthCustomHeader) + if string(jsonCustomDestinationHttpDestinationAuthCustomHeader) == "{}" { // empty struct + obj.CustomDestinationHttpDestinationAuthCustomHeader = nil + } else { + match++ + } + } else { + obj.CustomDestinationHttpDestinationAuthCustomHeader = nil + } + } else { + obj.CustomDestinationHttpDestinationAuthCustomHeader = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.CustomDestinationHttpDestinationAuthBasic = nil + obj.CustomDestinationHttpDestinationAuthCustomHeader = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj CustomDestinationHttpDestinationAuth) MarshalJSON() ([]byte, error) { + if obj.CustomDestinationHttpDestinationAuthBasic != nil { + return datadog.Marshal(&obj.CustomDestinationHttpDestinationAuthBasic) + } + + if obj.CustomDestinationHttpDestinationAuthCustomHeader != nil { + return datadog.Marshal(&obj.CustomDestinationHttpDestinationAuthCustomHeader) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *CustomDestinationHttpDestinationAuth) GetActualInstance() interface{} { + if obj.CustomDestinationHttpDestinationAuthBasic != nil { + return obj.CustomDestinationHttpDestinationAuthBasic + } + + if obj.CustomDestinationHttpDestinationAuthCustomHeader != nil { + return obj.CustomDestinationHttpDestinationAuthCustomHeader + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_custom_destination_http_destination_auth_basic.go b/api/datadogV2/model_custom_destination_http_destination_auth_basic.go new file mode 100644 index 00000000000..de12330fdfa --- /dev/null +++ b/api/datadogV2/model_custom_destination_http_destination_auth_basic.go @@ -0,0 +1,177 @@ +// 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" +) + +// CustomDestinationHttpDestinationAuthBasic Basic access authentication. +type CustomDestinationHttpDestinationAuthBasic struct { + // The password of the authentication. This field is not returned by the API. + Password string `json:"password"` + // Type of the basic access authentication. + Type CustomDestinationHttpDestinationAuthBasicType `json:"type"` + // The username of the authentication. This field is not returned by the API. + Username string `json:"username"` + // 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{} +} + +// NewCustomDestinationHttpDestinationAuthBasic instantiates a new CustomDestinationHttpDestinationAuthBasic 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 NewCustomDestinationHttpDestinationAuthBasic(password string, typeVar CustomDestinationHttpDestinationAuthBasicType, username string) *CustomDestinationHttpDestinationAuthBasic { + this := CustomDestinationHttpDestinationAuthBasic{} + this.Password = password + this.Type = typeVar + this.Username = username + return &this +} + +// NewCustomDestinationHttpDestinationAuthBasicWithDefaults instantiates a new CustomDestinationHttpDestinationAuthBasic 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 NewCustomDestinationHttpDestinationAuthBasicWithDefaults() *CustomDestinationHttpDestinationAuthBasic { + this := CustomDestinationHttpDestinationAuthBasic{} + var typeVar CustomDestinationHttpDestinationAuthBasicType = CUSTOMDESTINATIONHTTPDESTINATIONAUTHBASICTYPE_BASIC + this.Type = typeVar + return &this +} + +// GetPassword returns the Password field value. +func (o *CustomDestinationHttpDestinationAuthBasic) GetPassword() string { + if o == nil { + var ret string + return ret + } + return o.Password +} + +// GetPasswordOk returns a tuple with the Password field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationHttpDestinationAuthBasic) GetPasswordOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Password, true +} + +// SetPassword sets field value. +func (o *CustomDestinationHttpDestinationAuthBasic) SetPassword(v string) { + o.Password = v +} + +// GetType returns the Type field value. +func (o *CustomDestinationHttpDestinationAuthBasic) GetType() CustomDestinationHttpDestinationAuthBasicType { + if o == nil { + var ret CustomDestinationHttpDestinationAuthBasicType + 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 *CustomDestinationHttpDestinationAuthBasic) GetTypeOk() (*CustomDestinationHttpDestinationAuthBasicType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationHttpDestinationAuthBasic) SetType(v CustomDestinationHttpDestinationAuthBasicType) { + o.Type = v +} + +// GetUsername returns the Username field value. +func (o *CustomDestinationHttpDestinationAuthBasic) GetUsername() string { + if o == nil { + var ret string + return ret + } + return o.Username +} + +// GetUsernameOk returns a tuple with the Username field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationHttpDestinationAuthBasic) GetUsernameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Username, true +} + +// SetUsername sets field value. +func (o *CustomDestinationHttpDestinationAuthBasic) SetUsername(v string) { + o.Username = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationHttpDestinationAuthBasic) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["password"] = o.Password + toSerialize["type"] = o.Type + toSerialize["username"] = o.Username + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationHttpDestinationAuthBasic) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Password *string `json:"password"` + Type *CustomDestinationHttpDestinationAuthBasicType `json:"type"` + Username *string `json:"username"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Password == nil { + return fmt.Errorf("required field password missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + if all.Username == nil { + return fmt.Errorf("required field username missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"password", "type", "username"}) + } else { + return err + } + + hasInvalidField := false + o.Password = *all.Password + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + o.Username = *all.Username + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_custom_destination_http_destination_auth_basic_type.go b/api/datadogV2/model_custom_destination_http_destination_auth_basic_type.go new file mode 100644 index 00000000000..f6b07c96e82 --- /dev/null +++ b/api/datadogV2/model_custom_destination_http_destination_auth_basic_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" +) + +// CustomDestinationHttpDestinationAuthBasicType Type of the basic access authentication. +type CustomDestinationHttpDestinationAuthBasicType string + +// List of CustomDestinationHttpDestinationAuthBasicType. +const ( + CUSTOMDESTINATIONHTTPDESTINATIONAUTHBASICTYPE_BASIC CustomDestinationHttpDestinationAuthBasicType = "basic" +) + +var allowedCustomDestinationHttpDestinationAuthBasicTypeEnumValues = []CustomDestinationHttpDestinationAuthBasicType{ + CUSTOMDESTINATIONHTTPDESTINATIONAUTHBASICTYPE_BASIC, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationHttpDestinationAuthBasicType) GetAllowedValues() []CustomDestinationHttpDestinationAuthBasicType { + return allowedCustomDestinationHttpDestinationAuthBasicTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationHttpDestinationAuthBasicType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationHttpDestinationAuthBasicType(value) + return nil +} + +// NewCustomDestinationHttpDestinationAuthBasicTypeFromValue returns a pointer to a valid CustomDestinationHttpDestinationAuthBasicType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationHttpDestinationAuthBasicTypeFromValue(v string) (*CustomDestinationHttpDestinationAuthBasicType, error) { + ev := CustomDestinationHttpDestinationAuthBasicType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationHttpDestinationAuthBasicType: valid values are %v", v, allowedCustomDestinationHttpDestinationAuthBasicTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationHttpDestinationAuthBasicType) IsValid() bool { + for _, existing := range allowedCustomDestinationHttpDestinationAuthBasicTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationHttpDestinationAuthBasicType value. +func (v CustomDestinationHttpDestinationAuthBasicType) Ptr() *CustomDestinationHttpDestinationAuthBasicType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_http_destination_auth_custom_header.go b/api/datadogV2/model_custom_destination_http_destination_auth_custom_header.go new file mode 100644 index 00000000000..e507d6d8ead --- /dev/null +++ b/api/datadogV2/model_custom_destination_http_destination_auth_custom_header.go @@ -0,0 +1,177 @@ +// 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" +) + +// CustomDestinationHttpDestinationAuthCustomHeader Custom header access authentication. +type CustomDestinationHttpDestinationAuthCustomHeader struct { + // The header name of the authentication. + HeaderName string `json:"header_name"` + // The header value of the authentication. This field is not returned by the API. + HeaderValue string `json:"header_value"` + // Type of the custom header access authentication. + Type CustomDestinationHttpDestinationAuthCustomHeaderType `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{} +} + +// NewCustomDestinationHttpDestinationAuthCustomHeader instantiates a new CustomDestinationHttpDestinationAuthCustomHeader 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 NewCustomDestinationHttpDestinationAuthCustomHeader(headerName string, headerValue string, typeVar CustomDestinationHttpDestinationAuthCustomHeaderType) *CustomDestinationHttpDestinationAuthCustomHeader { + this := CustomDestinationHttpDestinationAuthCustomHeader{} + this.HeaderName = headerName + this.HeaderValue = headerValue + this.Type = typeVar + return &this +} + +// NewCustomDestinationHttpDestinationAuthCustomHeaderWithDefaults instantiates a new CustomDestinationHttpDestinationAuthCustomHeader 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 NewCustomDestinationHttpDestinationAuthCustomHeaderWithDefaults() *CustomDestinationHttpDestinationAuthCustomHeader { + this := CustomDestinationHttpDestinationAuthCustomHeader{} + var typeVar CustomDestinationHttpDestinationAuthCustomHeaderType = CUSTOMDESTINATIONHTTPDESTINATIONAUTHCUSTOMHEADERTYPE_CUSTOM_HEADER + this.Type = typeVar + return &this +} + +// GetHeaderName returns the HeaderName field value. +func (o *CustomDestinationHttpDestinationAuthCustomHeader) GetHeaderName() string { + if o == nil { + var ret string + return ret + } + return o.HeaderName +} + +// GetHeaderNameOk returns a tuple with the HeaderName field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationHttpDestinationAuthCustomHeader) GetHeaderNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.HeaderName, true +} + +// SetHeaderName sets field value. +func (o *CustomDestinationHttpDestinationAuthCustomHeader) SetHeaderName(v string) { + o.HeaderName = v +} + +// GetHeaderValue returns the HeaderValue field value. +func (o *CustomDestinationHttpDestinationAuthCustomHeader) GetHeaderValue() string { + if o == nil { + var ret string + return ret + } + return o.HeaderValue +} + +// GetHeaderValueOk returns a tuple with the HeaderValue field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationHttpDestinationAuthCustomHeader) GetHeaderValueOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.HeaderValue, true +} + +// SetHeaderValue sets field value. +func (o *CustomDestinationHttpDestinationAuthCustomHeader) SetHeaderValue(v string) { + o.HeaderValue = v +} + +// GetType returns the Type field value. +func (o *CustomDestinationHttpDestinationAuthCustomHeader) GetType() CustomDestinationHttpDestinationAuthCustomHeaderType { + if o == nil { + var ret CustomDestinationHttpDestinationAuthCustomHeaderType + 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 *CustomDestinationHttpDestinationAuthCustomHeader) GetTypeOk() (*CustomDestinationHttpDestinationAuthCustomHeaderType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationHttpDestinationAuthCustomHeader) SetType(v CustomDestinationHttpDestinationAuthCustomHeaderType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationHttpDestinationAuthCustomHeader) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["header_name"] = o.HeaderName + toSerialize["header_value"] = o.HeaderValue + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationHttpDestinationAuthCustomHeader) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + HeaderName *string `json:"header_name"` + HeaderValue *string `json:"header_value"` + Type *CustomDestinationHttpDestinationAuthCustomHeaderType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.HeaderName == nil { + return fmt.Errorf("required field header_name missing") + } + if all.HeaderValue == nil { + return fmt.Errorf("required field header_value 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{"header_name", "header_value", "type"}) + } else { + return err + } + + hasInvalidField := false + o.HeaderName = *all.HeaderName + o.HeaderValue = *all.HeaderValue + 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_custom_destination_http_destination_auth_custom_header_type.go b/api/datadogV2/model_custom_destination_http_destination_auth_custom_header_type.go new file mode 100644 index 00000000000..085b675e09a --- /dev/null +++ b/api/datadogV2/model_custom_destination_http_destination_auth_custom_header_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" +) + +// CustomDestinationHttpDestinationAuthCustomHeaderType Type of the custom header access authentication. +type CustomDestinationHttpDestinationAuthCustomHeaderType string + +// List of CustomDestinationHttpDestinationAuthCustomHeaderType. +const ( + CUSTOMDESTINATIONHTTPDESTINATIONAUTHCUSTOMHEADERTYPE_CUSTOM_HEADER CustomDestinationHttpDestinationAuthCustomHeaderType = "custom_header" +) + +var allowedCustomDestinationHttpDestinationAuthCustomHeaderTypeEnumValues = []CustomDestinationHttpDestinationAuthCustomHeaderType{ + CUSTOMDESTINATIONHTTPDESTINATIONAUTHCUSTOMHEADERTYPE_CUSTOM_HEADER, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationHttpDestinationAuthCustomHeaderType) GetAllowedValues() []CustomDestinationHttpDestinationAuthCustomHeaderType { + return allowedCustomDestinationHttpDestinationAuthCustomHeaderTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationHttpDestinationAuthCustomHeaderType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationHttpDestinationAuthCustomHeaderType(value) + return nil +} + +// NewCustomDestinationHttpDestinationAuthCustomHeaderTypeFromValue returns a pointer to a valid CustomDestinationHttpDestinationAuthCustomHeaderType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationHttpDestinationAuthCustomHeaderTypeFromValue(v string) (*CustomDestinationHttpDestinationAuthCustomHeaderType, error) { + ev := CustomDestinationHttpDestinationAuthCustomHeaderType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationHttpDestinationAuthCustomHeaderType: valid values are %v", v, allowedCustomDestinationHttpDestinationAuthCustomHeaderTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationHttpDestinationAuthCustomHeaderType) IsValid() bool { + for _, existing := range allowedCustomDestinationHttpDestinationAuthCustomHeaderTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationHttpDestinationAuthCustomHeaderType value. +func (v CustomDestinationHttpDestinationAuthCustomHeaderType) Ptr() *CustomDestinationHttpDestinationAuthCustomHeaderType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_response.go b/api/datadogV2/model_custom_destination_response.go new file mode 100644 index 00000000000..c3da557bc7f --- /dev/null +++ b/api/datadogV2/model_custom_destination_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" +) + +// CustomDestinationResponse The custom destination. +type CustomDestinationResponse struct { + // The definition of a custom destination. + Data *CustomDestinationResponseDefinition `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{} +} + +// NewCustomDestinationResponse instantiates a new CustomDestinationResponse 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 NewCustomDestinationResponse() *CustomDestinationResponse { + this := CustomDestinationResponse{} + return &this +} + +// NewCustomDestinationResponseWithDefaults instantiates a new CustomDestinationResponse 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 NewCustomDestinationResponseWithDefaults() *CustomDestinationResponse { + this := CustomDestinationResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CustomDestinationResponse) GetData() CustomDestinationResponseDefinition { + if o == nil || o.Data == nil { + var ret CustomDestinationResponseDefinition + 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 *CustomDestinationResponse) GetDataOk() (*CustomDestinationResponseDefinition, 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 *CustomDestinationResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given CustomDestinationResponseDefinition and assigns it to the Data field. +func (o *CustomDestinationResponse) SetData(v CustomDestinationResponseDefinition) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationResponse) 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 *CustomDestinationResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CustomDestinationResponseDefinition `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_custom_destination_response_attributes.go b/api/datadogV2/model_custom_destination_response_attributes.go new file mode 100644 index 00000000000..9c6651a88f0 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_attributes.go @@ -0,0 +1,345 @@ +// 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" +) + +// CustomDestinationResponseAttributes The attributes associated with the custom destination. +type CustomDestinationResponseAttributes struct { + // Whether logs matching this custom destination should be forwarded or not. + Enabled *bool `json:"enabled,omitempty"` + // Whether tags from the forwarded logs should be forwarded or not. + ForwardTags *bool `json:"forward_tags,omitempty"` + // List of [keys of tags](https://docs.datadoghq.com/getting_started/tagging/#define-tags) to be filtered. + // + // An empty list represents no restriction is in place and either all or no tags will be + // forwarded depending on `forward_tags_restriction_list_type` parameter. + ForwardTagsRestrictionList []string `json:"forward_tags_restriction_list,omitempty"` + // How `forward_tags_restriction_list` parameter should be interpreted. + // If `ALLOW_LIST`, then only tags whose keys on the forwarded logs match the ones on the restriction list + // are forwarded. + // + // `BLOCK_LIST` works the opposite way. It does not forward the tags matching the ones on the list. + ForwardTagsRestrictionListType *CustomDestinationAttributeTagsRestrictionListType `json:"forward_tags_restriction_list_type,omitempty"` + // A custom destination's location to forward logs. + ForwarderDestination *CustomDestinationResponseForwardDestination `json:"forwarder_destination,omitempty"` + // The custom destination name. + Name *string `json:"name,omitempty"` + // The custom destination query filter. Logs matching this query are forwarded to the destination. + Query *string `json:"query,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{} +} + +// NewCustomDestinationResponseAttributes instantiates a new CustomDestinationResponseAttributes 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 NewCustomDestinationResponseAttributes() *CustomDestinationResponseAttributes { + this := CustomDestinationResponseAttributes{} + var enabled bool = true + this.Enabled = &enabled + var forwardTags bool = true + this.ForwardTags = &forwardTags + var forwardTagsRestrictionListType CustomDestinationAttributeTagsRestrictionListType = CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST + this.ForwardTagsRestrictionListType = &forwardTagsRestrictionListType + var query string = "" + this.Query = &query + return &this +} + +// NewCustomDestinationResponseAttributesWithDefaults instantiates a new CustomDestinationResponseAttributes 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 NewCustomDestinationResponseAttributesWithDefaults() *CustomDestinationResponseAttributes { + this := CustomDestinationResponseAttributes{} + var enabled bool = true + this.Enabled = &enabled + var forwardTags bool = true + this.ForwardTags = &forwardTags + var forwardTagsRestrictionListType CustomDestinationAttributeTagsRestrictionListType = CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST + this.ForwardTagsRestrictionListType = &forwardTagsRestrictionListType + var query string = "" + this.Query = &query + return &this +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *CustomDestinationResponseAttributes) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseAttributes) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *CustomDestinationResponseAttributes) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *CustomDestinationResponseAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetForwardTags returns the ForwardTags field value if set, zero value otherwise. +func (o *CustomDestinationResponseAttributes) GetForwardTags() bool { + if o == nil || o.ForwardTags == nil { + var ret bool + return ret + } + return *o.ForwardTags +} + +// GetForwardTagsOk returns a tuple with the ForwardTags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseAttributes) GetForwardTagsOk() (*bool, bool) { + if o == nil || o.ForwardTags == nil { + return nil, false + } + return o.ForwardTags, true +} + +// HasForwardTags returns a boolean if a field has been set. +func (o *CustomDestinationResponseAttributes) HasForwardTags() bool { + return o != nil && o.ForwardTags != nil +} + +// SetForwardTags gets a reference to the given bool and assigns it to the ForwardTags field. +func (o *CustomDestinationResponseAttributes) SetForwardTags(v bool) { + o.ForwardTags = &v +} + +// GetForwardTagsRestrictionList returns the ForwardTagsRestrictionList field value if set, zero value otherwise. +func (o *CustomDestinationResponseAttributes) GetForwardTagsRestrictionList() []string { + if o == nil || o.ForwardTagsRestrictionList == nil { + var ret []string + return ret + } + return o.ForwardTagsRestrictionList +} + +// GetForwardTagsRestrictionListOk returns a tuple with the ForwardTagsRestrictionList field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseAttributes) GetForwardTagsRestrictionListOk() (*[]string, bool) { + if o == nil || o.ForwardTagsRestrictionList == nil { + return nil, false + } + return &o.ForwardTagsRestrictionList, true +} + +// HasForwardTagsRestrictionList returns a boolean if a field has been set. +func (o *CustomDestinationResponseAttributes) HasForwardTagsRestrictionList() bool { + return o != nil && o.ForwardTagsRestrictionList != nil +} + +// SetForwardTagsRestrictionList gets a reference to the given []string and assigns it to the ForwardTagsRestrictionList field. +func (o *CustomDestinationResponseAttributes) SetForwardTagsRestrictionList(v []string) { + o.ForwardTagsRestrictionList = v +} + +// GetForwardTagsRestrictionListType returns the ForwardTagsRestrictionListType field value if set, zero value otherwise. +func (o *CustomDestinationResponseAttributes) GetForwardTagsRestrictionListType() CustomDestinationAttributeTagsRestrictionListType { + if o == nil || o.ForwardTagsRestrictionListType == nil { + var ret CustomDestinationAttributeTagsRestrictionListType + return ret + } + return *o.ForwardTagsRestrictionListType +} + +// GetForwardTagsRestrictionListTypeOk returns a tuple with the ForwardTagsRestrictionListType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseAttributes) GetForwardTagsRestrictionListTypeOk() (*CustomDestinationAttributeTagsRestrictionListType, bool) { + if o == nil || o.ForwardTagsRestrictionListType == nil { + return nil, false + } + return o.ForwardTagsRestrictionListType, true +} + +// HasForwardTagsRestrictionListType returns a boolean if a field has been set. +func (o *CustomDestinationResponseAttributes) HasForwardTagsRestrictionListType() bool { + return o != nil && o.ForwardTagsRestrictionListType != nil +} + +// SetForwardTagsRestrictionListType gets a reference to the given CustomDestinationAttributeTagsRestrictionListType and assigns it to the ForwardTagsRestrictionListType field. +func (o *CustomDestinationResponseAttributes) SetForwardTagsRestrictionListType(v CustomDestinationAttributeTagsRestrictionListType) { + o.ForwardTagsRestrictionListType = &v +} + +// GetForwarderDestination returns the ForwarderDestination field value if set, zero value otherwise. +func (o *CustomDestinationResponseAttributes) GetForwarderDestination() CustomDestinationResponseForwardDestination { + if o == nil || o.ForwarderDestination == nil { + var ret CustomDestinationResponseForwardDestination + return ret + } + return *o.ForwarderDestination +} + +// GetForwarderDestinationOk returns a tuple with the ForwarderDestination field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseAttributes) GetForwarderDestinationOk() (*CustomDestinationResponseForwardDestination, bool) { + if o == nil || o.ForwarderDestination == nil { + return nil, false + } + return o.ForwarderDestination, true +} + +// HasForwarderDestination returns a boolean if a field has been set. +func (o *CustomDestinationResponseAttributes) HasForwarderDestination() bool { + return o != nil && o.ForwarderDestination != nil +} + +// SetForwarderDestination gets a reference to the given CustomDestinationResponseForwardDestination and assigns it to the ForwarderDestination field. +func (o *CustomDestinationResponseAttributes) SetForwarderDestination(v CustomDestinationResponseForwardDestination) { + o.ForwarderDestination = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CustomDestinationResponseAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CustomDestinationResponseAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CustomDestinationResponseAttributes) SetName(v string) { + o.Name = &v +} + +// GetQuery returns the Query field value if set, zero value otherwise. +func (o *CustomDestinationResponseAttributes) GetQuery() string { + if o == nil || o.Query == nil { + var ret string + return ret + } + return *o.Query +} + +// GetQueryOk returns a tuple with the Query field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseAttributes) GetQueryOk() (*string, bool) { + if o == nil || o.Query == nil { + return nil, false + } + return o.Query, true +} + +// HasQuery returns a boolean if a field has been set. +func (o *CustomDestinationResponseAttributes) HasQuery() bool { + return o != nil && o.Query != nil +} + +// SetQuery gets a reference to the given string and assigns it to the Query field. +func (o *CustomDestinationResponseAttributes) SetQuery(v string) { + o.Query = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationResponseAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.ForwardTags != nil { + toSerialize["forward_tags"] = o.ForwardTags + } + if o.ForwardTagsRestrictionList != nil { + toSerialize["forward_tags_restriction_list"] = o.ForwardTagsRestrictionList + } + if o.ForwardTagsRestrictionListType != nil { + toSerialize["forward_tags_restriction_list_type"] = o.ForwardTagsRestrictionListType + } + if o.ForwarderDestination != nil { + toSerialize["forwarder_destination"] = o.ForwarderDestination + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Query != nil { + toSerialize["query"] = o.Query + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Enabled *bool `json:"enabled,omitempty"` + ForwardTags *bool `json:"forward_tags,omitempty"` + ForwardTagsRestrictionList []string `json:"forward_tags_restriction_list,omitempty"` + ForwardTagsRestrictionListType *CustomDestinationAttributeTagsRestrictionListType `json:"forward_tags_restriction_list_type,omitempty"` + ForwarderDestination *CustomDestinationResponseForwardDestination `json:"forwarder_destination,omitempty"` + Name *string `json:"name,omitempty"` + Query *string `json:"query,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{"enabled", "forward_tags", "forward_tags_restriction_list", "forward_tags_restriction_list_type", "forwarder_destination", "name", "query"}) + } else { + return err + } + + hasInvalidField := false + o.Enabled = all.Enabled + o.ForwardTags = all.ForwardTags + o.ForwardTagsRestrictionList = all.ForwardTagsRestrictionList + if all.ForwardTagsRestrictionListType != nil && !all.ForwardTagsRestrictionListType.IsValid() { + hasInvalidField = true + } else { + o.ForwardTagsRestrictionListType = all.ForwardTagsRestrictionListType + } + o.ForwarderDestination = all.ForwarderDestination + o.Name = all.Name + o.Query = all.Query + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_custom_destination_response_definition.go b/api/datadogV2/model_custom_destination_response_definition.go new file mode 100644 index 00000000000..37c3ca1e6a1 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_definition.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" +) + +// CustomDestinationResponseDefinition The definition of a custom destination. +type CustomDestinationResponseDefinition struct { + // The attributes associated with the custom destination. + Attributes *CustomDestinationResponseAttributes `json:"attributes,omitempty"` + // The custom destination ID. + Id *string `json:"id,omitempty"` + // The type of the resource. The value should always be `custom_destination`. + Type *CustomDestinationType `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{} +} + +// NewCustomDestinationResponseDefinition instantiates a new CustomDestinationResponseDefinition 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 NewCustomDestinationResponseDefinition() *CustomDestinationResponseDefinition { + this := CustomDestinationResponseDefinition{} + var typeVar CustomDestinationType = CUSTOMDESTINATIONTYPE_custom_destination + this.Type = &typeVar + return &this +} + +// NewCustomDestinationResponseDefinitionWithDefaults instantiates a new CustomDestinationResponseDefinition 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 NewCustomDestinationResponseDefinitionWithDefaults() *CustomDestinationResponseDefinition { + this := CustomDestinationResponseDefinition{} + var typeVar CustomDestinationType = CUSTOMDESTINATIONTYPE_custom_destination + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *CustomDestinationResponseDefinition) GetAttributes() CustomDestinationResponseAttributes { + if o == nil || o.Attributes == nil { + var ret CustomDestinationResponseAttributes + 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 *CustomDestinationResponseDefinition) GetAttributesOk() (*CustomDestinationResponseAttributes, 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 *CustomDestinationResponseDefinition) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given CustomDestinationResponseAttributes and assigns it to the Attributes field. +func (o *CustomDestinationResponseDefinition) SetAttributes(v CustomDestinationResponseAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *CustomDestinationResponseDefinition) 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 *CustomDestinationResponseDefinition) 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 *CustomDestinationResponseDefinition) 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 *CustomDestinationResponseDefinition) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *CustomDestinationResponseDefinition) GetType() CustomDestinationType { + if o == nil || o.Type == nil { + var ret CustomDestinationType + 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 *CustomDestinationResponseDefinition) GetTypeOk() (*CustomDestinationType, 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 *CustomDestinationResponseDefinition) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given CustomDestinationType and assigns it to the Type field. +func (o *CustomDestinationResponseDefinition) SetType(v CustomDestinationType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationResponseDefinition) 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 *CustomDestinationResponseDefinition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CustomDestinationResponseAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *CustomDestinationType `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_custom_destination_response_forward_destination.go b/api/datadogV2/model_custom_destination_response_forward_destination.go new file mode 100644 index 00000000000..a6547828e07 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_forward_destination.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" +) + +// CustomDestinationResponseForwardDestination - A custom destination's location to forward logs. +type CustomDestinationResponseForwardDestination struct { + CustomDestinationResponseForwardDestinationHttp *CustomDestinationResponseForwardDestinationHttp + CustomDestinationResponseForwardDestinationSplunk *CustomDestinationResponseForwardDestinationSplunk + CustomDestinationResponseForwardDestinationElasticsearch *CustomDestinationResponseForwardDestinationElasticsearch + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// CustomDestinationResponseForwardDestinationHttpAsCustomDestinationResponseForwardDestination is a convenience function that returns CustomDestinationResponseForwardDestinationHttp wrapped in CustomDestinationResponseForwardDestination. +func CustomDestinationResponseForwardDestinationHttpAsCustomDestinationResponseForwardDestination(v *CustomDestinationResponseForwardDestinationHttp) CustomDestinationResponseForwardDestination { + return CustomDestinationResponseForwardDestination{CustomDestinationResponseForwardDestinationHttp: v} +} + +// CustomDestinationResponseForwardDestinationSplunkAsCustomDestinationResponseForwardDestination is a convenience function that returns CustomDestinationResponseForwardDestinationSplunk wrapped in CustomDestinationResponseForwardDestination. +func CustomDestinationResponseForwardDestinationSplunkAsCustomDestinationResponseForwardDestination(v *CustomDestinationResponseForwardDestinationSplunk) CustomDestinationResponseForwardDestination { + return CustomDestinationResponseForwardDestination{CustomDestinationResponseForwardDestinationSplunk: v} +} + +// CustomDestinationResponseForwardDestinationElasticsearchAsCustomDestinationResponseForwardDestination is a convenience function that returns CustomDestinationResponseForwardDestinationElasticsearch wrapped in CustomDestinationResponseForwardDestination. +func CustomDestinationResponseForwardDestinationElasticsearchAsCustomDestinationResponseForwardDestination(v *CustomDestinationResponseForwardDestinationElasticsearch) CustomDestinationResponseForwardDestination { + return CustomDestinationResponseForwardDestination{CustomDestinationResponseForwardDestinationElasticsearch: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *CustomDestinationResponseForwardDestination) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into CustomDestinationResponseForwardDestinationHttp + err = datadog.Unmarshal(data, &obj.CustomDestinationResponseForwardDestinationHttp) + if err == nil { + if obj.CustomDestinationResponseForwardDestinationHttp != nil && obj.CustomDestinationResponseForwardDestinationHttp.UnparsedObject == nil { + jsonCustomDestinationResponseForwardDestinationHttp, _ := datadog.Marshal(obj.CustomDestinationResponseForwardDestinationHttp) + if string(jsonCustomDestinationResponseForwardDestinationHttp) == "{}" { // empty struct + obj.CustomDestinationResponseForwardDestinationHttp = nil + } else { + match++ + } + } else { + obj.CustomDestinationResponseForwardDestinationHttp = nil + } + } else { + obj.CustomDestinationResponseForwardDestinationHttp = nil + } + + // try to unmarshal data into CustomDestinationResponseForwardDestinationSplunk + err = datadog.Unmarshal(data, &obj.CustomDestinationResponseForwardDestinationSplunk) + if err == nil { + if obj.CustomDestinationResponseForwardDestinationSplunk != nil && obj.CustomDestinationResponseForwardDestinationSplunk.UnparsedObject == nil { + jsonCustomDestinationResponseForwardDestinationSplunk, _ := datadog.Marshal(obj.CustomDestinationResponseForwardDestinationSplunk) + if string(jsonCustomDestinationResponseForwardDestinationSplunk) == "{}" { // empty struct + obj.CustomDestinationResponseForwardDestinationSplunk = nil + } else { + match++ + } + } else { + obj.CustomDestinationResponseForwardDestinationSplunk = nil + } + } else { + obj.CustomDestinationResponseForwardDestinationSplunk = nil + } + + // try to unmarshal data into CustomDestinationResponseForwardDestinationElasticsearch + err = datadog.Unmarshal(data, &obj.CustomDestinationResponseForwardDestinationElasticsearch) + if err == nil { + if obj.CustomDestinationResponseForwardDestinationElasticsearch != nil && obj.CustomDestinationResponseForwardDestinationElasticsearch.UnparsedObject == nil { + jsonCustomDestinationResponseForwardDestinationElasticsearch, _ := datadog.Marshal(obj.CustomDestinationResponseForwardDestinationElasticsearch) + if string(jsonCustomDestinationResponseForwardDestinationElasticsearch) == "{}" { // empty struct + obj.CustomDestinationResponseForwardDestinationElasticsearch = nil + } else { + match++ + } + } else { + obj.CustomDestinationResponseForwardDestinationElasticsearch = nil + } + } else { + obj.CustomDestinationResponseForwardDestinationElasticsearch = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.CustomDestinationResponseForwardDestinationHttp = nil + obj.CustomDestinationResponseForwardDestinationSplunk = nil + obj.CustomDestinationResponseForwardDestinationElasticsearch = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj CustomDestinationResponseForwardDestination) MarshalJSON() ([]byte, error) { + if obj.CustomDestinationResponseForwardDestinationHttp != nil { + return datadog.Marshal(&obj.CustomDestinationResponseForwardDestinationHttp) + } + + if obj.CustomDestinationResponseForwardDestinationSplunk != nil { + return datadog.Marshal(&obj.CustomDestinationResponseForwardDestinationSplunk) + } + + if obj.CustomDestinationResponseForwardDestinationElasticsearch != nil { + return datadog.Marshal(&obj.CustomDestinationResponseForwardDestinationElasticsearch) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *CustomDestinationResponseForwardDestination) GetActualInstance() interface{} { + if obj.CustomDestinationResponseForwardDestinationHttp != nil { + return obj.CustomDestinationResponseForwardDestinationHttp + } + + if obj.CustomDestinationResponseForwardDestinationSplunk != nil { + return obj.CustomDestinationResponseForwardDestinationSplunk + } + + if obj.CustomDestinationResponseForwardDestinationElasticsearch != nil { + return obj.CustomDestinationResponseForwardDestinationElasticsearch + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_custom_destination_response_forward_destination_elasticsearch.go b/api/datadogV2/model_custom_destination_response_forward_destination_elasticsearch.go new file mode 100644 index 00000000000..992c125949b --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_forward_destination_elasticsearch.go @@ -0,0 +1,254 @@ +// 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" +) + +// CustomDestinationResponseForwardDestinationElasticsearch The Elasticsearch destination. +type CustomDestinationResponseForwardDestinationElasticsearch struct { + // Basic access authentication. + Auth map[string]interface{} `json:"auth"` + // The destination for which logs will be forwarded to. + // Must have HTTPS scheme and forwarding back to Datadog is not allowed. + Endpoint string `json:"endpoint"` + // Name of the Elasticsearch index (must follow [Elasticsearch's criteria](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/indices-create-index.html#indices-create-api-path-params)). + IndexName string `json:"index_name"` + // Date pattern with US locale and UTC timezone to be appended to the index name after adding `-` + // (that is, `${index_name}-${indexPattern}`). + // You can customize the index rotation naming pattern by choosing one of these options: + // - Hourly: `yyyy-MM-dd-HH` (as an example, it would render: `2022-10-19-09`) + // - Daily: `yyyy-MM-dd` (as an example, it would render: `2022-10-19`) + // - Weekly: `yyyy-'W'ww` (as an example, it would render: `2022-W42`) + // - Monthly: `yyyy-MM` (as an example, it would render: `2022-10`) + // + // If this field is missing or is blank, it means that the index name will always be the same + // (that is, no rotation). + IndexRotation *string `json:"index_rotation,omitempty"` + // Type of the Elasticsearch destination. + Type CustomDestinationResponseForwardDestinationElasticsearchType `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{} +} + +// NewCustomDestinationResponseForwardDestinationElasticsearch instantiates a new CustomDestinationResponseForwardDestinationElasticsearch 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 NewCustomDestinationResponseForwardDestinationElasticsearch(auth map[string]interface{}, endpoint string, indexName string, typeVar CustomDestinationResponseForwardDestinationElasticsearchType) *CustomDestinationResponseForwardDestinationElasticsearch { + this := CustomDestinationResponseForwardDestinationElasticsearch{} + this.Auth = auth + this.Endpoint = endpoint + this.IndexName = indexName + this.Type = typeVar + return &this +} + +// NewCustomDestinationResponseForwardDestinationElasticsearchWithDefaults instantiates a new CustomDestinationResponseForwardDestinationElasticsearch 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 NewCustomDestinationResponseForwardDestinationElasticsearchWithDefaults() *CustomDestinationResponseForwardDestinationElasticsearch { + this := CustomDestinationResponseForwardDestinationElasticsearch{} + var typeVar CustomDestinationResponseForwardDestinationElasticsearchType = CUSTOMDESTINATIONRESPONSEFORWARDDESTINATIONELASTICSEARCHTYPE_ELASTICSEARCH + this.Type = typeVar + return &this +} + +// GetAuth returns the Auth field value. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) GetAuth() map[string]interface{} { + if o == nil { + var ret map[string]interface{} + return ret + } + return o.Auth +} + +// GetAuthOk returns a tuple with the Auth field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) GetAuthOk() (*map[string]interface{}, bool) { + if o == nil { + return nil, false + } + return &o.Auth, true +} + +// SetAuth sets field value. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) SetAuth(v map[string]interface{}) { + o.Auth = v +} + +// GetEndpoint returns the Endpoint field value. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) GetEndpoint() string { + if o == nil { + var ret string + return ret + } + return o.Endpoint +} + +// GetEndpointOk returns a tuple with the Endpoint field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) GetEndpointOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Endpoint, true +} + +// SetEndpoint sets field value. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) SetEndpoint(v string) { + o.Endpoint = v +} + +// GetIndexName returns the IndexName field value. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) GetIndexName() string { + if o == nil { + var ret string + return ret + } + return o.IndexName +} + +// GetIndexNameOk returns a tuple with the IndexName field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) GetIndexNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.IndexName, true +} + +// SetIndexName sets field value. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) SetIndexName(v string) { + o.IndexName = v +} + +// GetIndexRotation returns the IndexRotation field value if set, zero value otherwise. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) GetIndexRotation() string { + if o == nil || o.IndexRotation == nil { + var ret string + return ret + } + return *o.IndexRotation +} + +// GetIndexRotationOk returns a tuple with the IndexRotation field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) GetIndexRotationOk() (*string, bool) { + if o == nil || o.IndexRotation == nil { + return nil, false + } + return o.IndexRotation, true +} + +// HasIndexRotation returns a boolean if a field has been set. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) HasIndexRotation() bool { + return o != nil && o.IndexRotation != nil +} + +// SetIndexRotation gets a reference to the given string and assigns it to the IndexRotation field. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) SetIndexRotation(v string) { + o.IndexRotation = &v +} + +// GetType returns the Type field value. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) GetType() CustomDestinationResponseForwardDestinationElasticsearchType { + if o == nil { + var ret CustomDestinationResponseForwardDestinationElasticsearchType + 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 *CustomDestinationResponseForwardDestinationElasticsearch) GetTypeOk() (*CustomDestinationResponseForwardDestinationElasticsearchType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) SetType(v CustomDestinationResponseForwardDestinationElasticsearchType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationResponseForwardDestinationElasticsearch) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["auth"] = o.Auth + toSerialize["endpoint"] = o.Endpoint + toSerialize["index_name"] = o.IndexName + if o.IndexRotation != nil { + toSerialize["index_rotation"] = o.IndexRotation + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationResponseForwardDestinationElasticsearch) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Auth *map[string]interface{} `json:"auth"` + Endpoint *string `json:"endpoint"` + IndexName *string `json:"index_name"` + IndexRotation *string `json:"index_rotation,omitempty"` + Type *CustomDestinationResponseForwardDestinationElasticsearchType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Auth == nil { + return fmt.Errorf("required field auth missing") + } + if all.Endpoint == nil { + return fmt.Errorf("required field endpoint missing") + } + if all.IndexName == nil { + return fmt.Errorf("required field index_name 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{"auth", "endpoint", "index_name", "index_rotation", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Auth = *all.Auth + o.Endpoint = *all.Endpoint + o.IndexName = *all.IndexName + o.IndexRotation = all.IndexRotation + 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_custom_destination_response_forward_destination_elasticsearch_type.go b/api/datadogV2/model_custom_destination_response_forward_destination_elasticsearch_type.go new file mode 100644 index 00000000000..0691cd0cc50 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_forward_destination_elasticsearch_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" +) + +// CustomDestinationResponseForwardDestinationElasticsearchType Type of the Elasticsearch destination. +type CustomDestinationResponseForwardDestinationElasticsearchType string + +// List of CustomDestinationResponseForwardDestinationElasticsearchType. +const ( + CUSTOMDESTINATIONRESPONSEFORWARDDESTINATIONELASTICSEARCHTYPE_ELASTICSEARCH CustomDestinationResponseForwardDestinationElasticsearchType = "elasticsearch" +) + +var allowedCustomDestinationResponseForwardDestinationElasticsearchTypeEnumValues = []CustomDestinationResponseForwardDestinationElasticsearchType{ + CUSTOMDESTINATIONRESPONSEFORWARDDESTINATIONELASTICSEARCHTYPE_ELASTICSEARCH, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationResponseForwardDestinationElasticsearchType) GetAllowedValues() []CustomDestinationResponseForwardDestinationElasticsearchType { + return allowedCustomDestinationResponseForwardDestinationElasticsearchTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationResponseForwardDestinationElasticsearchType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationResponseForwardDestinationElasticsearchType(value) + return nil +} + +// NewCustomDestinationResponseForwardDestinationElasticsearchTypeFromValue returns a pointer to a valid CustomDestinationResponseForwardDestinationElasticsearchType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationResponseForwardDestinationElasticsearchTypeFromValue(v string) (*CustomDestinationResponseForwardDestinationElasticsearchType, error) { + ev := CustomDestinationResponseForwardDestinationElasticsearchType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationResponseForwardDestinationElasticsearchType: valid values are %v", v, allowedCustomDestinationResponseForwardDestinationElasticsearchTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationResponseForwardDestinationElasticsearchType) IsValid() bool { + for _, existing := range allowedCustomDestinationResponseForwardDestinationElasticsearchTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationResponseForwardDestinationElasticsearchType value. +func (v CustomDestinationResponseForwardDestinationElasticsearchType) Ptr() *CustomDestinationResponseForwardDestinationElasticsearchType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_response_forward_destination_http.go b/api/datadogV2/model_custom_destination_response_forward_destination_http.go new file mode 100644 index 00000000000..bbc0b0882ed --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_forward_destination_http.go @@ -0,0 +1,178 @@ +// 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" +) + +// CustomDestinationResponseForwardDestinationHttp The HTTP destination. +type CustomDestinationResponseForwardDestinationHttp struct { + // Authentication method of the HTTP requests. + Auth CustomDestinationResponseHttpDestinationAuth `json:"auth"` + // The destination for which logs will be forwarded to. + // Must have HTTPS scheme and forwarding back to Datadog is not allowed. + Endpoint string `json:"endpoint"` + // Type of the HTTP destination. + Type CustomDestinationResponseForwardDestinationHttpType `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{} +} + +// NewCustomDestinationResponseForwardDestinationHttp instantiates a new CustomDestinationResponseForwardDestinationHttp 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 NewCustomDestinationResponseForwardDestinationHttp(auth CustomDestinationResponseHttpDestinationAuth, endpoint string, typeVar CustomDestinationResponseForwardDestinationHttpType) *CustomDestinationResponseForwardDestinationHttp { + this := CustomDestinationResponseForwardDestinationHttp{} + this.Auth = auth + this.Endpoint = endpoint + this.Type = typeVar + return &this +} + +// NewCustomDestinationResponseForwardDestinationHttpWithDefaults instantiates a new CustomDestinationResponseForwardDestinationHttp 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 NewCustomDestinationResponseForwardDestinationHttpWithDefaults() *CustomDestinationResponseForwardDestinationHttp { + this := CustomDestinationResponseForwardDestinationHttp{} + var typeVar CustomDestinationResponseForwardDestinationHttpType = CUSTOMDESTINATIONRESPONSEFORWARDDESTINATIONHTTPTYPE_HTTP + this.Type = typeVar + return &this +} + +// GetAuth returns the Auth field value. +func (o *CustomDestinationResponseForwardDestinationHttp) GetAuth() CustomDestinationResponseHttpDestinationAuth { + if o == nil { + var ret CustomDestinationResponseHttpDestinationAuth + return ret + } + return o.Auth +} + +// GetAuthOk returns a tuple with the Auth field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseForwardDestinationHttp) GetAuthOk() (*CustomDestinationResponseHttpDestinationAuth, bool) { + if o == nil { + return nil, false + } + return &o.Auth, true +} + +// SetAuth sets field value. +func (o *CustomDestinationResponseForwardDestinationHttp) SetAuth(v CustomDestinationResponseHttpDestinationAuth) { + o.Auth = v +} + +// GetEndpoint returns the Endpoint field value. +func (o *CustomDestinationResponseForwardDestinationHttp) GetEndpoint() string { + if o == nil { + var ret string + return ret + } + return o.Endpoint +} + +// GetEndpointOk returns a tuple with the Endpoint field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseForwardDestinationHttp) GetEndpointOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Endpoint, true +} + +// SetEndpoint sets field value. +func (o *CustomDestinationResponseForwardDestinationHttp) SetEndpoint(v string) { + o.Endpoint = v +} + +// GetType returns the Type field value. +func (o *CustomDestinationResponseForwardDestinationHttp) GetType() CustomDestinationResponseForwardDestinationHttpType { + if o == nil { + var ret CustomDestinationResponseForwardDestinationHttpType + 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 *CustomDestinationResponseForwardDestinationHttp) GetTypeOk() (*CustomDestinationResponseForwardDestinationHttpType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationResponseForwardDestinationHttp) SetType(v CustomDestinationResponseForwardDestinationHttpType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationResponseForwardDestinationHttp) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["auth"] = o.Auth + toSerialize["endpoint"] = o.Endpoint + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationResponseForwardDestinationHttp) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Auth *CustomDestinationResponseHttpDestinationAuth `json:"auth"` + Endpoint *string `json:"endpoint"` + Type *CustomDestinationResponseForwardDestinationHttpType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Auth == nil { + return fmt.Errorf("required field auth missing") + } + if all.Endpoint == nil { + return fmt.Errorf("required field endpoint 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{"auth", "endpoint", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Auth = *all.Auth + o.Endpoint = *all.Endpoint + 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_custom_destination_response_forward_destination_http_type.go b/api/datadogV2/model_custom_destination_response_forward_destination_http_type.go new file mode 100644 index 00000000000..8a8390c12e3 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_forward_destination_http_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" +) + +// CustomDestinationResponseForwardDestinationHttpType Type of the HTTP destination. +type CustomDestinationResponseForwardDestinationHttpType string + +// List of CustomDestinationResponseForwardDestinationHttpType. +const ( + CUSTOMDESTINATIONRESPONSEFORWARDDESTINATIONHTTPTYPE_HTTP CustomDestinationResponseForwardDestinationHttpType = "http" +) + +var allowedCustomDestinationResponseForwardDestinationHttpTypeEnumValues = []CustomDestinationResponseForwardDestinationHttpType{ + CUSTOMDESTINATIONRESPONSEFORWARDDESTINATIONHTTPTYPE_HTTP, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationResponseForwardDestinationHttpType) GetAllowedValues() []CustomDestinationResponseForwardDestinationHttpType { + return allowedCustomDestinationResponseForwardDestinationHttpTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationResponseForwardDestinationHttpType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationResponseForwardDestinationHttpType(value) + return nil +} + +// NewCustomDestinationResponseForwardDestinationHttpTypeFromValue returns a pointer to a valid CustomDestinationResponseForwardDestinationHttpType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationResponseForwardDestinationHttpTypeFromValue(v string) (*CustomDestinationResponseForwardDestinationHttpType, error) { + ev := CustomDestinationResponseForwardDestinationHttpType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationResponseForwardDestinationHttpType: valid values are %v", v, allowedCustomDestinationResponseForwardDestinationHttpTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationResponseForwardDestinationHttpType) IsValid() bool { + for _, existing := range allowedCustomDestinationResponseForwardDestinationHttpTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationResponseForwardDestinationHttpType value. +func (v CustomDestinationResponseForwardDestinationHttpType) Ptr() *CustomDestinationResponseForwardDestinationHttpType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_response_forward_destination_splunk.go b/api/datadogV2/model_custom_destination_response_forward_destination_splunk.go new file mode 100644 index 00000000000..da72edba632 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_forward_destination_splunk.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" +) + +// CustomDestinationResponseForwardDestinationSplunk The Splunk HTTP Event Collector (HEC) destination. +type CustomDestinationResponseForwardDestinationSplunk struct { + // The destination for which logs will be forwarded to. + // Must have HTTPS scheme and forwarding back to Datadog is not allowed. + Endpoint string `json:"endpoint"` + // Type of the Splunk HTTP Event Collector (HEC) destination. + Type CustomDestinationResponseForwardDestinationSplunkType `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{} +} + +// NewCustomDestinationResponseForwardDestinationSplunk instantiates a new CustomDestinationResponseForwardDestinationSplunk 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 NewCustomDestinationResponseForwardDestinationSplunk(endpoint string, typeVar CustomDestinationResponseForwardDestinationSplunkType) *CustomDestinationResponseForwardDestinationSplunk { + this := CustomDestinationResponseForwardDestinationSplunk{} + this.Endpoint = endpoint + this.Type = typeVar + return &this +} + +// NewCustomDestinationResponseForwardDestinationSplunkWithDefaults instantiates a new CustomDestinationResponseForwardDestinationSplunk 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 NewCustomDestinationResponseForwardDestinationSplunkWithDefaults() *CustomDestinationResponseForwardDestinationSplunk { + this := CustomDestinationResponseForwardDestinationSplunk{} + var typeVar CustomDestinationResponseForwardDestinationSplunkType = CUSTOMDESTINATIONRESPONSEFORWARDDESTINATIONSPLUNKTYPE_SPLUNK_HEC + this.Type = typeVar + return &this +} + +// GetEndpoint returns the Endpoint field value. +func (o *CustomDestinationResponseForwardDestinationSplunk) GetEndpoint() string { + if o == nil { + var ret string + return ret + } + return o.Endpoint +} + +// GetEndpointOk returns a tuple with the Endpoint field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseForwardDestinationSplunk) GetEndpointOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Endpoint, true +} + +// SetEndpoint sets field value. +func (o *CustomDestinationResponseForwardDestinationSplunk) SetEndpoint(v string) { + o.Endpoint = v +} + +// GetType returns the Type field value. +func (o *CustomDestinationResponseForwardDestinationSplunk) GetType() CustomDestinationResponseForwardDestinationSplunkType { + if o == nil { + var ret CustomDestinationResponseForwardDestinationSplunkType + 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 *CustomDestinationResponseForwardDestinationSplunk) GetTypeOk() (*CustomDestinationResponseForwardDestinationSplunkType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationResponseForwardDestinationSplunk) SetType(v CustomDestinationResponseForwardDestinationSplunkType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationResponseForwardDestinationSplunk) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["endpoint"] = o.Endpoint + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationResponseForwardDestinationSplunk) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Endpoint *string `json:"endpoint"` + Type *CustomDestinationResponseForwardDestinationSplunkType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Endpoint == nil { + return fmt.Errorf("required field endpoint 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{"endpoint", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Endpoint = *all.Endpoint + 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_custom_destination_response_forward_destination_splunk_type.go b/api/datadogV2/model_custom_destination_response_forward_destination_splunk_type.go new file mode 100644 index 00000000000..0ef98195568 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_forward_destination_splunk_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" +) + +// CustomDestinationResponseForwardDestinationSplunkType Type of the Splunk HTTP Event Collector (HEC) destination. +type CustomDestinationResponseForwardDestinationSplunkType string + +// List of CustomDestinationResponseForwardDestinationSplunkType. +const ( + CUSTOMDESTINATIONRESPONSEFORWARDDESTINATIONSPLUNKTYPE_SPLUNK_HEC CustomDestinationResponseForwardDestinationSplunkType = "splunk_hec" +) + +var allowedCustomDestinationResponseForwardDestinationSplunkTypeEnumValues = []CustomDestinationResponseForwardDestinationSplunkType{ + CUSTOMDESTINATIONRESPONSEFORWARDDESTINATIONSPLUNKTYPE_SPLUNK_HEC, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationResponseForwardDestinationSplunkType) GetAllowedValues() []CustomDestinationResponseForwardDestinationSplunkType { + return allowedCustomDestinationResponseForwardDestinationSplunkTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationResponseForwardDestinationSplunkType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationResponseForwardDestinationSplunkType(value) + return nil +} + +// NewCustomDestinationResponseForwardDestinationSplunkTypeFromValue returns a pointer to a valid CustomDestinationResponseForwardDestinationSplunkType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationResponseForwardDestinationSplunkTypeFromValue(v string) (*CustomDestinationResponseForwardDestinationSplunkType, error) { + ev := CustomDestinationResponseForwardDestinationSplunkType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationResponseForwardDestinationSplunkType: valid values are %v", v, allowedCustomDestinationResponseForwardDestinationSplunkTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationResponseForwardDestinationSplunkType) IsValid() bool { + for _, existing := range allowedCustomDestinationResponseForwardDestinationSplunkTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationResponseForwardDestinationSplunkType value. +func (v CustomDestinationResponseForwardDestinationSplunkType) Ptr() *CustomDestinationResponseForwardDestinationSplunkType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_response_http_destination_auth.go b/api/datadogV2/model_custom_destination_response_http_destination_auth.go new file mode 100644 index 00000000000..503fd27cb87 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_http_destination_auth.go @@ -0,0 +1,105 @@ +// 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" +) + +// CustomDestinationResponseHttpDestinationAuth - Authentication method of the HTTP requests. +type CustomDestinationResponseHttpDestinationAuth struct { + CustomDestinationResponseHttpDestinationAuthBasic *CustomDestinationResponseHttpDestinationAuthBasic + CustomDestinationResponseHttpDestinationAuthCustomHeader *CustomDestinationResponseHttpDestinationAuthCustomHeader + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// CustomDestinationResponseHttpDestinationAuthBasicAsCustomDestinationResponseHttpDestinationAuth is a convenience function that returns CustomDestinationResponseHttpDestinationAuthBasic wrapped in CustomDestinationResponseHttpDestinationAuth. +func CustomDestinationResponseHttpDestinationAuthBasicAsCustomDestinationResponseHttpDestinationAuth(v *CustomDestinationResponseHttpDestinationAuthBasic) CustomDestinationResponseHttpDestinationAuth { + return CustomDestinationResponseHttpDestinationAuth{CustomDestinationResponseHttpDestinationAuthBasic: v} +} + +// CustomDestinationResponseHttpDestinationAuthCustomHeaderAsCustomDestinationResponseHttpDestinationAuth is a convenience function that returns CustomDestinationResponseHttpDestinationAuthCustomHeader wrapped in CustomDestinationResponseHttpDestinationAuth. +func CustomDestinationResponseHttpDestinationAuthCustomHeaderAsCustomDestinationResponseHttpDestinationAuth(v *CustomDestinationResponseHttpDestinationAuthCustomHeader) CustomDestinationResponseHttpDestinationAuth { + return CustomDestinationResponseHttpDestinationAuth{CustomDestinationResponseHttpDestinationAuthCustomHeader: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *CustomDestinationResponseHttpDestinationAuth) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into CustomDestinationResponseHttpDestinationAuthBasic + err = datadog.Unmarshal(data, &obj.CustomDestinationResponseHttpDestinationAuthBasic) + if err == nil { + if obj.CustomDestinationResponseHttpDestinationAuthBasic != nil && obj.CustomDestinationResponseHttpDestinationAuthBasic.UnparsedObject == nil { + jsonCustomDestinationResponseHttpDestinationAuthBasic, _ := datadog.Marshal(obj.CustomDestinationResponseHttpDestinationAuthBasic) + if string(jsonCustomDestinationResponseHttpDestinationAuthBasic) == "{}" { // empty struct + obj.CustomDestinationResponseHttpDestinationAuthBasic = nil + } else { + match++ + } + } else { + obj.CustomDestinationResponseHttpDestinationAuthBasic = nil + } + } else { + obj.CustomDestinationResponseHttpDestinationAuthBasic = nil + } + + // try to unmarshal data into CustomDestinationResponseHttpDestinationAuthCustomHeader + err = datadog.Unmarshal(data, &obj.CustomDestinationResponseHttpDestinationAuthCustomHeader) + if err == nil { + if obj.CustomDestinationResponseHttpDestinationAuthCustomHeader != nil && obj.CustomDestinationResponseHttpDestinationAuthCustomHeader.UnparsedObject == nil { + jsonCustomDestinationResponseHttpDestinationAuthCustomHeader, _ := datadog.Marshal(obj.CustomDestinationResponseHttpDestinationAuthCustomHeader) + if string(jsonCustomDestinationResponseHttpDestinationAuthCustomHeader) == "{}" { // empty struct + obj.CustomDestinationResponseHttpDestinationAuthCustomHeader = nil + } else { + match++ + } + } else { + obj.CustomDestinationResponseHttpDestinationAuthCustomHeader = nil + } + } else { + obj.CustomDestinationResponseHttpDestinationAuthCustomHeader = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.CustomDestinationResponseHttpDestinationAuthBasic = nil + obj.CustomDestinationResponseHttpDestinationAuthCustomHeader = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj CustomDestinationResponseHttpDestinationAuth) MarshalJSON() ([]byte, error) { + if obj.CustomDestinationResponseHttpDestinationAuthBasic != nil { + return datadog.Marshal(&obj.CustomDestinationResponseHttpDestinationAuthBasic) + } + + if obj.CustomDestinationResponseHttpDestinationAuthCustomHeader != nil { + return datadog.Marshal(&obj.CustomDestinationResponseHttpDestinationAuthCustomHeader) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *CustomDestinationResponseHttpDestinationAuth) GetActualInstance() interface{} { + if obj.CustomDestinationResponseHttpDestinationAuthBasic != nil { + return obj.CustomDestinationResponseHttpDestinationAuthBasic + } + + if obj.CustomDestinationResponseHttpDestinationAuthCustomHeader != nil { + return obj.CustomDestinationResponseHttpDestinationAuthCustomHeader + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_custom_destination_response_http_destination_auth_basic.go b/api/datadogV2/model_custom_destination_response_http_destination_auth_basic.go new file mode 100644 index 00000000000..4c2b0ba5eab --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_http_destination_auth_basic.go @@ -0,0 +1,113 @@ +// 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" +) + +// CustomDestinationResponseHttpDestinationAuthBasic Basic access authentication. +type CustomDestinationResponseHttpDestinationAuthBasic struct { + // Type of the basic access authentication. + Type CustomDestinationResponseHttpDestinationAuthBasicType `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{} +} + +// NewCustomDestinationResponseHttpDestinationAuthBasic instantiates a new CustomDestinationResponseHttpDestinationAuthBasic 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 NewCustomDestinationResponseHttpDestinationAuthBasic(typeVar CustomDestinationResponseHttpDestinationAuthBasicType) *CustomDestinationResponseHttpDestinationAuthBasic { + this := CustomDestinationResponseHttpDestinationAuthBasic{} + this.Type = typeVar + return &this +} + +// NewCustomDestinationResponseHttpDestinationAuthBasicWithDefaults instantiates a new CustomDestinationResponseHttpDestinationAuthBasic 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 NewCustomDestinationResponseHttpDestinationAuthBasicWithDefaults() *CustomDestinationResponseHttpDestinationAuthBasic { + this := CustomDestinationResponseHttpDestinationAuthBasic{} + var typeVar CustomDestinationResponseHttpDestinationAuthBasicType = CUSTOMDESTINATIONRESPONSEHTTPDESTINATIONAUTHBASICTYPE_BASIC + this.Type = typeVar + return &this +} + +// GetType returns the Type field value. +func (o *CustomDestinationResponseHttpDestinationAuthBasic) GetType() CustomDestinationResponseHttpDestinationAuthBasicType { + if o == nil { + var ret CustomDestinationResponseHttpDestinationAuthBasicType + 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 *CustomDestinationResponseHttpDestinationAuthBasic) GetTypeOk() (*CustomDestinationResponseHttpDestinationAuthBasicType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationResponseHttpDestinationAuthBasic) SetType(v CustomDestinationResponseHttpDestinationAuthBasicType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationResponseHttpDestinationAuthBasic) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationResponseHttpDestinationAuthBasic) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Type *CustomDestinationResponseHttpDestinationAuthBasicType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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{"type"}) + } else { + return err + } + + hasInvalidField := false + 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_custom_destination_response_http_destination_auth_basic_type.go b/api/datadogV2/model_custom_destination_response_http_destination_auth_basic_type.go new file mode 100644 index 00000000000..5f5c3840a70 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_http_destination_auth_basic_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" +) + +// CustomDestinationResponseHttpDestinationAuthBasicType Type of the basic access authentication. +type CustomDestinationResponseHttpDestinationAuthBasicType string + +// List of CustomDestinationResponseHttpDestinationAuthBasicType. +const ( + CUSTOMDESTINATIONRESPONSEHTTPDESTINATIONAUTHBASICTYPE_BASIC CustomDestinationResponseHttpDestinationAuthBasicType = "basic" +) + +var allowedCustomDestinationResponseHttpDestinationAuthBasicTypeEnumValues = []CustomDestinationResponseHttpDestinationAuthBasicType{ + CUSTOMDESTINATIONRESPONSEHTTPDESTINATIONAUTHBASICTYPE_BASIC, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationResponseHttpDestinationAuthBasicType) GetAllowedValues() []CustomDestinationResponseHttpDestinationAuthBasicType { + return allowedCustomDestinationResponseHttpDestinationAuthBasicTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationResponseHttpDestinationAuthBasicType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationResponseHttpDestinationAuthBasicType(value) + return nil +} + +// NewCustomDestinationResponseHttpDestinationAuthBasicTypeFromValue returns a pointer to a valid CustomDestinationResponseHttpDestinationAuthBasicType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationResponseHttpDestinationAuthBasicTypeFromValue(v string) (*CustomDestinationResponseHttpDestinationAuthBasicType, error) { + ev := CustomDestinationResponseHttpDestinationAuthBasicType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationResponseHttpDestinationAuthBasicType: valid values are %v", v, allowedCustomDestinationResponseHttpDestinationAuthBasicTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationResponseHttpDestinationAuthBasicType) IsValid() bool { + for _, existing := range allowedCustomDestinationResponseHttpDestinationAuthBasicTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationResponseHttpDestinationAuthBasicType value. +func (v CustomDestinationResponseHttpDestinationAuthBasicType) Ptr() *CustomDestinationResponseHttpDestinationAuthBasicType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_response_http_destination_auth_custom_header.go b/api/datadogV2/model_custom_destination_response_http_destination_auth_custom_header.go new file mode 100644 index 00000000000..10b0c44bb75 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_http_destination_auth_custom_header.go @@ -0,0 +1,145 @@ +// 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" +) + +// CustomDestinationResponseHttpDestinationAuthCustomHeader Custom header access authentication. +type CustomDestinationResponseHttpDestinationAuthCustomHeader struct { + // The header name of the authentication. + HeaderName string `json:"header_name"` + // Type of the custom header access authentication. + Type CustomDestinationResponseHttpDestinationAuthCustomHeaderType `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{} +} + +// NewCustomDestinationResponseHttpDestinationAuthCustomHeader instantiates a new CustomDestinationResponseHttpDestinationAuthCustomHeader 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 NewCustomDestinationResponseHttpDestinationAuthCustomHeader(headerName string, typeVar CustomDestinationResponseHttpDestinationAuthCustomHeaderType) *CustomDestinationResponseHttpDestinationAuthCustomHeader { + this := CustomDestinationResponseHttpDestinationAuthCustomHeader{} + this.HeaderName = headerName + this.Type = typeVar + return &this +} + +// NewCustomDestinationResponseHttpDestinationAuthCustomHeaderWithDefaults instantiates a new CustomDestinationResponseHttpDestinationAuthCustomHeader 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 NewCustomDestinationResponseHttpDestinationAuthCustomHeaderWithDefaults() *CustomDestinationResponseHttpDestinationAuthCustomHeader { + this := CustomDestinationResponseHttpDestinationAuthCustomHeader{} + var typeVar CustomDestinationResponseHttpDestinationAuthCustomHeaderType = CUSTOMDESTINATIONRESPONSEHTTPDESTINATIONAUTHCUSTOMHEADERTYPE_CUSTOM_HEADER + this.Type = typeVar + return &this +} + +// GetHeaderName returns the HeaderName field value. +func (o *CustomDestinationResponseHttpDestinationAuthCustomHeader) GetHeaderName() string { + if o == nil { + var ret string + return ret + } + return o.HeaderName +} + +// GetHeaderNameOk returns a tuple with the HeaderName field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationResponseHttpDestinationAuthCustomHeader) GetHeaderNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.HeaderName, true +} + +// SetHeaderName sets field value. +func (o *CustomDestinationResponseHttpDestinationAuthCustomHeader) SetHeaderName(v string) { + o.HeaderName = v +} + +// GetType returns the Type field value. +func (o *CustomDestinationResponseHttpDestinationAuthCustomHeader) GetType() CustomDestinationResponseHttpDestinationAuthCustomHeaderType { + if o == nil { + var ret CustomDestinationResponseHttpDestinationAuthCustomHeaderType + 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 *CustomDestinationResponseHttpDestinationAuthCustomHeader) GetTypeOk() (*CustomDestinationResponseHttpDestinationAuthCustomHeaderType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationResponseHttpDestinationAuthCustomHeader) SetType(v CustomDestinationResponseHttpDestinationAuthCustomHeaderType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationResponseHttpDestinationAuthCustomHeader) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["header_name"] = o.HeaderName + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationResponseHttpDestinationAuthCustomHeader) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + HeaderName *string `json:"header_name"` + Type *CustomDestinationResponseHttpDestinationAuthCustomHeaderType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.HeaderName == nil { + return fmt.Errorf("required field header_name 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{"header_name", "type"}) + } else { + return err + } + + hasInvalidField := false + o.HeaderName = *all.HeaderName + 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_custom_destination_response_http_destination_auth_custom_header_type.go b/api/datadogV2/model_custom_destination_response_http_destination_auth_custom_header_type.go new file mode 100644 index 00000000000..7c9cf7cb9b6 --- /dev/null +++ b/api/datadogV2/model_custom_destination_response_http_destination_auth_custom_header_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" +) + +// CustomDestinationResponseHttpDestinationAuthCustomHeaderType Type of the custom header access authentication. +type CustomDestinationResponseHttpDestinationAuthCustomHeaderType string + +// List of CustomDestinationResponseHttpDestinationAuthCustomHeaderType. +const ( + CUSTOMDESTINATIONRESPONSEHTTPDESTINATIONAUTHCUSTOMHEADERTYPE_CUSTOM_HEADER CustomDestinationResponseHttpDestinationAuthCustomHeaderType = "custom_header" +) + +var allowedCustomDestinationResponseHttpDestinationAuthCustomHeaderTypeEnumValues = []CustomDestinationResponseHttpDestinationAuthCustomHeaderType{ + CUSTOMDESTINATIONRESPONSEHTTPDESTINATIONAUTHCUSTOMHEADERTYPE_CUSTOM_HEADER, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationResponseHttpDestinationAuthCustomHeaderType) GetAllowedValues() []CustomDestinationResponseHttpDestinationAuthCustomHeaderType { + return allowedCustomDestinationResponseHttpDestinationAuthCustomHeaderTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationResponseHttpDestinationAuthCustomHeaderType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationResponseHttpDestinationAuthCustomHeaderType(value) + return nil +} + +// NewCustomDestinationResponseHttpDestinationAuthCustomHeaderTypeFromValue returns a pointer to a valid CustomDestinationResponseHttpDestinationAuthCustomHeaderType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationResponseHttpDestinationAuthCustomHeaderTypeFromValue(v string) (*CustomDestinationResponseHttpDestinationAuthCustomHeaderType, error) { + ev := CustomDestinationResponseHttpDestinationAuthCustomHeaderType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationResponseHttpDestinationAuthCustomHeaderType: valid values are %v", v, allowedCustomDestinationResponseHttpDestinationAuthCustomHeaderTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationResponseHttpDestinationAuthCustomHeaderType) IsValid() bool { + for _, existing := range allowedCustomDestinationResponseHttpDestinationAuthCustomHeaderTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationResponseHttpDestinationAuthCustomHeaderType value. +func (v CustomDestinationResponseHttpDestinationAuthCustomHeaderType) Ptr() *CustomDestinationResponseHttpDestinationAuthCustomHeaderType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_type.go b/api/datadogV2/model_custom_destination_type.go new file mode 100644 index 00000000000..3edd991f991 --- /dev/null +++ b/api/datadogV2/model_custom_destination_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" +) + +// CustomDestinationType The type of the resource. The value should always be `custom_destination`. +type CustomDestinationType string + +// List of CustomDestinationType. +const ( + CUSTOMDESTINATIONTYPE_custom_destination CustomDestinationType = "custom_destination" +) + +var allowedCustomDestinationTypeEnumValues = []CustomDestinationType{ + CUSTOMDESTINATIONTYPE_custom_destination, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CustomDestinationType) GetAllowedValues() []CustomDestinationType { + return allowedCustomDestinationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CustomDestinationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CustomDestinationType(value) + return nil +} + +// NewCustomDestinationTypeFromValue returns a pointer to a valid CustomDestinationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCustomDestinationTypeFromValue(v string) (*CustomDestinationType, error) { + ev := CustomDestinationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CustomDestinationType: valid values are %v", v, allowedCustomDestinationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CustomDestinationType) IsValid() bool { + for _, existing := range allowedCustomDestinationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CustomDestinationType value. +func (v CustomDestinationType) Ptr() *CustomDestinationType { + return &v +} diff --git a/api/datadogV2/model_custom_destination_update_request.go b/api/datadogV2/model_custom_destination_update_request.go new file mode 100644 index 00000000000..932bd2c7552 --- /dev/null +++ b/api/datadogV2/model_custom_destination_update_request.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" +) + +// CustomDestinationUpdateRequest The custom destination. +type CustomDestinationUpdateRequest struct { + // The definition of a custom destination. + Data *CustomDestinationUpdateRequestDefinition `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{} +} + +// NewCustomDestinationUpdateRequest instantiates a new CustomDestinationUpdateRequest 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 NewCustomDestinationUpdateRequest() *CustomDestinationUpdateRequest { + this := CustomDestinationUpdateRequest{} + return &this +} + +// NewCustomDestinationUpdateRequestWithDefaults instantiates a new CustomDestinationUpdateRequest 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 NewCustomDestinationUpdateRequestWithDefaults() *CustomDestinationUpdateRequest { + this := CustomDestinationUpdateRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CustomDestinationUpdateRequest) GetData() CustomDestinationUpdateRequestDefinition { + if o == nil || o.Data == nil { + var ret CustomDestinationUpdateRequestDefinition + 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 *CustomDestinationUpdateRequest) GetDataOk() (*CustomDestinationUpdateRequestDefinition, 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 *CustomDestinationUpdateRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given CustomDestinationUpdateRequestDefinition and assigns it to the Data field. +func (o *CustomDestinationUpdateRequest) SetData(v CustomDestinationUpdateRequestDefinition) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationUpdateRequest) 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 *CustomDestinationUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CustomDestinationUpdateRequestDefinition `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_custom_destination_update_request_attributes.go b/api/datadogV2/model_custom_destination_update_request_attributes.go new file mode 100644 index 00000000000..a2ff6929832 --- /dev/null +++ b/api/datadogV2/model_custom_destination_update_request_attributes.go @@ -0,0 +1,343 @@ +// 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" +) + +// CustomDestinationUpdateRequestAttributes The attributes associated with the custom destination. +type CustomDestinationUpdateRequestAttributes struct { + // Whether logs matching this custom destination should be forwarded or not. + Enabled *bool `json:"enabled,omitempty"` + // Whether tags from the forwarded logs should be forwarded or not. + ForwardTags *bool `json:"forward_tags,omitempty"` + // List of [keys of tags](https://docs.datadoghq.com/getting_started/tagging/#define-tags) to be restricted from being forwarded. + // An empty list represents no restriction is in place and either all or no tags will be forwarded depending on `forward_tags_restriction_list_type` parameter. + ForwardTagsRestrictionList []string `json:"forward_tags_restriction_list,omitempty"` + // How `forward_tags_restriction_list` parameter should be interpreted. + // If `ALLOW_LIST`, then only tags whose keys on the forwarded logs match the ones on the restriction list + // are forwarded. + // + // `BLOCK_LIST` works the opposite way. It does not forward the tags matching the ones on the list. + ForwardTagsRestrictionListType *CustomDestinationAttributeTagsRestrictionListType `json:"forward_tags_restriction_list_type,omitempty"` + // A custom destination's location to forward logs. + ForwarderDestination *CustomDestinationForwardDestination `json:"forwarder_destination,omitempty"` + // The custom destination name. + Name *string `json:"name,omitempty"` + // The custom destination query and filter. Logs matching this query are forwarded to the destination. + Query *string `json:"query,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{} +} + +// NewCustomDestinationUpdateRequestAttributes instantiates a new CustomDestinationUpdateRequestAttributes 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 NewCustomDestinationUpdateRequestAttributes() *CustomDestinationUpdateRequestAttributes { + this := CustomDestinationUpdateRequestAttributes{} + var enabled bool = true + this.Enabled = &enabled + var forwardTags bool = true + this.ForwardTags = &forwardTags + var forwardTagsRestrictionListType CustomDestinationAttributeTagsRestrictionListType = CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST + this.ForwardTagsRestrictionListType = &forwardTagsRestrictionListType + var query string = "" + this.Query = &query + return &this +} + +// NewCustomDestinationUpdateRequestAttributesWithDefaults instantiates a new CustomDestinationUpdateRequestAttributes 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 NewCustomDestinationUpdateRequestAttributesWithDefaults() *CustomDestinationUpdateRequestAttributes { + this := CustomDestinationUpdateRequestAttributes{} + var enabled bool = true + this.Enabled = &enabled + var forwardTags bool = true + this.ForwardTags = &forwardTags + var forwardTagsRestrictionListType CustomDestinationAttributeTagsRestrictionListType = CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST + this.ForwardTagsRestrictionListType = &forwardTagsRestrictionListType + var query string = "" + this.Query = &query + return &this +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *CustomDestinationUpdateRequestAttributes) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationUpdateRequestAttributes) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *CustomDestinationUpdateRequestAttributes) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *CustomDestinationUpdateRequestAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetForwardTags returns the ForwardTags field value if set, zero value otherwise. +func (o *CustomDestinationUpdateRequestAttributes) GetForwardTags() bool { + if o == nil || o.ForwardTags == nil { + var ret bool + return ret + } + return *o.ForwardTags +} + +// GetForwardTagsOk returns a tuple with the ForwardTags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationUpdateRequestAttributes) GetForwardTagsOk() (*bool, bool) { + if o == nil || o.ForwardTags == nil { + return nil, false + } + return o.ForwardTags, true +} + +// HasForwardTags returns a boolean if a field has been set. +func (o *CustomDestinationUpdateRequestAttributes) HasForwardTags() bool { + return o != nil && o.ForwardTags != nil +} + +// SetForwardTags gets a reference to the given bool and assigns it to the ForwardTags field. +func (o *CustomDestinationUpdateRequestAttributes) SetForwardTags(v bool) { + o.ForwardTags = &v +} + +// GetForwardTagsRestrictionList returns the ForwardTagsRestrictionList field value if set, zero value otherwise. +func (o *CustomDestinationUpdateRequestAttributes) GetForwardTagsRestrictionList() []string { + if o == nil || o.ForwardTagsRestrictionList == nil { + var ret []string + return ret + } + return o.ForwardTagsRestrictionList +} + +// GetForwardTagsRestrictionListOk returns a tuple with the ForwardTagsRestrictionList field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationUpdateRequestAttributes) GetForwardTagsRestrictionListOk() (*[]string, bool) { + if o == nil || o.ForwardTagsRestrictionList == nil { + return nil, false + } + return &o.ForwardTagsRestrictionList, true +} + +// HasForwardTagsRestrictionList returns a boolean if a field has been set. +func (o *CustomDestinationUpdateRequestAttributes) HasForwardTagsRestrictionList() bool { + return o != nil && o.ForwardTagsRestrictionList != nil +} + +// SetForwardTagsRestrictionList gets a reference to the given []string and assigns it to the ForwardTagsRestrictionList field. +func (o *CustomDestinationUpdateRequestAttributes) SetForwardTagsRestrictionList(v []string) { + o.ForwardTagsRestrictionList = v +} + +// GetForwardTagsRestrictionListType returns the ForwardTagsRestrictionListType field value if set, zero value otherwise. +func (o *CustomDestinationUpdateRequestAttributes) GetForwardTagsRestrictionListType() CustomDestinationAttributeTagsRestrictionListType { + if o == nil || o.ForwardTagsRestrictionListType == nil { + var ret CustomDestinationAttributeTagsRestrictionListType + return ret + } + return *o.ForwardTagsRestrictionListType +} + +// GetForwardTagsRestrictionListTypeOk returns a tuple with the ForwardTagsRestrictionListType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationUpdateRequestAttributes) GetForwardTagsRestrictionListTypeOk() (*CustomDestinationAttributeTagsRestrictionListType, bool) { + if o == nil || o.ForwardTagsRestrictionListType == nil { + return nil, false + } + return o.ForwardTagsRestrictionListType, true +} + +// HasForwardTagsRestrictionListType returns a boolean if a field has been set. +func (o *CustomDestinationUpdateRequestAttributes) HasForwardTagsRestrictionListType() bool { + return o != nil && o.ForwardTagsRestrictionListType != nil +} + +// SetForwardTagsRestrictionListType gets a reference to the given CustomDestinationAttributeTagsRestrictionListType and assigns it to the ForwardTagsRestrictionListType field. +func (o *CustomDestinationUpdateRequestAttributes) SetForwardTagsRestrictionListType(v CustomDestinationAttributeTagsRestrictionListType) { + o.ForwardTagsRestrictionListType = &v +} + +// GetForwarderDestination returns the ForwarderDestination field value if set, zero value otherwise. +func (o *CustomDestinationUpdateRequestAttributes) GetForwarderDestination() CustomDestinationForwardDestination { + if o == nil || o.ForwarderDestination == nil { + var ret CustomDestinationForwardDestination + return ret + } + return *o.ForwarderDestination +} + +// GetForwarderDestinationOk returns a tuple with the ForwarderDestination field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationUpdateRequestAttributes) GetForwarderDestinationOk() (*CustomDestinationForwardDestination, bool) { + if o == nil || o.ForwarderDestination == nil { + return nil, false + } + return o.ForwarderDestination, true +} + +// HasForwarderDestination returns a boolean if a field has been set. +func (o *CustomDestinationUpdateRequestAttributes) HasForwarderDestination() bool { + return o != nil && o.ForwarderDestination != nil +} + +// SetForwarderDestination gets a reference to the given CustomDestinationForwardDestination and assigns it to the ForwarderDestination field. +func (o *CustomDestinationUpdateRequestAttributes) SetForwarderDestination(v CustomDestinationForwardDestination) { + o.ForwarderDestination = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CustomDestinationUpdateRequestAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationUpdateRequestAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CustomDestinationUpdateRequestAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CustomDestinationUpdateRequestAttributes) SetName(v string) { + o.Name = &v +} + +// GetQuery returns the Query field value if set, zero value otherwise. +func (o *CustomDestinationUpdateRequestAttributes) GetQuery() string { + if o == nil || o.Query == nil { + var ret string + return ret + } + return *o.Query +} + +// GetQueryOk returns a tuple with the Query field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CustomDestinationUpdateRequestAttributes) GetQueryOk() (*string, bool) { + if o == nil || o.Query == nil { + return nil, false + } + return o.Query, true +} + +// HasQuery returns a boolean if a field has been set. +func (o *CustomDestinationUpdateRequestAttributes) HasQuery() bool { + return o != nil && o.Query != nil +} + +// SetQuery gets a reference to the given string and assigns it to the Query field. +func (o *CustomDestinationUpdateRequestAttributes) SetQuery(v string) { + o.Query = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationUpdateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.ForwardTags != nil { + toSerialize["forward_tags"] = o.ForwardTags + } + if o.ForwardTagsRestrictionList != nil { + toSerialize["forward_tags_restriction_list"] = o.ForwardTagsRestrictionList + } + if o.ForwardTagsRestrictionListType != nil { + toSerialize["forward_tags_restriction_list_type"] = o.ForwardTagsRestrictionListType + } + if o.ForwarderDestination != nil { + toSerialize["forwarder_destination"] = o.ForwarderDestination + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Query != nil { + toSerialize["query"] = o.Query + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationUpdateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Enabled *bool `json:"enabled,omitempty"` + ForwardTags *bool `json:"forward_tags,omitempty"` + ForwardTagsRestrictionList []string `json:"forward_tags_restriction_list,omitempty"` + ForwardTagsRestrictionListType *CustomDestinationAttributeTagsRestrictionListType `json:"forward_tags_restriction_list_type,omitempty"` + ForwarderDestination *CustomDestinationForwardDestination `json:"forwarder_destination,omitempty"` + Name *string `json:"name,omitempty"` + Query *string `json:"query,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{"enabled", "forward_tags", "forward_tags_restriction_list", "forward_tags_restriction_list_type", "forwarder_destination", "name", "query"}) + } else { + return err + } + + hasInvalidField := false + o.Enabled = all.Enabled + o.ForwardTags = all.ForwardTags + o.ForwardTagsRestrictionList = all.ForwardTagsRestrictionList + if all.ForwardTagsRestrictionListType != nil && !all.ForwardTagsRestrictionListType.IsValid() { + hasInvalidField = true + } else { + o.ForwardTagsRestrictionListType = all.ForwardTagsRestrictionListType + } + o.ForwarderDestination = all.ForwarderDestination + o.Name = all.Name + o.Query = all.Query + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_custom_destination_update_request_definition.go b/api/datadogV2/model_custom_destination_update_request_definition.go new file mode 100644 index 00000000000..e562e1cf616 --- /dev/null +++ b/api/datadogV2/model_custom_destination_update_request_definition.go @@ -0,0 +1,183 @@ +// 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" +) + +// CustomDestinationUpdateRequestDefinition The definition of a custom destination. +type CustomDestinationUpdateRequestDefinition struct { + // The attributes associated with the custom destination. + Attributes *CustomDestinationUpdateRequestAttributes `json:"attributes,omitempty"` + // The custom destination ID. + Id string `json:"id"` + // The type of the resource. The value should always be `custom_destination`. + Type CustomDestinationType `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{} +} + +// NewCustomDestinationUpdateRequestDefinition instantiates a new CustomDestinationUpdateRequestDefinition 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 NewCustomDestinationUpdateRequestDefinition(id string, typeVar CustomDestinationType) *CustomDestinationUpdateRequestDefinition { + this := CustomDestinationUpdateRequestDefinition{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewCustomDestinationUpdateRequestDefinitionWithDefaults instantiates a new CustomDestinationUpdateRequestDefinition 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 NewCustomDestinationUpdateRequestDefinitionWithDefaults() *CustomDestinationUpdateRequestDefinition { + this := CustomDestinationUpdateRequestDefinition{} + var typeVar CustomDestinationType = CUSTOMDESTINATIONTYPE_custom_destination + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *CustomDestinationUpdateRequestDefinition) GetAttributes() CustomDestinationUpdateRequestAttributes { + if o == nil || o.Attributes == nil { + var ret CustomDestinationUpdateRequestAttributes + 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 *CustomDestinationUpdateRequestDefinition) GetAttributesOk() (*CustomDestinationUpdateRequestAttributes, 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 *CustomDestinationUpdateRequestDefinition) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given CustomDestinationUpdateRequestAttributes and assigns it to the Attributes field. +func (o *CustomDestinationUpdateRequestDefinition) SetAttributes(v CustomDestinationUpdateRequestAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value. +func (o *CustomDestinationUpdateRequestDefinition) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *CustomDestinationUpdateRequestDefinition) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *CustomDestinationUpdateRequestDefinition) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *CustomDestinationUpdateRequestDefinition) GetType() CustomDestinationType { + if o == nil { + var ret CustomDestinationType + 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 *CustomDestinationUpdateRequestDefinition) GetTypeOk() (*CustomDestinationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CustomDestinationUpdateRequestDefinition) SetType(v CustomDestinationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationUpdateRequestDefinition) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CustomDestinationUpdateRequestDefinition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CustomDestinationUpdateRequestAttributes `json:"attributes,omitempty"` + Id *string `json:"id"` + Type *CustomDestinationType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id 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", "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.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_custom_destinations_response.go b/api/datadogV2/model_custom_destinations_response.go new file mode 100644 index 00000000000..40d2ba5d61f --- /dev/null +++ b/api/datadogV2/model_custom_destinations_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" +) + +// CustomDestinationsResponse The available custom destinations. +type CustomDestinationsResponse struct { + // A list of custom destinations. + Data []CustomDestinationResponseDefinition `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{} +} + +// NewCustomDestinationsResponse instantiates a new CustomDestinationsResponse 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 NewCustomDestinationsResponse() *CustomDestinationsResponse { + this := CustomDestinationsResponse{} + return &this +} + +// NewCustomDestinationsResponseWithDefaults instantiates a new CustomDestinationsResponse 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 NewCustomDestinationsResponseWithDefaults() *CustomDestinationsResponse { + this := CustomDestinationsResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CustomDestinationsResponse) GetData() []CustomDestinationResponseDefinition { + if o == nil || o.Data == nil { + var ret []CustomDestinationResponseDefinition + 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 *CustomDestinationsResponse) GetDataOk() (*[]CustomDestinationResponseDefinition, 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 *CustomDestinationsResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []CustomDestinationResponseDefinition and assigns it to the Data field. +func (o *CustomDestinationsResponse) SetData(v []CustomDestinationResponseDefinition) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CustomDestinationsResponse) 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 *CustomDestinationsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []CustomDestinationResponseDefinition `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/examples/v2/logs-custom-destinations/CreateLogsCustomDestination.go b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination.go new file mode 100644 index 00000000000..c3f7e2ea1fb --- /dev/null +++ b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination.go @@ -0,0 +1,56 @@ +// Create a custom destination 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.CustomDestinationCreateRequest{ + Data: &datadogV2.CustomDestinationCreateRequestDefinition{ + Attributes: datadogV2.CustomDestinationCreateRequestAttributes{ + Enabled: datadog.PtrBool(true), + ForwardTags: datadog.PtrBool(true), + ForwardTagsRestrictionList: []string{ + "datacenter", + "host", + }, + ForwardTagsRestrictionListType: datadogV2.CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST.Ptr(), + ForwarderDestination: datadogV2.CustomDestinationForwardDestination{ + CustomDestinationForwardDestinationHttp: &datadogV2.CustomDestinationForwardDestinationHttp{ + Auth: datadogV2.CustomDestinationHttpDestinationAuth{ + CustomDestinationHttpDestinationAuthBasic: &datadogV2.CustomDestinationHttpDestinationAuthBasic{ + Password: "datadog-custom-destination-password", + Type: datadogV2.CUSTOMDESTINATIONHTTPDESTINATIONAUTHBASICTYPE_BASIC, + Username: "datadog-custom-destination-username", + }}, + Endpoint: "https://example.com", + Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONHTTPTYPE_HTTP, + }}, + Name: "Nginx logs", + Query: datadog.PtrString("source:nginx"), + }, + Type: datadogV2.CUSTOMDESTINATIONTYPE_custom_destination, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsCustomDestinationsApi(apiClient) + resp, r, err := api.CreateLogsCustomDestination(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.CreateLogsCustomDestination`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.CreateLogsCustomDestination`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_1091442807.go b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_1091442807.go new file mode 100644 index 00000000000..bf5d1724134 --- /dev/null +++ b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_1091442807.go @@ -0,0 +1,56 @@ +// Create a Custom Header HTTP custom destination 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.CustomDestinationCreateRequest{ + Data: &datadogV2.CustomDestinationCreateRequestDefinition{ + Attributes: datadogV2.CustomDestinationCreateRequestAttributes{ + Enabled: datadog.PtrBool(false), + ForwardTags: datadog.PtrBool(false), + ForwardTagsRestrictionList: []string{ + "datacenter", + "host", + }, + ForwardTagsRestrictionListType: datadogV2.CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST.Ptr(), + ForwarderDestination: datadogV2.CustomDestinationForwardDestination{ + CustomDestinationForwardDestinationHttp: &datadogV2.CustomDestinationForwardDestinationHttp{ + Auth: datadogV2.CustomDestinationHttpDestinationAuth{ + CustomDestinationHttpDestinationAuthCustomHeader: &datadogV2.CustomDestinationHttpDestinationAuthCustomHeader{ + HeaderValue: "my-secret", + Type: datadogV2.CUSTOMDESTINATIONHTTPDESTINATIONAUTHCUSTOMHEADERTYPE_CUSTOM_HEADER, + HeaderName: "MY-AUTHENTICATION-HEADER", + }}, + Endpoint: "https://example.com", + Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONHTTPTYPE_HTTP, + }}, + Name: "Nginx logs", + Query: datadog.PtrString("source:nginx"), + }, + Type: datadogV2.CUSTOMDESTINATIONTYPE_custom_destination, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsCustomDestinationsApi(apiClient) + resp, r, err := api.CreateLogsCustomDestination(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.CreateLogsCustomDestination`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.CreateLogsCustomDestination`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_1288180912.go b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_1288180912.go new file mode 100644 index 00000000000..9820b63f5c9 --- /dev/null +++ b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_1288180912.go @@ -0,0 +1,51 @@ +// Create a Splunk custom destination 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.CustomDestinationCreateRequest{ + Data: &datadogV2.CustomDestinationCreateRequestDefinition{ + Attributes: datadogV2.CustomDestinationCreateRequestAttributes{ + Enabled: datadog.PtrBool(false), + ForwardTags: datadog.PtrBool(false), + ForwardTagsRestrictionList: []string{ + "datacenter", + "host", + }, + ForwardTagsRestrictionListType: datadogV2.CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST.Ptr(), + ForwarderDestination: datadogV2.CustomDestinationForwardDestination{ + CustomDestinationForwardDestinationSplunk: &datadogV2.CustomDestinationForwardDestinationSplunk{ + AccessToken: "my-access-token", + Endpoint: "https://example.com", + Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONSPLUNKTYPE_SPLUNK_HEC, + }}, + Name: "Nginx logs", + Query: datadog.PtrString("source:nginx"), + }, + Type: datadogV2.CUSTOMDESTINATIONTYPE_custom_destination, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsCustomDestinationsApi(apiClient) + resp, r, err := api.CreateLogsCustomDestination(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.CreateLogsCustomDestination`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.CreateLogsCustomDestination`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_141236188.go b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_141236188.go new file mode 100644 index 00000000000..5e254615ea6 --- /dev/null +++ b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_141236188.go @@ -0,0 +1,56 @@ +// Create an Elasticsearch custom destination 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.CustomDestinationCreateRequest{ + Data: &datadogV2.CustomDestinationCreateRequestDefinition{ + Attributes: datadogV2.CustomDestinationCreateRequestAttributes{ + Enabled: datadog.PtrBool(false), + ForwardTags: datadog.PtrBool(false), + ForwardTagsRestrictionList: []string{ + "datacenter", + "host", + }, + ForwardTagsRestrictionListType: datadogV2.CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST.Ptr(), + ForwarderDestination: datadogV2.CustomDestinationForwardDestination{ + CustomDestinationForwardDestinationElasticsearch: &datadogV2.CustomDestinationForwardDestinationElasticsearch{ + Auth: datadogV2.CustomDestinationElasticsearchDestinationAuth{ + Username: "my-username", + Password: "my-password", + }, + IndexName: "nginx-logs", + IndexRotation: datadog.PtrString("yyyy-MM-dd"), + Endpoint: "https://example.com", + Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONELASTICSEARCHTYPE_ELASTICSEARCH, + }}, + Name: "Nginx logs", + Query: datadog.PtrString("source:nginx"), + }, + Type: datadogV2.CUSTOMDESTINATIONTYPE_custom_destination, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsCustomDestinationsApi(apiClient) + resp, r, err := api.CreateLogsCustomDestination(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.CreateLogsCustomDestination`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.CreateLogsCustomDestination`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_2184123765.go b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_2184123765.go new file mode 100644 index 00000000000..406e6f5a065 --- /dev/null +++ b/examples/v2/logs-custom-destinations/CreateLogsCustomDestination_2184123765.go @@ -0,0 +1,56 @@ +// Create a Basic HTTP custom destination 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.CustomDestinationCreateRequest{ + Data: &datadogV2.CustomDestinationCreateRequestDefinition{ + Attributes: datadogV2.CustomDestinationCreateRequestAttributes{ + Enabled: datadog.PtrBool(false), + ForwardTags: datadog.PtrBool(false), + ForwardTagsRestrictionList: []string{ + "datacenter", + "host", + }, + ForwardTagsRestrictionListType: datadogV2.CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST.Ptr(), + ForwarderDestination: datadogV2.CustomDestinationForwardDestination{ + CustomDestinationForwardDestinationHttp: &datadogV2.CustomDestinationForwardDestinationHttp{ + Auth: datadogV2.CustomDestinationHttpDestinationAuth{ + CustomDestinationHttpDestinationAuthBasic: &datadogV2.CustomDestinationHttpDestinationAuthBasic{ + Password: "datadog-custom-destination-password", + Type: datadogV2.CUSTOMDESTINATIONHTTPDESTINATIONAUTHBASICTYPE_BASIC, + Username: "datadog-custom-destination-username", + }}, + Endpoint: "https://example.com", + Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONHTTPTYPE_HTTP, + }}, + Name: "Nginx logs", + Query: datadog.PtrString("source:nginx"), + }, + Type: datadogV2.CUSTOMDESTINATIONTYPE_custom_destination, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsCustomDestinationsApi(apiClient) + resp, r, err := api.CreateLogsCustomDestination(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.CreateLogsCustomDestination`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.CreateLogsCustomDestination`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-custom-destinations/DeleteLogsCustomDestination.go b/examples/v2/logs-custom-destinations/DeleteLogsCustomDestination.go new file mode 100644 index 00000000000..de817c8a727 --- /dev/null +++ b/examples/v2/logs-custom-destinations/DeleteLogsCustomDestination.go @@ -0,0 +1,28 @@ +// Delete a custom destination returns "OK" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "custom_destination" in the system + CustomDestinationDataID := os.Getenv("CUSTOM_DESTINATION_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsCustomDestinationsApi(apiClient) + r, err := api.DeleteLogsCustomDestination(ctx, CustomDestinationDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.DeleteLogsCustomDestination`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/logs-custom-destinations/GetLogsCustomDestination.go b/examples/v2/logs-custom-destinations/GetLogsCustomDestination.go new file mode 100644 index 00000000000..37e3e59df59 --- /dev/null +++ b/examples/v2/logs-custom-destinations/GetLogsCustomDestination.go @@ -0,0 +1,32 @@ +// Get a custom destination 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() { + // there is a valid "custom_destination" in the system + CustomDestinationDataID := os.Getenv("CUSTOM_DESTINATION_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsCustomDestinationsApi(apiClient) + resp, r, err := api.GetLogsCustomDestination(ctx, CustomDestinationDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.GetLogsCustomDestination`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.GetLogsCustomDestination`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-custom-destinations/ListLogsCustomDestinations.go b/examples/v2/logs-custom-destinations/ListLogsCustomDestinations.go new file mode 100644 index 00000000000..7102ab2a73c --- /dev/null +++ b/examples/v2/logs-custom-destinations/ListLogsCustomDestinations.go @@ -0,0 +1,29 @@ +// Get all custom destinations 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.NewLogsCustomDestinationsApi(apiClient) + resp, r, err := api.ListLogsCustomDestinations(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.ListLogsCustomDestinations`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.ListLogsCustomDestinations`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-custom-destinations/UpdateLogsCustomDestination.go b/examples/v2/logs-custom-destinations/UpdateLogsCustomDestination.go new file mode 100644 index 00000000000..245c4e4ba81 --- /dev/null +++ b/examples/v2/logs-custom-destinations/UpdateLogsCustomDestination.go @@ -0,0 +1,41 @@ +// Update a custom destination 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() { + // there is a valid "custom_destination" in the system + CustomDestinationDataID := os.Getenv("CUSTOM_DESTINATION_DATA_ID") + + body := datadogV2.CustomDestinationUpdateRequest{ + Data: &datadogV2.CustomDestinationUpdateRequestDefinition{ + Attributes: &datadogV2.CustomDestinationUpdateRequestAttributes{ + Name: datadog.PtrString("Nginx logs (Updated)"), + }, + Type: datadogV2.CUSTOMDESTINATIONTYPE_custom_destination, + Id: CustomDestinationDataID, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsCustomDestinationsApi(apiClient) + resp, r, err := api.UpdateLogsCustomDestination(ctx, CustomDestinationDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.UpdateLogsCustomDestination`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.UpdateLogsCustomDestination`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 146df41cbd9..5bfcfc0a999 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -71,6 +71,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "IPAllowlistApi": reflect.ValueOf(datadogV2.NewIPAllowlistApi), "LogsApi": reflect.ValueOf(datadogV2.NewLogsApi), "LogsArchivesApi": reflect.ValueOf(datadogV2.NewLogsArchivesApi), + "LogsCustomDestinationsApi": reflect.ValueOf(datadogV2.NewLogsCustomDestinationsApi), "LogsMetricsApi": reflect.ValueOf(datadogV2.NewLogsMetricsApi), "MetricsApi": reflect.ValueOf(datadogV2.NewMetricsApi), "MonitorsApi": reflect.ValueOf(datadogV2.NewMonitorsApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Basic_HTTP_custom_destination_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Basic_HTTP_custom_destination_returns_OK_response.freeze new file mode 100644 index 00000000000..14b4198db7a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Basic_HTTP_custom_destination_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:07.582Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Basic_HTTP_custom_destination_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Basic_HTTP_custom_destination_returns_OK_response.yaml new file mode 100644 index 00000000000..e268b8c40ea --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Basic_HTTP_custom_destination_returns_OK_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["datacenter","host"],"forward_tags_restriction_list_type":"ALLOW_LIST","forwarder_destination":{"auth":{"password":"datadog-custom-destination-password","type":"basic","username":"datadog-custom-destination-username"},"endpoint":"https://example.com","type":"http"},"name":"Nginx logs","query":"source:nginx"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":{"id":"9608c7d6-8ea4-4487-88da-ab7620dd000c","attributes":{"name":"Nginx + logs","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"type":"basic"},"type":"http"},"forward_tags_restriction_list_type":"ALLOW_LIST","forward_tags_restriction_list":["datacenter","host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/9608c7d6-8ea4-4487-88da-ab7620dd000c + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Custom_Header_HTTP_custom_destination_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Custom_Header_HTTP_custom_destination_returns_OK_response.freeze new file mode 100644 index 00000000000..884ab65f4e5 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Custom_Header_HTTP_custom_destination_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:08.664Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Custom_Header_HTTP_custom_destination_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Custom_Header_HTTP_custom_destination_returns_OK_response.yaml new file mode 100644 index 00000000000..3c79d48301a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Custom_Header_HTTP_custom_destination_returns_OK_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["datacenter","host"],"forward_tags_restriction_list_type":"ALLOW_LIST","forwarder_destination":{"auth":{"header_name":"MY-AUTHENTICATION-HEADER","header_value":"my-secret","type":"custom_header"},"endpoint":"https://example.com","type":"http"},"name":"Nginx logs","query":"source:nginx"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":{"id":"b522ed5a-3fab-47f4-a828-d34bd5632656","attributes":{"name":"Nginx + logs","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"header_name":"MY-AUTHENTICATION-HEADER","type":"custom_header"},"type":"http"},"forward_tags_restriction_list_type":"ALLOW_LIST","forward_tags_restriction_list":["datacenter","host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/b522ed5a-3fab-47f4-a828-d34bd5632656 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Splunk_custom_destination_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Splunk_custom_destination_returns_OK_response.freeze new file mode 100644 index 00000000000..79246244e65 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Splunk_custom_destination_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:09.499Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Splunk_custom_destination_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Splunk_custom_destination_returns_OK_response.yaml new file mode 100644 index 00000000000..95e431dbb4f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_Splunk_custom_destination_returns_OK_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["datacenter","host"],"forward_tags_restriction_list_type":"ALLOW_LIST","forwarder_destination":{"access_token":"my-access-token","endpoint":"https://example.com","type":"splunk_hec"},"name":"Nginx logs","query":"source:nginx"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":{"id":"dcdf0ca2-b06a-4b75-8b07-0ba1987bd2fe","attributes":{"name":"Nginx + logs","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","type":"splunk_hec"},"forward_tags_restriction_list_type":"ALLOW_LIST","forward_tags_restriction_list":["datacenter","host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/dcdf0ca2-b06a-4b75-8b07-0ba1987bd2fe + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_custom_destination_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_custom_destination_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..8f6df3cca07 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_custom_destination_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:10.485Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_custom_destination_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_custom_destination_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..1d458637a20 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_a_custom_destination_returns_Bad_Request_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"name":"Nginx logs"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"errors":["The parameter ''forwarder_destination'' is required"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_an_Elasticsearch_custom_destination_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_an_Elasticsearch_custom_destination_returns_OK_response.freeze new file mode 100644 index 00000000000..9f38ea9f8ef --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_an_Elasticsearch_custom_destination_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:10.813Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_an_Elasticsearch_custom_destination_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_an_Elasticsearch_custom_destination_returns_OK_response.yaml new file mode 100644 index 00000000000..ab59c9d44ff --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Create_an_Elasticsearch_custom_destination_returns_OK_response.yaml @@ -0,0 +1,42 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["datacenter","host"],"forward_tags_restriction_list_type":"ALLOW_LIST","forwarder_destination":{"auth":{"password":"my-password","username":"my-username"},"endpoint":"https://example.com","index_name":"nginx-logs","index_rotation":"yyyy-MM-dd","type":"elasticsearch"},"name":"Nginx logs","query":"source:nginx"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":{"id":"922dba96-00c4-49fb-969c-aabf48a3d5c3","attributes":{"name":"Nginx + logs","query":"source:nginx","enabled":false,"forwarder_destination":{"index_name":"nginx-logs","index_rotation":"yyyy-MM-dd","endpoint":"https://example.com","auth":{},"type":"elasticsearch"},"forward_tags_restriction_list_type":"ALLOW_LIST","forward_tags_restriction_list":["datacenter","host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/922dba96-00c4-49fb-969c-aabf48a3d5c3 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..a66cf29054a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:11.769Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..b3e451f0986 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_Not_Found_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/does-not-exist + response: + body: '{"errors":["NotFound"]} + + ' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_OK_response.freeze new file mode 100644 index 00000000000..118be029f84 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:12.109Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_OK_response.yaml new file mode 100644 index 00000000000..ce173efc09d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Delete_a_custom_destination_returns_OK_response.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["host"],"forward_tags_restriction_list_type":"BLOCK_LIST","forwarder_destination":{"auth":{"password":"my-password","type":"basic","username":"my-username"},"endpoint":"https://example.com","type":"http"},"name":"Test-Delete_a_custom_destination_returns_OK_response-1710235212","query":"source:nginx"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":{"id":"596bb741-53be-49c6-939d-b5d4d9307689","attributes":{"name":"Test-Delete_a_custom_destination_returns_OK_response-1710235212","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"type":"basic"},"type":"http"},"forward_tags_restriction_list_type":"BLOCK_LIST","forward_tags_restriction_list":["host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/596bb741-53be-49c6-939d-b5d4d9307689 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/596bb741-53be-49c6-939d-b5d4d9307689 + response: + body: '{"errors":["NotFound"]} + + ' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..f247a8b5e0f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:13.398Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..7c252103696 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_Not_Found_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/does-not-exist + response: + body: '{"errors":["NotFound"]} + + ' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_OK_response.freeze new file mode 100644 index 00000000000..1d60a375138 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:13.821Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_OK_response.yaml new file mode 100644 index 00000000000..bb8aa68519c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_a_custom_destination_returns_OK_response.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["host"],"forward_tags_restriction_list_type":"BLOCK_LIST","forwarder_destination":{"auth":{"password":"my-password","type":"basic","username":"my-username"},"endpoint":"https://example.com","type":"http"},"name":"Test-Get_a_custom_destination_returns_OK_response-1710235213","query":"source:nginx"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":{"id":"13e3f7e6-307e-4a91-a269-e016da18efc5","attributes":{"name":"Test-Get_a_custom_destination_returns_OK_response-1710235213","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"type":"basic"},"type":"http"},"forward_tags_restriction_list_type":"BLOCK_LIST","forward_tags_restriction_list":["host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/13e3f7e6-307e-4a91-a269-e016da18efc5 + response: + body: '{"data":{"id":"13e3f7e6-307e-4a91-a269-e016da18efc5","attributes":{"name":"Test-Get_a_custom_destination_returns_OK_response-1710235213","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"type":"basic"},"type":"http"},"forward_tags_restriction_list_type":"BLOCK_LIST","forward_tags_restriction_list":["host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/13e3f7e6-307e-4a91-a269-e016da18efc5 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_all_custom_destinations_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_all_custom_destinations_returns_OK_response.freeze new file mode 100644 index 00000000000..65faf1870bc --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_all_custom_destinations_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:15.085Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_all_custom_destinations_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_all_custom_destinations_returns_OK_response.yaml new file mode 100644 index 00000000000..3c0d08fcee1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Get_all_custom_destinations_returns_OK_response.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["host"],"forward_tags_restriction_list_type":"BLOCK_LIST","forwarder_destination":{"auth":{"password":"my-password","type":"basic","username":"my-username"},"endpoint":"https://example.com","type":"http"},"name":"Test-Get_all_custom_destinations_returns_OK_response-1710235215","query":"source:nginx"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":{"id":"85883e0f-b010-4b8b-816d-a629600a4d0a","attributes":{"name":"Test-Get_all_custom_destinations_returns_OK_response-1710235215","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"type":"basic"},"type":"http"},"forward_tags_restriction_list_type":"BLOCK_LIST","forward_tags_restriction_list":["host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":[{"id":"85883e0f-b010-4b8b-816d-a629600a4d0a","attributes":{"name":"Test-Get_all_custom_destinations_returns_OK_response-1710235215","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"type":"basic"},"type":"http"},"forward_tags_restriction_list_type":"BLOCK_LIST","forward_tags_restriction_list":["host"],"forward_tags":false},"type":"custom_destination"}]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/85883e0f-b010-4b8b-816d-a629600a4d0a + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..131ba9254c8 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:16.332Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..6d7c213ac06 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Bad_Request_response.yaml @@ -0,0 +1,63 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["host"],"forward_tags_restriction_list_type":"BLOCK_LIST","forwarder_destination":{"auth":{"password":"my-password","type":"basic","username":"my-username"},"endpoint":"https://example.com","type":"http"},"name":"Test-Update_a_custom_destination_returns_Bad_Request_response-1710235216","query":"source:nginx"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":{"id":"0f1b60fc-4671-4bd5-834b-bc86c8a5065b","attributes":{"name":"Test-Update_a_custom_destination_returns_Bad_Request_response-1710235216","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"type":"basic"},"type":"http"},"forward_tags_restriction_list_type":"BLOCK_LIST","forward_tags_restriction_list":["host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"data":{"attributes":{"forward_tags_restriction_list_type":"this_list_type_does_not_exist"},"id":"0f1b60fc-4671-4bd5-834b-bc86c8a5065b","type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/0f1b60fc-4671-4bd5-834b-bc86c8a5065b + response: + body: '{"errors":["Internal error"]} + + ' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/0f1b60fc-4671-4bd5-834b-bc86c8a5065b + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..9b964d6ef49 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:17.628Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..8988c9ed576 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_Not_Found_response.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["datacenter","host"],"forward_tags_restriction_list_type":"ALLOW_LIST","forwarder_destination":{"auth":{"password":"datadog-custom-destination-password","type":"basic","username":"datadog-custom-destination-username"},"endpoint":"https://example.com","type":"http"},"name":"Nginx logs","query":"source:nginx"},"id":"id-from-non-existing-custom-destination","type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PATCH + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/id-from-non-existing-custom-destination + response: + body: '{"errors":["NotFound"]} + + ' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_OK_response.freeze new file mode 100644 index 00000000000..f79f9f1e90d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-12T09:20:18.077Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_OK_response.yaml new file mode 100644 index 00000000000..d7be3cd67b0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Custom_Destinations/Scenario_Update_a_custom_destination_returns_OK_response.yaml @@ -0,0 +1,64 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"enabled":false,"forward_tags":false,"forward_tags_restriction_list":["host"],"forward_tags_restriction_list_type":"BLOCK_LIST","forwarder_destination":{"auth":{"password":"my-password","type":"basic","username":"my-username"},"endpoint":"https://example.com","type":"http"},"name":"Test-Update_a_custom_destination_returns_OK_response-1710235218","query":"source:nginx"},"type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations + response: + body: '{"data":{"id":"22ce0782-a48f-4340-98f5-fd3671b66e19","attributes":{"name":"Test-Update_a_custom_destination_returns_OK_response-1710235218","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"type":"basic"},"type":"http"},"forward_tags_restriction_list_type":"BLOCK_LIST","forward_tags_restriction_list":["host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"data":{"attributes":{"name":"Nginx logs (Updated)"},"id":"22ce0782-a48f-4340-98f5-fd3671b66e19","type":"custom_destination"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/22ce0782-a48f-4340-98f5-fd3671b66e19 + response: + body: '{"data":{"id":"22ce0782-a48f-4340-98f5-fd3671b66e19","attributes":{"name":"Nginx + logs (Updated)","query":"source:nginx","enabled":false,"forwarder_destination":{"endpoint":"https://example.com","auth":{"type":"basic"},"type":"http"},"forward_tags_restriction_list_type":"BLOCK_LIST","forward_tags_restriction_list":["host"],"forward_tags":false},"type":"custom_destination"}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/custom-destinations/22ce0782-a48f-4340-98f5-fd3671b66e19 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 73de3c05e39..04b3989db8b 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -284,6 +284,18 @@ "tag": "IP Allowlist", "operationId": "UpdateIPAllowlist" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"query\": \"source:nginx\",\n \"enabled\": false,\n \"forwarder_destination\": {\n \"type\": \"http\",\n \"endpoint\": \"https://example.com\",\n \"auth\": {\n \"type\": \"basic\",\n \"username\": \"my-username\",\n \"password\": \"my-password\"\n }\n },\n \"forward_tags_restriction_list_type\": \"BLOCK_LIST\",\n \"forward_tags_restriction_list\": [\"host\"],\n \"forward_tags\": false\n },\n \"type\": \"custom_destination\"\n }\n}" + } + ], + "step": "there is a valid \"custom_destination\" in the system", + "key": "custom_destination", + "tag": "Logs Custom Destinations", + "operationId": "CreateLogsCustomDestination" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/logs_custom_destinations.feature b/tests/scenarios/features/v2/logs_custom_destinations.feature new file mode 100644 index 00000000000..812898736cf --- /dev/null +++ b/tests/scenarios/features/v2/logs_custom_destinations.feature @@ -0,0 +1,248 @@ +@endpoint(logs-custom-destinations) @endpoint(logs-custom-destinations-v2) +Feature: Logs Custom Destinations + Custom Destinations forward all the logs ingested to an external + destination. See the [Custom Destinations + Page](https://app.datadoghq.com/logs/pipelines/log-forwarding/custom- + destinations) for a list of the custom destinations currently configured + in web UI. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "LogsCustomDestinations" API + + @team:DataDog/logs-backend + Scenario: Create a Basic HTTP custom destination returns "OK" response + Given new "CreateLogsCustomDestination" request + And body with value {"data": {"attributes": {"enabled": false, "forward_tags": false, "forward_tags_restriction_list": ["datacenter", "host"], "forward_tags_restriction_list_type": "ALLOW_LIST", "forwarder_destination": {"auth": {"password": "datadog-custom-destination-password", "type": "basic", "username": "datadog-custom-destination-username"}, "endpoint": "https://example.com", "type": "http"}, "name": "Nginx logs", "query": "source:nginx"}, "type": "custom_destination"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "custom_destination" + And the response "data" has field "id" + And the response "data.attributes.name" is equal to "Nginx logs" + And the response "data.attributes.query" is equal to "source:nginx" + And the response "data.attributes.forwarder_destination.type" is equal to "http" + And the response "data.attributes.forwarder_destination.endpoint" is equal to "https://example.com" + And the response "data.attributes.forwarder_destination.auth.type" is equal to "basic" + And the response "data.attributes.forwarder_destination.auth" does not have field "username" + And the response "data.attributes.forwarder_destination.auth" does not have field "password" + And the response "data.attributes.enabled" is false + And the response "data.attributes.forward_tags" is false + And the response "data.attributes.forward_tags_restriction_list" has length 2 + And the response "data.attributes.forward_tags_restriction_list" array contains value "datacenter" + And the response "data.attributes.forward_tags_restriction_list" array contains value "host" + And the response "data.attributes.forward_tags_restriction_list_type" is equal to "ALLOW_LIST" + + @team:DataDog/logs-backend + Scenario: Create a Custom Header HTTP custom destination returns "OK" response + Given new "CreateLogsCustomDestination" request + And body with value {"data": {"attributes": {"enabled": false, "forward_tags": false, "forward_tags_restriction_list": ["datacenter", "host"], "forward_tags_restriction_list_type": "ALLOW_LIST", "forwarder_destination": {"auth": {"header_value": "my-secret", "type": "custom_header", "header_name": "MY-AUTHENTICATION-HEADER"}, "endpoint": "https://example.com", "type": "http"}, "name": "Nginx logs", "query": "source:nginx"}, "type": "custom_destination"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "custom_destination" + And the response "data" has field "id" + And the response "data.attributes.name" is equal to "Nginx logs" + And the response "data.attributes.query" is equal to "source:nginx" + And the response "data.attributes.forwarder_destination.type" is equal to "http" + And the response "data.attributes.forwarder_destination.endpoint" is equal to "https://example.com" + And the response "data.attributes.forwarder_destination.auth.type" is equal to "custom_header" + And the response "data.attributes.forwarder_destination.auth.header_name" is equal to "MY-AUTHENTICATION-HEADER" + And the response "data.attributes.forwarder_destination.auth" does not have field "header_value" + And the response "data.attributes.enabled" is false + And the response "data.attributes.forward_tags" is false + And the response "data.attributes.forward_tags_restriction_list" has length 2 + And the response "data.attributes.forward_tags_restriction_list" array contains value "datacenter" + And the response "data.attributes.forward_tags_restriction_list" array contains value "host" + And the response "data.attributes.forward_tags_restriction_list_type" is equal to "ALLOW_LIST" + + @team:DataDog/logs-backend + Scenario: Create a Splunk custom destination returns "OK" response + Given new "CreateLogsCustomDestination" request + And body with value {"data": {"attributes": {"enabled": false, "forward_tags": false, "forward_tags_restriction_list": ["datacenter", "host"], "forward_tags_restriction_list_type": "ALLOW_LIST", "forwarder_destination": {"access_token": "my-access-token", "endpoint": "https://example.com", "type": "splunk_hec"}, "name": "Nginx logs", "query": "source:nginx"}, "type": "custom_destination"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "custom_destination" + And the response "data" has field "id" + And the response "data.attributes.name" is equal to "Nginx logs" + And the response "data.attributes.query" is equal to "source:nginx" + And the response "data.attributes.forwarder_destination.type" is equal to "splunk_hec" + And the response "data.attributes.forwarder_destination.endpoint" is equal to "https://example.com" + And the response "data.attributes.forwarder_destination" does not have field "access_token" + And the response "data.attributes.enabled" is false + And the response "data.attributes.forward_tags" is false + And the response "data.attributes.forward_tags_restriction_list" has length 2 + And the response "data.attributes.forward_tags_restriction_list" array contains value "datacenter" + And the response "data.attributes.forward_tags_restriction_list" array contains value "host" + And the response "data.attributes.forward_tags_restriction_list_type" is equal to "ALLOW_LIST" + + @skip-java @skip-python @skip-typescript @team:DataDog/logs-backend + Scenario: Create a custom destination returns "Bad Request" response + Given new "CreateLogsCustomDestination" request + And body with value {"data": {"attributes": {"name": "Nginx logs"}, "type": "custom_destination"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/logs-backend + Scenario: Create a custom destination returns "Conflict" response + Given new "CreateLogsCustomDestination" request + And body with value {"data": {"attributes": {"enabled": true, "forward_tags": true, "forward_tags_restriction_list": ["datacenter", "host"], "forward_tags_restriction_list_type": "ALLOW_LIST", "forwarder_destination": {"auth": {"password": "datadog-custom-destination-password", "type": "basic", "username": "datadog-custom-destination-username"}, "endpoint": "https://example.com", "type": "http"}, "name": "Nginx logs", "query": "source:nginx"}, "type": "custom_destination"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/logs-backend + Scenario: Create a custom destination returns "OK" response + Given new "CreateLogsCustomDestination" request + And body with value {"data": {"attributes": {"enabled": true, "forward_tags": true, "forward_tags_restriction_list": ["datacenter", "host"], "forward_tags_restriction_list_type": "ALLOW_LIST", "forwarder_destination": {"auth": {"password": "datadog-custom-destination-password", "type": "basic", "username": "datadog-custom-destination-username"}, "endpoint": "https://example.com", "type": "http"}, "name": "Nginx logs", "query": "source:nginx"}, "type": "custom_destination"}} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/logs-backend + Scenario: Create an Elasticsearch custom destination returns "OK" response + Given new "CreateLogsCustomDestination" request + And body with value {"data": {"attributes": {"enabled": false, "forward_tags": false, "forward_tags_restriction_list": ["datacenter", "host"], "forward_tags_restriction_list_type": "ALLOW_LIST", "forwarder_destination": {"auth": {"username": "my-username", "password": "my-password"}, "index_name": "nginx-logs", "index_rotation": "yyyy-MM-dd", "endpoint": "https://example.com", "type": "elasticsearch"}, "name": "Nginx logs", "query": "source:nginx"}, "type": "custom_destination"}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "custom_destination" + And the response "data" has field "id" + And the response "data.attributes.name" is equal to "Nginx logs" + And the response "data.attributes.query" is equal to "source:nginx" + And the response "data.attributes.forwarder_destination.type" is equal to "elasticsearch" + And the response "data.attributes.forwarder_destination.endpoint" is equal to "https://example.com" + And the response "data.attributes.forwarder_destination.index_name" is equal to "nginx-logs" + And the response "data.attributes.forwarder_destination.index_rotation" is equal to "yyyy-MM-dd" + And the response "data.attributes.forwarder_destination.auth" does not have field "username" + And the response "data.attributes.forwarder_destination.auth" does not have field "password" + And the response "data.attributes.enabled" is false + And the response "data.attributes.forward_tags" is false + And the response "data.attributes.forward_tags_restriction_list" has length 2 + And the response "data.attributes.forward_tags_restriction_list" array contains value "datacenter" + And the response "data.attributes.forward_tags_restriction_list" array contains value "host" + And the response "data.attributes.forward_tags_restriction_list_type" is equal to "ALLOW_LIST" + + @generated @skip @team:DataDog/logs-backend + Scenario: Delete a custom destination returns "Bad Request" response + Given new "DeleteLogsCustomDestination" request + And request contains "custom_destination_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/logs-backend + Scenario: Delete a custom destination returns "Not Found" response + Given new "DeleteLogsCustomDestination" request + And request contains "custom_destination_id" parameter with value "does-not-exist" + When the request is sent + Then the response status is 404 Not found + + @team:DataDog/logs-backend + Scenario: Delete a custom destination returns "OK" response + Given new "DeleteLogsCustomDestination" request + And there is a valid "custom_destination" in the system + And request contains "custom_destination_id" parameter from "custom_destination.data.id" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:DataDog/logs-backend + Scenario: Get a custom destination returns "Bad Request" response + Given new "GetLogsCustomDestination" request + And request contains "custom_destination_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/logs-backend + Scenario: Get a custom destination returns "Not Found" response + Given new "GetLogsCustomDestination" request + And request contains "custom_destination_id" parameter with value "does-not-exist" + When the request is sent + Then the response status is 404 Not found + + @team:DataDog/logs-backend + Scenario: Get a custom destination returns "OK" response + Given new "GetLogsCustomDestination" request + And there is a valid "custom_destination" in the system + And request contains "custom_destination_id" parameter from "custom_destination.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "custom_destination" + And the response "data.id" is equal to "{{ custom_destination.data.id }}" + And the response "data.attributes.name" is equal to "{{ custom_destination.data.attributes.name }}" + And the response "data.attributes.query" is equal to "{{ custom_destination.data.attributes.query }}" + And the response "data.attributes.forwarder_destination.type" is equal to "{{ custom_destination.data.attributes.forwarder_destination.type }}" + And the response "data.attributes.forwarder_destination.endpoint" is equal to "{{ custom_destination.data.attributes.forwarder_destination.endpoint }}" + And the response "data.attributes.forwarder_destination.auth.type" is equal to "{{ custom_destination.data.attributes.forwarder_destination.auth.type }}" + And the response "data.attributes.forwarder_destination.auth" does not have field "username" + And the response "data.attributes.forwarder_destination.auth" does not have field "password" + And the response "data.attributes.enabled" is false + And the response "data.attributes.forward_tags" is false + And the response "data.attributes.forward_tags_restriction_list" has length 1 + And the response "data.attributes.forward_tags_restriction_list" array contains value "host" + And the response "data.attributes.forward_tags_restriction_list_type" is equal to "{{ custom_destination.data.attributes.forward_tags_restriction_list_type }}" + + @team:DataDog/logs-backend + Scenario: Get all custom destinations returns "OK" response + Given new "ListLogsCustomDestinations" request + And there is a valid "custom_destination" in the system + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "data[0].type" is equal to "custom_destination" + And the response "data[0].id" is equal to "{{ custom_destination.data.id }}" + And the response "data[0].attributes.name" is equal to "{{ custom_destination.data.attributes.name }}" + And the response "data[0].attributes.query" is equal to "{{ custom_destination.data.attributes.query }}" + And the response "data[0].attributes.forwarder_destination.type" is equal to "{{ custom_destination.data.attributes.forwarder_destination.type }}" + And the response "data[0].attributes.forwarder_destination.endpoint" is equal to "{{ custom_destination.data.attributes.forwarder_destination.endpoint }}" + And the response "data[0].attributes.forwarder_destination.auth.type" is equal to "{{ custom_destination.data.attributes.forwarder_destination.auth.type }}" + And the response "data[0].attributes.forwarder_destination.auth" does not have field "username" + And the response "data[0].attributes.forwarder_destination.auth" does not have field "password" + And the response "data[0].attributes.enabled" is false + And the response "data[0].attributes.forward_tags" is false + And the response "data[0].attributes.forward_tags_restriction_list" has length 1 + And the response "data[0].attributes.forward_tags_restriction_list" array contains value "host" + And the response "data[0].attributes.forward_tags_restriction_list_type" is equal to "{{ custom_destination.data.attributes.forward_tags_restriction_list_type }}" + + @team:DataDog/logs-backend + Scenario: Update a custom destination returns "Bad Request" response + Given new "UpdateLogsCustomDestination" request + And there is a valid "custom_destination" in the system + And request contains "custom_destination_id" parameter from "custom_destination.data.id" + And body with value {"data": {"attributes": {"forward_tags_restriction_list_type": "this_list_type_does_not_exist"}, "type": "custom_destination", "id": "{{ custom_destination.data.id }}" }} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/logs-backend + Scenario: Update a custom destination returns "Conflict" response + Given new "UpdateLogsCustomDestination" request + And request contains "custom_destination_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"enabled": false, "forward_tags": false, "forward_tags_restriction_list": ["datacenter", "host"], "forward_tags_restriction_list_type": "ALLOW_LIST", "forwarder_destination": {"auth": {"password": "datadog-custom-destination-password", "type": "basic", "username": "datadog-custom-destination-username"}, "endpoint": "https://example.com", "type": "http"}, "name": "Nginx logs", "query": "source:nginx"}, "type": "custom_destination"}} + When the request is sent + Then the response status is 409 Conflict + + @team:DataDog/logs-backend + Scenario: Update a custom destination returns "Not Found" response + Given new "UpdateLogsCustomDestination" request + And request contains "custom_destination_id" parameter with value "id-from-non-existing-custom-destination" + And body with value {"data": {"attributes": {"enabled": false, "forward_tags": false, "forward_tags_restriction_list": ["datacenter", "host"], "forward_tags_restriction_list_type": "ALLOW_LIST", "forwarder_destination": {"auth": {"type": "basic", "username": "datadog-custom-destination-username", "password": "datadog-custom-destination-password"}, "endpoint": "https://example.com", "type": "http"}, "name": "Nginx logs", "query": "source:nginx"}, "type": "custom_destination", "id": "id-from-non-existing-custom-destination" }} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/logs-backend + Scenario: Update a custom destination returns "OK" response + Given new "UpdateLogsCustomDestination" request + And there is a valid "custom_destination" in the system + And request contains "custom_destination_id" parameter from "custom_destination.data.id" + And body with value {"data": {"attributes": {"name": "Nginx logs (Updated)"}, "type": "custom_destination", "id": "{{ custom_destination.data.id }}" }} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "custom_destination" + And the response "data.id" is equal to "{{ custom_destination.data.id }}" + And the response "data.attributes.name" is equal to "Nginx logs (Updated)" + And the response "data.attributes.query" is equal to "{{ custom_destination.data.attributes.query }}" + And the response "data.attributes.forwarder_destination.type" is equal to "{{ custom_destination.data.attributes.forwarder_destination.type }}" + And the response "data.attributes.forwarder_destination.endpoint" is equal to "{{ custom_destination.data.attributes.forwarder_destination.endpoint }}" + And the response "data.attributes.forwarder_destination.auth.type" is equal to "{{ custom_destination.data.attributes.forwarder_destination.auth.type }}" + And the response "data.attributes.forwarder_destination.auth" does not have field "username" + And the response "data.attributes.forwarder_destination.auth" does not have field "password" + And the response "data.attributes.enabled" is false + And the response "data.attributes.forward_tags" is false + And the response "data.attributes.forward_tags_restriction_list" has length 1 + And the response "data.attributes.forward_tags_restriction_list" array contains value "host" + And the response "data.attributes.forward_tags_restriction_list_type" is equal to "{{ custom_destination.data.attributes.forward_tags_restriction_list_type }}" diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 90fee66806c..f1ce400479c 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1076,6 +1076,43 @@ "type": "unsafe" } }, + "ListLogsCustomDestinations": { + "tag": "Logs Custom Destinations", + "undo": { + "type": "safe" + } + }, + "CreateLogsCustomDestination": { + "tag": "Logs Custom Destinations", + "undo": { + "operationId": "DeleteLogsCustomDestination", + "parameters": [ + { + "name": "custom_destination_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteLogsCustomDestination": { + "tag": "Logs Custom Destinations", + "undo": { + "type": "idempotent" + } + }, + "GetLogsCustomDestination": { + "tag": "Logs Custom Destinations", + "undo": { + "type": "safe" + } + }, + "UpdateLogsCustomDestination": { + "tag": "Logs Custom Destinations", + "undo": { + "type": "idempotent" + } + }, "ListLogsMetrics": { "tag": "Logs Metrics", "undo": {