diff --git a/.generated-info b/.generated-info index db7079e0a7b..e86fa933c5f 100644 --- a/.generated-info +++ b/.generated-info @@ -1,4 +1,4 @@ { - "spec_repo_commit": "20279f4", - "generated": "2025-07-18 10:24:19.812" + "spec_repo_commit": "0f24b8e", + "generated": "2025-07-18 16:54:43.860" } diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ee3c8b9b971..5a4d2ba1227 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2016,11 +2016,13 @@ components: description: The definition of `ActionConnectionIntegration` object. oneOf: - $ref: '#/components/schemas/AWSIntegration' + - $ref: '#/components/schemas/DatadogIntegration' - $ref: '#/components/schemas/HTTPIntegration' ActionConnectionIntegrationUpdate: description: The definition of `ActionConnectionIntegrationUpdate` object. oneOf: - $ref: '#/components/schemas/AWSIntegrationUpdate' + - $ref: '#/components/schemas/DatadogIntegrationUpdate' - $ref: '#/components/schemas/HTTPIntegrationUpdate' ActionQuery: description: An action query. This query type is used to trigger an action, @@ -12378,6 +12380,103 @@ components: required: - databaseMonitoringTrigger type: object + DatadogAPIKey: + description: The definition of the `DatadogAPIKey` object. + properties: + api_key: + description: The `DatadogAPIKey` `api_key`. + example: '' + type: string + app_key: + description: The `DatadogAPIKey` `app_key`. + example: '' + type: string + datacenter: + description: The `DatadogAPIKey` `datacenter`. + example: '' + type: string + subdomain: + description: Custom subdomain used for Datadog URLs generated with this + Connection. For example, if this org uses `https://acme.datadoghq.com` + to access Datadog, set this field to `acme`. If this field is omitted, + generated URLs will use the default site URL for its datacenter (see [https://docs.datadoghq.com/getting_started/site](https://docs.datadoghq.com/getting_started/site)). + type: string + type: + $ref: '#/components/schemas/DatadogAPIKeyType' + required: + - type + - datacenter + - api_key + - app_key + type: object + DatadogAPIKeyType: + description: The definition of the `DatadogAPIKey` object. + enum: + - DatadogAPIKey + example: DatadogAPIKey + type: string + x-enum-varnames: + - DATADOGAPIKEY + DatadogAPIKeyUpdate: + description: The definition of the `DatadogAPIKey` object. + properties: + api_key: + description: The `DatadogAPIKeyUpdate` `api_key`. + type: string + app_key: + description: The `DatadogAPIKeyUpdate` `app_key`. + type: string + datacenter: + description: The `DatadogAPIKeyUpdate` `datacenter`. + type: string + subdomain: + description: Custom subdomain used for Datadog URLs generated with this + Connection. For example, if this org uses `https://acme.datadoghq.com` + to access Datadog, set this field to `acme`. If this field is omitted, + generated URLs will use the default site URL for its datacenter (see [https://docs.datadoghq.com/getting_started/site](https://docs.datadoghq.com/getting_started/site)). + type: string + type: + $ref: '#/components/schemas/DatadogAPIKeyType' + required: + - type + type: object + DatadogCredentials: + description: The definition of the `DatadogCredentials` object. + oneOf: + - $ref: '#/components/schemas/DatadogAPIKey' + DatadogCredentialsUpdate: + description: The definition of the `DatadogCredentialsUpdate` object. + oneOf: + - $ref: '#/components/schemas/DatadogAPIKeyUpdate' + DatadogIntegration: + description: The definition of the `DatadogIntegration` object. + properties: + credentials: + $ref: '#/components/schemas/DatadogCredentials' + type: + $ref: '#/components/schemas/DatadogIntegrationType' + required: + - type + - credentials + type: object + DatadogIntegrationType: + description: The definition of the `DatadogIntegrationType` object. + enum: + - Datadog + example: Datadog + type: string + x-enum-varnames: + - DATADOG + DatadogIntegrationUpdate: + description: The definition of the `DatadogIntegrationUpdate` object. + properties: + credentials: + $ref: '#/components/schemas/DatadogCredentialsUpdate' + type: + $ref: '#/components/schemas/DatadogIntegrationType' + required: + - type + type: object Dataset: description: Dataset object. properties: @@ -23189,6 +23288,61 @@ components: type: string type: array type: object + MetricTagCardinalitiesData: + description: A list of tag cardinalities associated with the given metric. + items: + $ref: '#/components/schemas/MetricTagCardinality' + type: array + MetricTagCardinalitiesMeta: + description: Response metadata object. + properties: + metric_name: + description: 'The name of metric for which the tag cardinalities are returned. + + This matches the metric name provided in the request. + + ' + type: string + type: object + MetricTagCardinalitiesResponse: + description: 'Response object that includes an array of objects representing + the cardinality details of a metric''s tags. + + ' + properties: + data: + $ref: '#/components/schemas/MetricTagCardinalitiesData' + meta: + $ref: '#/components/schemas/MetricTagCardinalitiesMeta' + readOnly: true + type: object + MetricTagCardinality: + description: Object containing metadata and attributes related to a specific + tag key associated with the metric. + example: + attributes: + cardinality_delta: 25 + id: http.request.latency + type: tag_cardinality + properties: + attributes: + $ref: '#/components/schemas/MetricTagCardinalityAttributes' + id: + description: The name of the tag key. + type: string + type: + default: tag_cardinality + description: This describes the endpoint action. + type: string + type: object + MetricTagCardinalityAttributes: + description: An object containing properties related to the tag key + properties: + cardinality_delta: + description: This describes the recent change in the tag keys cardinality + format: int64 + type: integer + type: object MetricTagConfiguration: description: Object for a single metric tag configuration. example: @@ -53610,6 +53764,50 @@ paths: x-permission: operator: OPEN permissions: [] + /api/v2/metrics/{metric_name}/tag-cardinalities: + get: + description: Returns the cardinality details of tags for a specific metric. + operationId: GetMetricTagCardinalityDetails + parameters: + - $ref: '#/components/parameters/MetricName' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/MetricTagCardinalitiesResponse' + description: Success + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Too Many Requests + summary: Get tag key cardinality details + tags: + - Metrics + x-permission: + operator: OR + permissions: + - metrics_read /api/v2/metrics/{metric_name}/tags: delete: description: 'Deletes a metric''s tag configuration. Can only be used with application diff --git a/api/datadogV2/api_metrics.go b/api/datadogV2/api_metrics.go index 7a465c37ec8..dbca5833e6b 100644 --- a/api/datadogV2/api_metrics.go +++ b/api/datadogV2/api_metrics.go @@ -484,6 +484,84 @@ func (a *MetricsApi) EstimateMetricsOutputSeries(ctx _context.Context, metricNam return localVarReturnValue, localVarHTTPResponse, nil } +// GetMetricTagCardinalityDetails Get tag key cardinality details. +// Returns the cardinality details of tags for a specific metric. +func (a *MetricsApi) GetMetricTagCardinalityDetails(ctx _context.Context, metricName string) (MetricTagCardinalitiesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue MetricTagCardinalitiesResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.MetricsApi.GetMetricTagCardinalityDetails") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/metrics/{metric_name}/tag-cardinalities" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{metric_name}", _neturl.PathEscape(datadog.ParameterToString(metricName, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 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 +} + // ListActiveMetricConfigurationsOptionalParameters holds optional parameters for ListActiveMetricConfigurations. type ListActiveMetricConfigurationsOptionalParameters struct { WindowSeconds *int64 diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index c4a711cff37..316a9bdd653 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -267,6 +267,7 @@ // - [MetricsApi.DeleteBulkTagsMetricsConfiguration] // - [MetricsApi.DeleteTagConfiguration] // - [MetricsApi.EstimateMetricsOutputSeries] +// - [MetricsApi.GetMetricTagCardinalityDetails] // - [MetricsApi.ListActiveMetricConfigurations] // - [MetricsApi.ListMetricAssets] // - [MetricsApi.ListTagConfigurationByName] diff --git a/api/datadogV2/model_action_connection_integration.go b/api/datadogV2/model_action_connection_integration.go index d5a48b1f46c..2294303be02 100644 --- a/api/datadogV2/model_action_connection_integration.go +++ b/api/datadogV2/model_action_connection_integration.go @@ -10,8 +10,9 @@ import ( // ActionConnectionIntegration - The definition of `ActionConnectionIntegration` object. type ActionConnectionIntegration struct { - AWSIntegration *AWSIntegration - HTTPIntegration *HTTPIntegration + AWSIntegration *AWSIntegration + DatadogIntegration *DatadogIntegration + HTTPIntegration *HTTPIntegration // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct UnparsedObject interface{} @@ -22,6 +23,11 @@ func AWSIntegrationAsActionConnectionIntegration(v *AWSIntegration) ActionConnec return ActionConnectionIntegration{AWSIntegration: v} } +// DatadogIntegrationAsActionConnectionIntegration is a convenience function that returns DatadogIntegration wrapped in ActionConnectionIntegration. +func DatadogIntegrationAsActionConnectionIntegration(v *DatadogIntegration) ActionConnectionIntegration { + return ActionConnectionIntegration{DatadogIntegration: v} +} + // HTTPIntegrationAsActionConnectionIntegration is a convenience function that returns HTTPIntegration wrapped in ActionConnectionIntegration. func HTTPIntegrationAsActionConnectionIntegration(v *HTTPIntegration) ActionConnectionIntegration { return ActionConnectionIntegration{HTTPIntegration: v} @@ -48,6 +54,23 @@ func (obj *ActionConnectionIntegration) UnmarshalJSON(data []byte) error { obj.AWSIntegration = nil } + // try to unmarshal data into DatadogIntegration + err = datadog.Unmarshal(data, &obj.DatadogIntegration) + if err == nil { + if obj.DatadogIntegration != nil && obj.DatadogIntegration.UnparsedObject == nil { + jsonDatadogIntegration, _ := datadog.Marshal(obj.DatadogIntegration) + if string(jsonDatadogIntegration) == "{}" { // empty struct + obj.DatadogIntegration = nil + } else { + match++ + } + } else { + obj.DatadogIntegration = nil + } + } else { + obj.DatadogIntegration = nil + } + // try to unmarshal data into HTTPIntegration err = datadog.Unmarshal(data, &obj.HTTPIntegration) if err == nil { @@ -68,6 +91,7 @@ func (obj *ActionConnectionIntegration) UnmarshalJSON(data []byte) error { if match != 1 { // more than 1 match // reset to nil obj.AWSIntegration = nil + obj.DatadogIntegration = nil obj.HTTPIntegration = nil return datadog.Unmarshal(data, &obj.UnparsedObject) } @@ -80,6 +104,10 @@ func (obj ActionConnectionIntegration) MarshalJSON() ([]byte, error) { return datadog.Marshal(&obj.AWSIntegration) } + if obj.DatadogIntegration != nil { + return datadog.Marshal(&obj.DatadogIntegration) + } + if obj.HTTPIntegration != nil { return datadog.Marshal(&obj.HTTPIntegration) } @@ -96,6 +124,10 @@ func (obj *ActionConnectionIntegration) GetActualInstance() interface{} { return obj.AWSIntegration } + if obj.DatadogIntegration != nil { + return obj.DatadogIntegration + } + if obj.HTTPIntegration != nil { return obj.HTTPIntegration } diff --git a/api/datadogV2/model_action_connection_integration_update.go b/api/datadogV2/model_action_connection_integration_update.go index 1f21ea888f7..4777cca3f2e 100644 --- a/api/datadogV2/model_action_connection_integration_update.go +++ b/api/datadogV2/model_action_connection_integration_update.go @@ -10,8 +10,9 @@ import ( // ActionConnectionIntegrationUpdate - The definition of `ActionConnectionIntegrationUpdate` object. type ActionConnectionIntegrationUpdate struct { - AWSIntegrationUpdate *AWSIntegrationUpdate - HTTPIntegrationUpdate *HTTPIntegrationUpdate + AWSIntegrationUpdate *AWSIntegrationUpdate + DatadogIntegrationUpdate *DatadogIntegrationUpdate + HTTPIntegrationUpdate *HTTPIntegrationUpdate // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct UnparsedObject interface{} @@ -22,6 +23,11 @@ func AWSIntegrationUpdateAsActionConnectionIntegrationUpdate(v *AWSIntegrationUp return ActionConnectionIntegrationUpdate{AWSIntegrationUpdate: v} } +// DatadogIntegrationUpdateAsActionConnectionIntegrationUpdate is a convenience function that returns DatadogIntegrationUpdate wrapped in ActionConnectionIntegrationUpdate. +func DatadogIntegrationUpdateAsActionConnectionIntegrationUpdate(v *DatadogIntegrationUpdate) ActionConnectionIntegrationUpdate { + return ActionConnectionIntegrationUpdate{DatadogIntegrationUpdate: v} +} + // HTTPIntegrationUpdateAsActionConnectionIntegrationUpdate is a convenience function that returns HTTPIntegrationUpdate wrapped in ActionConnectionIntegrationUpdate. func HTTPIntegrationUpdateAsActionConnectionIntegrationUpdate(v *HTTPIntegrationUpdate) ActionConnectionIntegrationUpdate { return ActionConnectionIntegrationUpdate{HTTPIntegrationUpdate: v} @@ -48,6 +54,23 @@ func (obj *ActionConnectionIntegrationUpdate) UnmarshalJSON(data []byte) error { obj.AWSIntegrationUpdate = nil } + // try to unmarshal data into DatadogIntegrationUpdate + err = datadog.Unmarshal(data, &obj.DatadogIntegrationUpdate) + if err == nil { + if obj.DatadogIntegrationUpdate != nil && obj.DatadogIntegrationUpdate.UnparsedObject == nil { + jsonDatadogIntegrationUpdate, _ := datadog.Marshal(obj.DatadogIntegrationUpdate) + if string(jsonDatadogIntegrationUpdate) == "{}" { // empty struct + obj.DatadogIntegrationUpdate = nil + } else { + match++ + } + } else { + obj.DatadogIntegrationUpdate = nil + } + } else { + obj.DatadogIntegrationUpdate = nil + } + // try to unmarshal data into HTTPIntegrationUpdate err = datadog.Unmarshal(data, &obj.HTTPIntegrationUpdate) if err == nil { @@ -68,6 +91,7 @@ func (obj *ActionConnectionIntegrationUpdate) UnmarshalJSON(data []byte) error { if match != 1 { // more than 1 match // reset to nil obj.AWSIntegrationUpdate = nil + obj.DatadogIntegrationUpdate = nil obj.HTTPIntegrationUpdate = nil return datadog.Unmarshal(data, &obj.UnparsedObject) } @@ -80,6 +104,10 @@ func (obj ActionConnectionIntegrationUpdate) MarshalJSON() ([]byte, error) { return datadog.Marshal(&obj.AWSIntegrationUpdate) } + if obj.DatadogIntegrationUpdate != nil { + return datadog.Marshal(&obj.DatadogIntegrationUpdate) + } + if obj.HTTPIntegrationUpdate != nil { return datadog.Marshal(&obj.HTTPIntegrationUpdate) } @@ -96,6 +124,10 @@ func (obj *ActionConnectionIntegrationUpdate) GetActualInstance() interface{} { return obj.AWSIntegrationUpdate } + if obj.DatadogIntegrationUpdate != nil { + return obj.DatadogIntegrationUpdate + } + if obj.HTTPIntegrationUpdate != nil { return obj.HTTPIntegrationUpdate } diff --git a/api/datadogV2/model_datadog_api_key.go b/api/datadogV2/model_datadog_api_key.go new file mode 100644 index 00000000000..d96feb63e71 --- /dev/null +++ b/api/datadogV2/model_datadog_api_key.go @@ -0,0 +1,242 @@ +// 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" +) + +// DatadogAPIKey The definition of the `DatadogAPIKey` object. +type DatadogAPIKey struct { + // The `DatadogAPIKey` `api_key`. + ApiKey string `json:"api_key"` + // The `DatadogAPIKey` `app_key`. + AppKey string `json:"app_key"` + // The `DatadogAPIKey` `datacenter`. + Datacenter string `json:"datacenter"` + // Custom subdomain used for Datadog URLs generated with this Connection. For example, if this org uses `https://acme.datadoghq.com` to access Datadog, set this field to `acme`. If this field is omitted, generated URLs will use the default site URL for its datacenter (see [https://docs.datadoghq.com/getting_started/site](https://docs.datadoghq.com/getting_started/site)). + Subdomain *string `json:"subdomain,omitempty"` + // The definition of the `DatadogAPIKey` object. + Type DatadogAPIKeyType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDatadogAPIKey instantiates a new DatadogAPIKey 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 NewDatadogAPIKey(apiKey string, appKey string, datacenter string, typeVar DatadogAPIKeyType) *DatadogAPIKey { + this := DatadogAPIKey{} + this.ApiKey = apiKey + this.AppKey = appKey + this.Datacenter = datacenter + this.Type = typeVar + return &this +} + +// NewDatadogAPIKeyWithDefaults instantiates a new DatadogAPIKey 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 NewDatadogAPIKeyWithDefaults() *DatadogAPIKey { + this := DatadogAPIKey{} + return &this +} + +// GetApiKey returns the ApiKey field value. +func (o *DatadogAPIKey) GetApiKey() string { + if o == nil { + var ret string + return ret + } + return o.ApiKey +} + +// GetApiKeyOk returns a tuple with the ApiKey field value +// and a boolean to check if the value has been set. +func (o *DatadogAPIKey) GetApiKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ApiKey, true +} + +// SetApiKey sets field value. +func (o *DatadogAPIKey) SetApiKey(v string) { + o.ApiKey = v +} + +// GetAppKey returns the AppKey field value. +func (o *DatadogAPIKey) GetAppKey() string { + if o == nil { + var ret string + return ret + } + return o.AppKey +} + +// GetAppKeyOk returns a tuple with the AppKey field value +// and a boolean to check if the value has been set. +func (o *DatadogAPIKey) GetAppKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AppKey, true +} + +// SetAppKey sets field value. +func (o *DatadogAPIKey) SetAppKey(v string) { + o.AppKey = v +} + +// GetDatacenter returns the Datacenter field value. +func (o *DatadogAPIKey) GetDatacenter() string { + if o == nil { + var ret string + return ret + } + return o.Datacenter +} + +// GetDatacenterOk returns a tuple with the Datacenter field value +// and a boolean to check if the value has been set. +func (o *DatadogAPIKey) GetDatacenterOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Datacenter, true +} + +// SetDatacenter sets field value. +func (o *DatadogAPIKey) SetDatacenter(v string) { + o.Datacenter = v +} + +// GetSubdomain returns the Subdomain field value if set, zero value otherwise. +func (o *DatadogAPIKey) GetSubdomain() string { + if o == nil || o.Subdomain == nil { + var ret string + return ret + } + return *o.Subdomain +} + +// GetSubdomainOk returns a tuple with the Subdomain field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DatadogAPIKey) GetSubdomainOk() (*string, bool) { + if o == nil || o.Subdomain == nil { + return nil, false + } + return o.Subdomain, true +} + +// HasSubdomain returns a boolean if a field has been set. +func (o *DatadogAPIKey) HasSubdomain() bool { + return o != nil && o.Subdomain != nil +} + +// SetSubdomain gets a reference to the given string and assigns it to the Subdomain field. +func (o *DatadogAPIKey) SetSubdomain(v string) { + o.Subdomain = &v +} + +// GetType returns the Type field value. +func (o *DatadogAPIKey) GetType() DatadogAPIKeyType { + if o == nil { + var ret DatadogAPIKeyType + 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 *DatadogAPIKey) GetTypeOk() (*DatadogAPIKeyType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DatadogAPIKey) SetType(v DatadogAPIKeyType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DatadogAPIKey) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["api_key"] = o.ApiKey + toSerialize["app_key"] = o.AppKey + toSerialize["datacenter"] = o.Datacenter + if o.Subdomain != nil { + toSerialize["subdomain"] = o.Subdomain + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DatadogAPIKey) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ApiKey *string `json:"api_key"` + AppKey *string `json:"app_key"` + Datacenter *string `json:"datacenter"` + Subdomain *string `json:"subdomain,omitempty"` + Type *DatadogAPIKeyType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ApiKey == nil { + return fmt.Errorf("required field api_key missing") + } + if all.AppKey == nil { + return fmt.Errorf("required field app_key missing") + } + if all.Datacenter == nil { + return fmt.Errorf("required field datacenter 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{"api_key", "app_key", "datacenter", "subdomain", "type"}) + } else { + return err + } + + hasInvalidField := false + o.ApiKey = *all.ApiKey + o.AppKey = *all.AppKey + o.Datacenter = *all.Datacenter + o.Subdomain = all.Subdomain + 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_datadog_api_key_type.go b/api/datadogV2/model_datadog_api_key_type.go new file mode 100644 index 00000000000..f9a2b6c27d9 --- /dev/null +++ b/api/datadogV2/model_datadog_api_key_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" +) + +// DatadogAPIKeyType The definition of the `DatadogAPIKey` object. +type DatadogAPIKeyType string + +// List of DatadogAPIKeyType. +const ( + DATADOGAPIKEYTYPE_DATADOGAPIKEY DatadogAPIKeyType = "DatadogAPIKey" +) + +var allowedDatadogAPIKeyTypeEnumValues = []DatadogAPIKeyType{ + DATADOGAPIKEYTYPE_DATADOGAPIKEY, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *DatadogAPIKeyType) GetAllowedValues() []DatadogAPIKeyType { + return allowedDatadogAPIKeyTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *DatadogAPIKeyType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = DatadogAPIKeyType(value) + return nil +} + +// NewDatadogAPIKeyTypeFromValue returns a pointer to a valid DatadogAPIKeyType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewDatadogAPIKeyTypeFromValue(v string) (*DatadogAPIKeyType, error) { + ev := DatadogAPIKeyType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for DatadogAPIKeyType: valid values are %v", v, allowedDatadogAPIKeyTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v DatadogAPIKeyType) IsValid() bool { + for _, existing := range allowedDatadogAPIKeyTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DatadogAPIKeyType value. +func (v DatadogAPIKeyType) Ptr() *DatadogAPIKeyType { + return &v +} diff --git a/api/datadogV2/model_datadog_api_key_update.go b/api/datadogV2/model_datadog_api_key_update.go new file mode 100644 index 00000000000..9fec5594ed7 --- /dev/null +++ b/api/datadogV2/model_datadog_api_key_update.go @@ -0,0 +1,251 @@ +// 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" +) + +// DatadogAPIKeyUpdate The definition of the `DatadogAPIKey` object. +type DatadogAPIKeyUpdate struct { + // The `DatadogAPIKeyUpdate` `api_key`. + ApiKey *string `json:"api_key,omitempty"` + // The `DatadogAPIKeyUpdate` `app_key`. + AppKey *string `json:"app_key,omitempty"` + // The `DatadogAPIKeyUpdate` `datacenter`. + Datacenter *string `json:"datacenter,omitempty"` + // Custom subdomain used for Datadog URLs generated with this Connection. For example, if this org uses `https://acme.datadoghq.com` to access Datadog, set this field to `acme`. If this field is omitted, generated URLs will use the default site URL for its datacenter (see [https://docs.datadoghq.com/getting_started/site](https://docs.datadoghq.com/getting_started/site)). + Subdomain *string `json:"subdomain,omitempty"` + // The definition of the `DatadogAPIKey` object. + Type DatadogAPIKeyType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDatadogAPIKeyUpdate instantiates a new DatadogAPIKeyUpdate 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 NewDatadogAPIKeyUpdate(typeVar DatadogAPIKeyType) *DatadogAPIKeyUpdate { + this := DatadogAPIKeyUpdate{} + this.Type = typeVar + return &this +} + +// NewDatadogAPIKeyUpdateWithDefaults instantiates a new DatadogAPIKeyUpdate 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 NewDatadogAPIKeyUpdateWithDefaults() *DatadogAPIKeyUpdate { + this := DatadogAPIKeyUpdate{} + return &this +} + +// GetApiKey returns the ApiKey field value if set, zero value otherwise. +func (o *DatadogAPIKeyUpdate) GetApiKey() string { + if o == nil || o.ApiKey == nil { + var ret string + return ret + } + return *o.ApiKey +} + +// GetApiKeyOk returns a tuple with the ApiKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DatadogAPIKeyUpdate) GetApiKeyOk() (*string, bool) { + if o == nil || o.ApiKey == nil { + return nil, false + } + return o.ApiKey, true +} + +// HasApiKey returns a boolean if a field has been set. +func (o *DatadogAPIKeyUpdate) HasApiKey() bool { + return o != nil && o.ApiKey != nil +} + +// SetApiKey gets a reference to the given string and assigns it to the ApiKey field. +func (o *DatadogAPIKeyUpdate) SetApiKey(v string) { + o.ApiKey = &v +} + +// GetAppKey returns the AppKey field value if set, zero value otherwise. +func (o *DatadogAPIKeyUpdate) GetAppKey() string { + if o == nil || o.AppKey == nil { + var ret string + return ret + } + return *o.AppKey +} + +// GetAppKeyOk returns a tuple with the AppKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DatadogAPIKeyUpdate) GetAppKeyOk() (*string, bool) { + if o == nil || o.AppKey == nil { + return nil, false + } + return o.AppKey, true +} + +// HasAppKey returns a boolean if a field has been set. +func (o *DatadogAPIKeyUpdate) HasAppKey() bool { + return o != nil && o.AppKey != nil +} + +// SetAppKey gets a reference to the given string and assigns it to the AppKey field. +func (o *DatadogAPIKeyUpdate) SetAppKey(v string) { + o.AppKey = &v +} + +// GetDatacenter returns the Datacenter field value if set, zero value otherwise. +func (o *DatadogAPIKeyUpdate) GetDatacenter() string { + if o == nil || o.Datacenter == nil { + var ret string + return ret + } + return *o.Datacenter +} + +// GetDatacenterOk returns a tuple with the Datacenter field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DatadogAPIKeyUpdate) GetDatacenterOk() (*string, bool) { + if o == nil || o.Datacenter == nil { + return nil, false + } + return o.Datacenter, true +} + +// HasDatacenter returns a boolean if a field has been set. +func (o *DatadogAPIKeyUpdate) HasDatacenter() bool { + return o != nil && o.Datacenter != nil +} + +// SetDatacenter gets a reference to the given string and assigns it to the Datacenter field. +func (o *DatadogAPIKeyUpdate) SetDatacenter(v string) { + o.Datacenter = &v +} + +// GetSubdomain returns the Subdomain field value if set, zero value otherwise. +func (o *DatadogAPIKeyUpdate) GetSubdomain() string { + if o == nil || o.Subdomain == nil { + var ret string + return ret + } + return *o.Subdomain +} + +// GetSubdomainOk returns a tuple with the Subdomain field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DatadogAPIKeyUpdate) GetSubdomainOk() (*string, bool) { + if o == nil || o.Subdomain == nil { + return nil, false + } + return o.Subdomain, true +} + +// HasSubdomain returns a boolean if a field has been set. +func (o *DatadogAPIKeyUpdate) HasSubdomain() bool { + return o != nil && o.Subdomain != nil +} + +// SetSubdomain gets a reference to the given string and assigns it to the Subdomain field. +func (o *DatadogAPIKeyUpdate) SetSubdomain(v string) { + o.Subdomain = &v +} + +// GetType returns the Type field value. +func (o *DatadogAPIKeyUpdate) GetType() DatadogAPIKeyType { + if o == nil { + var ret DatadogAPIKeyType + 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 *DatadogAPIKeyUpdate) GetTypeOk() (*DatadogAPIKeyType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DatadogAPIKeyUpdate) SetType(v DatadogAPIKeyType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DatadogAPIKeyUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ApiKey != nil { + toSerialize["api_key"] = o.ApiKey + } + if o.AppKey != nil { + toSerialize["app_key"] = o.AppKey + } + if o.Datacenter != nil { + toSerialize["datacenter"] = o.Datacenter + } + if o.Subdomain != nil { + toSerialize["subdomain"] = o.Subdomain + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DatadogAPIKeyUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ApiKey *string `json:"api_key,omitempty"` + AppKey *string `json:"app_key,omitempty"` + Datacenter *string `json:"datacenter,omitempty"` + Subdomain *string `json:"subdomain,omitempty"` + Type *DatadogAPIKeyType `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{"api_key", "app_key", "datacenter", "subdomain", "type"}) + } else { + return err + } + + hasInvalidField := false + o.ApiKey = all.ApiKey + o.AppKey = all.AppKey + o.Datacenter = all.Datacenter + o.Subdomain = all.Subdomain + 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_datadog_credentials.go b/api/datadogV2/model_datadog_credentials.go new file mode 100644 index 00000000000..dc4157c3518 --- /dev/null +++ b/api/datadogV2/model_datadog_credentials.go @@ -0,0 +1,73 @@ +// 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" +) + +// DatadogCredentials - The definition of the `DatadogCredentials` object. +type DatadogCredentials struct { + DatadogAPIKey *DatadogAPIKey + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// DatadogAPIKeyAsDatadogCredentials is a convenience function that returns DatadogAPIKey wrapped in DatadogCredentials. +func DatadogAPIKeyAsDatadogCredentials(v *DatadogAPIKey) DatadogCredentials { + return DatadogCredentials{DatadogAPIKey: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *DatadogCredentials) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into DatadogAPIKey + err = datadog.Unmarshal(data, &obj.DatadogAPIKey) + if err == nil { + if obj.DatadogAPIKey != nil && obj.DatadogAPIKey.UnparsedObject == nil { + jsonDatadogAPIKey, _ := datadog.Marshal(obj.DatadogAPIKey) + if string(jsonDatadogAPIKey) == "{}" { // empty struct + obj.DatadogAPIKey = nil + } else { + match++ + } + } else { + obj.DatadogAPIKey = nil + } + } else { + obj.DatadogAPIKey = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.DatadogAPIKey = 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 DatadogCredentials) MarshalJSON() ([]byte, error) { + if obj.DatadogAPIKey != nil { + return datadog.Marshal(&obj.DatadogAPIKey) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *DatadogCredentials) GetActualInstance() interface{} { + if obj.DatadogAPIKey != nil { + return obj.DatadogAPIKey + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_datadog_credentials_update.go b/api/datadogV2/model_datadog_credentials_update.go new file mode 100644 index 00000000000..2a62a03411c --- /dev/null +++ b/api/datadogV2/model_datadog_credentials_update.go @@ -0,0 +1,73 @@ +// 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" +) + +// DatadogCredentialsUpdate - The definition of the `DatadogCredentialsUpdate` object. +type DatadogCredentialsUpdate struct { + DatadogAPIKeyUpdate *DatadogAPIKeyUpdate + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// DatadogAPIKeyUpdateAsDatadogCredentialsUpdate is a convenience function that returns DatadogAPIKeyUpdate wrapped in DatadogCredentialsUpdate. +func DatadogAPIKeyUpdateAsDatadogCredentialsUpdate(v *DatadogAPIKeyUpdate) DatadogCredentialsUpdate { + return DatadogCredentialsUpdate{DatadogAPIKeyUpdate: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *DatadogCredentialsUpdate) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into DatadogAPIKeyUpdate + err = datadog.Unmarshal(data, &obj.DatadogAPIKeyUpdate) + if err == nil { + if obj.DatadogAPIKeyUpdate != nil && obj.DatadogAPIKeyUpdate.UnparsedObject == nil { + jsonDatadogAPIKeyUpdate, _ := datadog.Marshal(obj.DatadogAPIKeyUpdate) + if string(jsonDatadogAPIKeyUpdate) == "{}" { // empty struct + obj.DatadogAPIKeyUpdate = nil + } else { + match++ + } + } else { + obj.DatadogAPIKeyUpdate = nil + } + } else { + obj.DatadogAPIKeyUpdate = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.DatadogAPIKeyUpdate = 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 DatadogCredentialsUpdate) MarshalJSON() ([]byte, error) { + if obj.DatadogAPIKeyUpdate != nil { + return datadog.Marshal(&obj.DatadogAPIKeyUpdate) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *DatadogCredentialsUpdate) GetActualInstance() interface{} { + if obj.DatadogAPIKeyUpdate != nil { + return obj.DatadogAPIKeyUpdate + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_datadog_integration.go b/api/datadogV2/model_datadog_integration.go new file mode 100644 index 00000000000..e51a37f3861 --- /dev/null +++ b/api/datadogV2/model_datadog_integration.go @@ -0,0 +1,143 @@ +// 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" +) + +// DatadogIntegration The definition of the `DatadogIntegration` object. +type DatadogIntegration struct { + // The definition of the `DatadogCredentials` object. + Credentials DatadogCredentials `json:"credentials"` + // The definition of the `DatadogIntegrationType` object. + Type DatadogIntegrationType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDatadogIntegration instantiates a new DatadogIntegration 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 NewDatadogIntegration(credentials DatadogCredentials, typeVar DatadogIntegrationType) *DatadogIntegration { + this := DatadogIntegration{} + this.Credentials = credentials + this.Type = typeVar + return &this +} + +// NewDatadogIntegrationWithDefaults instantiates a new DatadogIntegration 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 NewDatadogIntegrationWithDefaults() *DatadogIntegration { + this := DatadogIntegration{} + return &this +} + +// GetCredentials returns the Credentials field value. +func (o *DatadogIntegration) GetCredentials() DatadogCredentials { + if o == nil { + var ret DatadogCredentials + return ret + } + return o.Credentials +} + +// GetCredentialsOk returns a tuple with the Credentials field value +// and a boolean to check if the value has been set. +func (o *DatadogIntegration) GetCredentialsOk() (*DatadogCredentials, bool) { + if o == nil { + return nil, false + } + return &o.Credentials, true +} + +// SetCredentials sets field value. +func (o *DatadogIntegration) SetCredentials(v DatadogCredentials) { + o.Credentials = v +} + +// GetType returns the Type field value. +func (o *DatadogIntegration) GetType() DatadogIntegrationType { + if o == nil { + var ret DatadogIntegrationType + 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 *DatadogIntegration) GetTypeOk() (*DatadogIntegrationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DatadogIntegration) SetType(v DatadogIntegrationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DatadogIntegration) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["credentials"] = o.Credentials + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DatadogIntegration) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Credentials *DatadogCredentials `json:"credentials"` + Type *DatadogIntegrationType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Credentials == nil { + return fmt.Errorf("required field credentials 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{"credentials", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Credentials = *all.Credentials + 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_datadog_integration_type.go b/api/datadogV2/model_datadog_integration_type.go new file mode 100644 index 00000000000..e4b6295bbcb --- /dev/null +++ b/api/datadogV2/model_datadog_integration_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" +) + +// DatadogIntegrationType The definition of the `DatadogIntegrationType` object. +type DatadogIntegrationType string + +// List of DatadogIntegrationType. +const ( + DATADOGINTEGRATIONTYPE_DATADOG DatadogIntegrationType = "Datadog" +) + +var allowedDatadogIntegrationTypeEnumValues = []DatadogIntegrationType{ + DATADOGINTEGRATIONTYPE_DATADOG, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *DatadogIntegrationType) GetAllowedValues() []DatadogIntegrationType { + return allowedDatadogIntegrationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *DatadogIntegrationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = DatadogIntegrationType(value) + return nil +} + +// NewDatadogIntegrationTypeFromValue returns a pointer to a valid DatadogIntegrationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewDatadogIntegrationTypeFromValue(v string) (*DatadogIntegrationType, error) { + ev := DatadogIntegrationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for DatadogIntegrationType: valid values are %v", v, allowedDatadogIntegrationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v DatadogIntegrationType) IsValid() bool { + for _, existing := range allowedDatadogIntegrationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to DatadogIntegrationType value. +func (v DatadogIntegrationType) Ptr() *DatadogIntegrationType { + return &v +} diff --git a/api/datadogV2/model_datadog_integration_update.go b/api/datadogV2/model_datadog_integration_update.go new file mode 100644 index 00000000000..149ef65923e --- /dev/null +++ b/api/datadogV2/model_datadog_integration_update.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" +) + +// DatadogIntegrationUpdate The definition of the `DatadogIntegrationUpdate` object. +type DatadogIntegrationUpdate struct { + // The definition of the `DatadogCredentialsUpdate` object. + Credentials *DatadogCredentialsUpdate `json:"credentials,omitempty"` + // The definition of the `DatadogIntegrationType` object. + Type DatadogIntegrationType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDatadogIntegrationUpdate instantiates a new DatadogIntegrationUpdate 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 NewDatadogIntegrationUpdate(typeVar DatadogIntegrationType) *DatadogIntegrationUpdate { + this := DatadogIntegrationUpdate{} + this.Type = typeVar + return &this +} + +// NewDatadogIntegrationUpdateWithDefaults instantiates a new DatadogIntegrationUpdate 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 NewDatadogIntegrationUpdateWithDefaults() *DatadogIntegrationUpdate { + this := DatadogIntegrationUpdate{} + return &this +} + +// GetCredentials returns the Credentials field value if set, zero value otherwise. +func (o *DatadogIntegrationUpdate) GetCredentials() DatadogCredentialsUpdate { + if o == nil || o.Credentials == nil { + var ret DatadogCredentialsUpdate + return ret + } + return *o.Credentials +} + +// GetCredentialsOk returns a tuple with the Credentials field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DatadogIntegrationUpdate) GetCredentialsOk() (*DatadogCredentialsUpdate, bool) { + if o == nil || o.Credentials == nil { + return nil, false + } + return o.Credentials, true +} + +// HasCredentials returns a boolean if a field has been set. +func (o *DatadogIntegrationUpdate) HasCredentials() bool { + return o != nil && o.Credentials != nil +} + +// SetCredentials gets a reference to the given DatadogCredentialsUpdate and assigns it to the Credentials field. +func (o *DatadogIntegrationUpdate) SetCredentials(v DatadogCredentialsUpdate) { + o.Credentials = &v +} + +// GetType returns the Type field value. +func (o *DatadogIntegrationUpdate) GetType() DatadogIntegrationType { + if o == nil { + var ret DatadogIntegrationType + 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 *DatadogIntegrationUpdate) GetTypeOk() (*DatadogIntegrationType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DatadogIntegrationUpdate) SetType(v DatadogIntegrationType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DatadogIntegrationUpdate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Credentials != nil { + toSerialize["credentials"] = o.Credentials + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DatadogIntegrationUpdate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Credentials *DatadogCredentialsUpdate `json:"credentials,omitempty"` + Type *DatadogIntegrationType `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{"credentials", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Credentials = all.Credentials + 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_metric_tag_cardinalities_meta.go b/api/datadogV2/model_metric_tag_cardinalities_meta.go new file mode 100644 index 00000000000..2fa5834a3ac --- /dev/null +++ b/api/datadogV2/model_metric_tag_cardinalities_meta.go @@ -0,0 +1,104 @@ +// 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" +) + +// MetricTagCardinalitiesMeta Response metadata object. +type MetricTagCardinalitiesMeta struct { + // The name of metric for which the tag cardinalities are returned. + // This matches the metric name provided in the request. + // + MetricName *string `json:"metric_name,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewMetricTagCardinalitiesMeta instantiates a new MetricTagCardinalitiesMeta 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 NewMetricTagCardinalitiesMeta() *MetricTagCardinalitiesMeta { + this := MetricTagCardinalitiesMeta{} + return &this +} + +// NewMetricTagCardinalitiesMetaWithDefaults instantiates a new MetricTagCardinalitiesMeta 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 NewMetricTagCardinalitiesMetaWithDefaults() *MetricTagCardinalitiesMeta { + this := MetricTagCardinalitiesMeta{} + return &this +} + +// GetMetricName returns the MetricName field value if set, zero value otherwise. +func (o *MetricTagCardinalitiesMeta) GetMetricName() string { + if o == nil || o.MetricName == nil { + var ret string + return ret + } + return *o.MetricName +} + +// GetMetricNameOk returns a tuple with the MetricName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricTagCardinalitiesMeta) GetMetricNameOk() (*string, bool) { + if o == nil || o.MetricName == nil { + return nil, false + } + return o.MetricName, true +} + +// HasMetricName returns a boolean if a field has been set. +func (o *MetricTagCardinalitiesMeta) HasMetricName() bool { + return o != nil && o.MetricName != nil +} + +// SetMetricName gets a reference to the given string and assigns it to the MetricName field. +func (o *MetricTagCardinalitiesMeta) SetMetricName(v string) { + o.MetricName = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MetricTagCardinalitiesMeta) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.MetricName != nil { + toSerialize["metric_name"] = o.MetricName + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MetricTagCardinalitiesMeta) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + MetricName *string `json:"metric_name,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{"metric_name"}) + } else { + return err + } + o.MetricName = all.MetricName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_metric_tag_cardinalities_response.go b/api/datadogV2/model_metric_tag_cardinalities_response.go new file mode 100644 index 00000000000..4050dee1152 --- /dev/null +++ b/api/datadogV2/model_metric_tag_cardinalities_response.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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MetricTagCardinalitiesResponse Response object that includes an array of objects representing the cardinality details of a metric's tags. +type MetricTagCardinalitiesResponse struct { + // A list of tag cardinalities associated with the given metric. + Data []MetricTagCardinality `json:"data,omitempty"` + // Response metadata object. + Meta *MetricTagCardinalitiesMeta `json:"meta,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewMetricTagCardinalitiesResponse instantiates a new MetricTagCardinalitiesResponse 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 NewMetricTagCardinalitiesResponse() *MetricTagCardinalitiesResponse { + this := MetricTagCardinalitiesResponse{} + return &this +} + +// NewMetricTagCardinalitiesResponseWithDefaults instantiates a new MetricTagCardinalitiesResponse 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 NewMetricTagCardinalitiesResponseWithDefaults() *MetricTagCardinalitiesResponse { + this := MetricTagCardinalitiesResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *MetricTagCardinalitiesResponse) GetData() []MetricTagCardinality { + if o == nil || o.Data == nil { + var ret []MetricTagCardinality + 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 *MetricTagCardinalitiesResponse) GetDataOk() (*[]MetricTagCardinality, 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 *MetricTagCardinalitiesResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []MetricTagCardinality and assigns it to the Data field. +func (o *MetricTagCardinalitiesResponse) SetData(v []MetricTagCardinality) { + o.Data = v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *MetricTagCardinalitiesResponse) GetMeta() MetricTagCardinalitiesMeta { + if o == nil || o.Meta == nil { + var ret MetricTagCardinalitiesMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricTagCardinalitiesResponse) GetMetaOk() (*MetricTagCardinalitiesMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *MetricTagCardinalitiesResponse) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given MetricTagCardinalitiesMeta and assigns it to the Meta field. +func (o *MetricTagCardinalitiesResponse) SetMeta(v MetricTagCardinalitiesMeta) { + o.Meta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MetricTagCardinalitiesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MetricTagCardinalitiesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []MetricTagCardinality `json:"data,omitempty"` + Meta *MetricTagCardinalitiesMeta `json:"meta,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", "meta"}) + } else { + return err + } + + hasInvalidField := false + o.Data = all.Data + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = all.Meta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_metric_tag_cardinality.go b/api/datadogV2/model_metric_tag_cardinality.go new file mode 100644 index 00000000000..4cf9003f282 --- /dev/null +++ b/api/datadogV2/model_metric_tag_cardinality.go @@ -0,0 +1,185 @@ +// 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" +) + +// MetricTagCardinality Object containing metadata and attributes related to a specific tag key associated with the metric. +type MetricTagCardinality struct { + // An object containing properties related to the tag key + Attributes *MetricTagCardinalityAttributes `json:"attributes,omitempty"` + // The name of the tag key. + Id *string `json:"id,omitempty"` + // This describes the endpoint action. + Type *string `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewMetricTagCardinality instantiates a new MetricTagCardinality 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 NewMetricTagCardinality() *MetricTagCardinality { + this := MetricTagCardinality{} + var typeVar string = "tag_cardinality" + this.Type = &typeVar + return &this +} + +// NewMetricTagCardinalityWithDefaults instantiates a new MetricTagCardinality 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 NewMetricTagCardinalityWithDefaults() *MetricTagCardinality { + this := MetricTagCardinality{} + var typeVar string = "tag_cardinality" + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *MetricTagCardinality) GetAttributes() MetricTagCardinalityAttributes { + if o == nil || o.Attributes == nil { + var ret MetricTagCardinalityAttributes + 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 *MetricTagCardinality) GetAttributesOk() (*MetricTagCardinalityAttributes, 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 *MetricTagCardinality) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given MetricTagCardinalityAttributes and assigns it to the Attributes field. +func (o *MetricTagCardinality) SetAttributes(v MetricTagCardinalityAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *MetricTagCardinality) 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 *MetricTagCardinality) 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 *MetricTagCardinality) 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 *MetricTagCardinality) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *MetricTagCardinality) GetType() string { + if o == nil || o.Type == nil { + var ret string + 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 *MetricTagCardinality) GetTypeOk() (*string, 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 *MetricTagCardinality) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *MetricTagCardinality) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MetricTagCardinality) 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 *MetricTagCardinality) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *MetricTagCardinalityAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *string `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 + 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_metric_tag_cardinality_attributes.go b/api/datadogV2/model_metric_tag_cardinality_attributes.go new file mode 100644 index 00000000000..b90fc639720 --- /dev/null +++ b/api/datadogV2/model_metric_tag_cardinality_attributes.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" +) + +// MetricTagCardinalityAttributes An object containing properties related to the tag key +type MetricTagCardinalityAttributes struct { + // This describes the recent change in the tag keys cardinality + CardinalityDelta *int64 `json:"cardinality_delta,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewMetricTagCardinalityAttributes instantiates a new MetricTagCardinalityAttributes 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 NewMetricTagCardinalityAttributes() *MetricTagCardinalityAttributes { + this := MetricTagCardinalityAttributes{} + return &this +} + +// NewMetricTagCardinalityAttributesWithDefaults instantiates a new MetricTagCardinalityAttributes 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 NewMetricTagCardinalityAttributesWithDefaults() *MetricTagCardinalityAttributes { + this := MetricTagCardinalityAttributes{} + return &this +} + +// GetCardinalityDelta returns the CardinalityDelta field value if set, zero value otherwise. +func (o *MetricTagCardinalityAttributes) GetCardinalityDelta() int64 { + if o == nil || o.CardinalityDelta == nil { + var ret int64 + return ret + } + return *o.CardinalityDelta +} + +// GetCardinalityDeltaOk returns a tuple with the CardinalityDelta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricTagCardinalityAttributes) GetCardinalityDeltaOk() (*int64, bool) { + if o == nil || o.CardinalityDelta == nil { + return nil, false + } + return o.CardinalityDelta, true +} + +// HasCardinalityDelta returns a boolean if a field has been set. +func (o *MetricTagCardinalityAttributes) HasCardinalityDelta() bool { + return o != nil && o.CardinalityDelta != nil +} + +// SetCardinalityDelta gets a reference to the given int64 and assigns it to the CardinalityDelta field. +func (o *MetricTagCardinalityAttributes) SetCardinalityDelta(v int64) { + o.CardinalityDelta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MetricTagCardinalityAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CardinalityDelta != nil { + toSerialize["cardinality_delta"] = o.CardinalityDelta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MetricTagCardinalityAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CardinalityDelta *int64 `json:"cardinality_delta,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{"cardinality_delta"}) + } else { + return err + } + o.CardinalityDelta = all.CardinalityDelta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/metrics/GetMetricTagCardinalityDetails.go b/examples/v2/metrics/GetMetricTagCardinalityDetails.go new file mode 100644 index 00000000000..291ee1cc6d2 --- /dev/null +++ b/examples/v2/metrics/GetMetricTagCardinalityDetails.go @@ -0,0 +1,29 @@ +// Get tag key cardinality details returns "Success" 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.NewMetricsApi(apiClient) + resp, r, err := api.GetMetricTagCardinalityDetails(ctx, "metric_name") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.GetMetricTagCardinalityDetails`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `MetricsApi.GetMetricTagCardinalityDetails`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/metrics.feature b/tests/scenarios/features/v2/metrics.feature index e412ab01368..41e753dfb3f 100644 --- a/tests/scenarios/features/v2/metrics.feature +++ b/tests/scenarios/features/v2/metrics.feature @@ -152,6 +152,30 @@ Feature: Metrics Then the response status is 200 Success And the response "data[0].type" is equal to "manage_tags" + @generated @skip @team:DataDog/metrics-experience + Scenario: Get tag key cardinality details returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And new "GetMetricTagCardinalityDetails" request + And request contains "metric_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/metrics-experience + Scenario: Get tag key cardinality details returns "Not Found" response + Given a valid "appKeyAuth" key in the system + And new "GetMetricTagCardinalityDetails" request + And request contains "metric_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/metrics-experience + Scenario: Get tag key cardinality details returns "Success" response + Given a valid "appKeyAuth" key in the system + And new "GetMetricTagCardinalityDetails" request + And request contains "metric_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 Success + @generated @skip @team:DataDog/metrics-experience Scenario: List active tags and aggregations returns "Bad Request" response Given a valid "appKeyAuth" key in the system diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index abe0c0b370d..a75ff96853d 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1864,6 +1864,12 @@ "type": "safe" } }, + "GetMetricTagCardinalityDetails": { + "tag": "Metrics", + "undo": { + "type": "safe" + } + }, "DeleteTagConfiguration": { "tag": "Metrics", "undo": {