diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 1e1724d2f72b..48ab737debc4 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -98062,6 +98062,414 @@ components: format: int64 type: integer type: object + TagPoliciesListResponse: + description: A page of tag policies. + properties: + data: + $ref: "#/components/schemas/TagPolicyDataArray" + included: + $ref: "#/components/schemas/TagPolicyIncludedResources" + required: + - data + type: object + TagPolicyAttributes: + description: The attributes of a tag policy resource. + properties: + created_at: + description: The RFC 3339 timestamp at which the policy was created. + example: "2026-05-21T22:11:06.108696Z" + format: date-time + type: string + created_by: + description: The identifier of the user who created the policy. + example: "test-user" + type: string + deleted_at: + description: The RFC 3339 timestamp at which the policy was soft-deleted. `null` if the policy has not been deleted. Only present when `include_deleted=true` is requested. + format: date-time + nullable: true + type: string + deleted_by: + description: The identifier of the user who soft-deleted the policy. `null` if the policy has not been deleted. + nullable: true + type: string + enabled: + description: Whether the policy is currently enforced. + example: true + type: boolean + modified_at: + description: The RFC 3339 timestamp at which the policy was last modified. + example: "2026-05-21T22:11:06.108696Z" + format: date-time + type: string + modified_by: + description: The identifier of the user who last modified the policy. + example: "test-user" + type: string + negated: + description: When `true`, the policy matches tag values that do NOT match any of the supplied patterns. + example: false + type: boolean + policy_name: + description: Human-readable name for the tag policy. + example: "Service tag must be one of api or web" + type: string + policy_type: + $ref: "#/components/schemas/TagPolicyType" + required: + description: When `true`, telemetry without this tag is treated as a violation. + example: true + type: boolean + scope: + description: The scope the policy applies within. + example: "env" + type: string + source: + $ref: "#/components/schemas/TagPolicySource" + tag_key: + description: The tag key that the policy governs. + example: "service" + type: string + tag_value_patterns: + description: The patterns that valid values for the tag key must match. + example: + - "api" + - "web" + items: + description: A pattern that valid tag values must match. + type: string + type: array + version: + description: A monotonically increasing version counter that is incremented on each update. + example: 1 + format: int64 + type: integer + required: + - policy_name + - source + - scope + - tag_key + - tag_value_patterns + - negated + - required + - enabled + - policy_type + - version + - created_at + - created_by + - modified_at + - modified_by + type: object + TagPolicyCreateAttributes: + description: Attributes that can be supplied when creating a tag policy. + properties: + enabled: + description: Whether the policy is currently enforced. Defaults to `true` for newly created policies. + example: true + type: boolean + negated: + description: When `true`, the policy matches tag values that do NOT match any of the supplied patterns. Defaults to `false`. + example: false + type: boolean + policy_name: + description: Human-readable name for the tag policy. + example: "Service tag must be one of api or web" + type: string + policy_type: + $ref: "#/components/schemas/TagPolicyCreateType" + required: + description: When `true`, telemetry without this tag is treated as a violation. Defaults to `false`. + example: true + type: boolean + scope: + description: |- + The scope the policy applies within. Typically an environment, team, or + organization-level identifier used to limit where the policy is enforced. + example: "env" + type: string + source: + $ref: "#/components/schemas/TagPolicySource" + tag_key: + description: The tag key that the policy governs (for example, `service`). + example: "service" + type: string + tag_value_patterns: + description: |- + One or more patterns that valid values for the tag key must match. At least one + pattern is required. + example: + - "api" + - "web" + items: + description: A pattern that valid tag values must match. + type: string + minItems: 1 + type: array + required: + - policy_name + - source + - scope + - tag_key + - tag_value_patterns + - policy_type + type: object + TagPolicyCreateData: + description: Data object for creating a tag policy. + properties: + attributes: + $ref: "#/components/schemas/TagPolicyCreateAttributes" + type: + $ref: "#/components/schemas/TagPolicyResourceType" + required: + - type + - attributes + type: object + TagPolicyCreateRequest: + description: Payload for creating a new tag policy. + properties: + data: + $ref: "#/components/schemas/TagPolicyCreateData" + required: + - data + type: object + TagPolicyCreateType: + description: |- + The policy type allowed when creating a tag policy. Only `surfacing` is accepted at + creation time. + enum: + - surfacing + example: "surfacing" + type: string + x-enum-varnames: + - SURFACING + TagPolicyData: + description: A tag policy resource. + properties: + attributes: + $ref: "#/components/schemas/TagPolicyAttributes" + id: + description: The unique identifier of the tag policy. + example: "123" + type: string + relationships: + $ref: "#/components/schemas/TagPolicyRelationships" + type: + $ref: "#/components/schemas/TagPolicyResourceType" + required: + - type + - id + - attributes + type: object + TagPolicyDataArray: + description: An array of tag policy data objects. + items: + $ref: "#/components/schemas/TagPolicyData" + type: array + TagPolicyInclude: + description: A related resource to include alongside a tag policy in the response. Currently the only supported value is `score`. + enum: + - score + example: "score" + type: string + x-enum-varnames: + - SCORE + TagPolicyIncludedResources: + description: Related resources fetched alongside the primary tag policies. Populated when an `include` query parameter is supplied. + items: + $ref: "#/components/schemas/TagPolicyScoreData" + type: array + TagPolicyRelationships: + description: Related resources for a tag policy. Only present when the corresponding `include` query parameter is supplied. + properties: + score: + $ref: "#/components/schemas/TagPolicyScoreRelationship" + type: object + TagPolicyResourceType: + description: JSON:API resource type for a tag policy. + enum: + - tag_policy + example: "tag_policy" + type: string + x-enum-varnames: + - TAG_POLICY + TagPolicyResponse: + description: A single tag policy. + properties: + data: + $ref: "#/components/schemas/TagPolicyData" + included: + $ref: "#/components/schemas/TagPolicyIncludedResources" + required: + - data + type: object + TagPolicyScoreAttributes: + description: Attributes of a tag policy compliance score. + properties: + score: + description: |- + The compliance score for the policy over the requested time window, as a percentage + between 0 and 100. `null` indicates that no relevant telemetry was found. + example: 80 + format: double + nullable: true + type: number + ts_end: + description: End of the time window the score was computed over, as a Unix timestamp in milliseconds. + example: 1779401466097 + format: int64 + type: integer + ts_start: + description: Start of the time window the score was computed over, as a Unix timestamp in milliseconds. + example: 1779315066097 + format: int64 + type: integer + version: + description: The version of the tag policy that the score was computed against. + example: 1 + format: int64 + type: integer + required: + - score + - ts_start + - ts_end + - version + type: object + TagPolicyScoreData: + description: A compliance score resource for a tag policy. + properties: + attributes: + $ref: "#/components/schemas/TagPolicyScoreAttributes" + id: + description: The unique identifier of the compliance score resource. + example: "123-v1-1779315066097-1779401466097" + type: string + type: + $ref: "#/components/schemas/TagPolicyScoreResourceType" + required: + - type + - id + - attributes + type: object + TagPolicyScoreRelationship: + description: A relationship to the compliance score resource for this policy. + properties: + data: + $ref: "#/components/schemas/TagPolicyScoreRelationshipData" + required: + - data + type: object + TagPolicyScoreRelationshipData: + description: Identifier of the related compliance score resource. + properties: + id: + description: The unique identifier of the related compliance score resource. + example: "123-v1-1779315066097-1779401466097" + type: string + type: + $ref: "#/components/schemas/TagPolicyScoreResourceType" + required: + - type + - id + type: object + TagPolicyScoreResourceType: + description: JSON:API resource type for a tag policy compliance score. + enum: + - tag_policy_score + example: "tag_policy_score" + type: string + x-enum-varnames: + - TAG_POLICY_SCORE + TagPolicyScoreResponse: + description: A tag policy compliance score. + properties: + data: + $ref: "#/components/schemas/TagPolicyScoreData" + required: + - data + type: object + TagPolicySource: + description: The telemetry source that a tag policy applies to. + enum: + - logs + - spans + - metrics + - rum + - feed + example: "logs" + type: string + x-enum-varnames: + - LOGS + - SPANS + - METRICS + - RUM + - FEED + TagPolicyType: + description: |- + How the policy is enforced. `blocking` rejects telemetry that violates the policy. + `surfacing` only highlights non-compliant telemetry without blocking it. + enum: + - blocking + - surfacing + example: "surfacing" + type: string + x-enum-varnames: + - BLOCKING + - SURFACING + TagPolicyUpdateAttributes: + description: |- + Mutable attributes of a tag policy. Each field is optional; omitting a field leaves its + current value unchanged. The `source` of a policy cannot be changed. + properties: + enabled: + description: Whether the policy is currently enforced. + type: boolean + negated: + description: When `true`, the policy matches tag values that do NOT match any of the supplied patterns. + type: boolean + policy_name: + description: Human-readable name for the tag policy. + type: string + policy_type: + $ref: "#/components/schemas/TagPolicyType" + required: + description: When `true`, telemetry without this tag is treated as a violation. + type: boolean + scope: + description: The scope the policy applies within. + type: string + tag_key: + description: The tag key that the policy governs. + type: string + tag_value_patterns: + description: One or more patterns that valid values for the tag key must match. + items: + description: A pattern that valid tag values must match. + type: string + type: array + type: object + TagPolicyUpdateData: + description: Data object for updating a tag policy. + properties: + attributes: + $ref: "#/components/schemas/TagPolicyUpdateAttributes" + id: + description: The unique identifier of the tag policy being updated. + example: "123" + type: string + type: + $ref: "#/components/schemas/TagPolicyResourceType" + required: + - type + - id + type: object + TagPolicyUpdateRequest: + description: Payload for updating an existing tag policy. Only the supplied fields are modified. + properties: + data: + $ref: "#/components/schemas/TagPolicyUpdateData" + required: + - data + type: object TagsEventAttribute: description: Array of tags associated with your event. example: ["team:A"] @@ -182595,6 +183003,559 @@ paths: operator: OR permissions: - synthetics_global_variable_write + /api/v2/tag-policies: + get: + description: |- + Retrieve all tag policies for the organization. Optionally include disabled or deleted + policies, filter by telemetry source, and include each policy's current compliance score + via the `include=score` query parameter. + operationId: ListTagPolicies + parameters: + - description: Whether to include policies that are currently disabled. Defaults to `false`. + example: false + in: query + name: include_disabled + required: false + schema: + type: boolean + - description: Whether to include policies that have been soft-deleted. Defaults to `false`. + example: false + in: query + name: include_deleted + required: false + schema: + type: boolean + - description: Comma-separated list of related resources to include alongside each policy in the response. Currently the only supported value is `score`. + example: "score" + in: query + name: include + required: false + schema: + $ref: "#/components/schemas/TagPolicyInclude" + - description: Restrict the result set to policies whose source matches the given value. + in: query + name: filter[source] + required: false + schema: + $ref: "#/components/schemas/TagPolicySource" + - description: Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Defaults to a recent window appropriate for the source. + example: 1779315066097 + in: query + name: ts_start + required: false + schema: + format: int64 + type: integer + - description: End of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Must be in the past and greater than `ts_start`. + example: 1779401466097 + in: query + name: ts_end + required: false + schema: + format: int64 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + created_at: "2026-05-21T22:11:06.108696Z" + created_by: "test-user" + enabled: true + modified_at: "2026-05-21T22:11:06.108696Z" + modified_by: "test-user" + negated: false + policy_name: "Service tag must be one of api or web" + policy_type: "surfacing" + required: true + scope: "env" + source: "logs" + tag_key: "service" + tag_value_patterns: + - "api" + - "web" + version: 1 + id: "123" + relationships: + score: + data: + id: "123-v1-1779315066097-1779401466097" + type: "tag_policy_score" + type: "tag_policy" + included: + - attributes: + score: 80 + ts_end: 1779401466097 + ts_start: 1779315066097 + version: 1 + id: "123-v1-1779315066097-1779401466097" + type: "tag_policy_score" + schema: + $ref: "#/components/schemas/TagPoliciesListResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List tag policies + tags: + - Tag Policies + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + post: + description: |- + Create a new tag policy for the organization. The caller's organization is derived from + the authenticated user; cross-organization creation is not supported. Fields such as + `policy_id`, `version`, and the timestamp/audit fields are assigned by the server. + operationId: CreateTagPolicy + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + enabled: true + negated: false + policy_name: "Service tag must be one of api or web" + policy_type: "surfacing" + required: true + scope: "env" + source: "logs" + tag_key: "service" + tag_value_patterns: + - "api" + - "web" + type: "tag_policy" + schema: + $ref: "#/components/schemas/TagPolicyCreateRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2026-05-21T22:11:06.108696Z" + created_by: "test-user" + enabled: true + modified_at: "2026-05-21T22:11:06.108696Z" + modified_by: "test-user" + negated: false + policy_name: "Service tag must be one of api or web" + policy_type: "surfacing" + required: true + scope: "env" + source: "logs" + tag_key: "service" + tag_value_patterns: + - "api" + - "web" + version: 1 + id: "123" + type: "tag_policy" + schema: + $ref: "#/components/schemas/TagPolicyResponse" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Create a tag policy + tags: + - Tag Policies + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/tag-policies/{policy_id}: + delete: + description: |- + Delete a tag policy. By default the policy is soft-deleted so it can be recovered later + and so that historical score data remains queryable. Pass `hard_delete=true` to remove + the policy permanently. + operationId: DeleteTagPolicy + parameters: + - description: The unique identifier of the tag policy to delete. + example: "123" + in: path + name: policy_id + required: true + schema: + type: string + - description: Whether to permanently delete the policy instead of performing a soft delete. Defaults to `false`. + example: false + in: query + name: hard_delete + required: false + schema: + type: boolean + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete a tag policy + tags: + - Tag Policies + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + get: + description: |- + Retrieve a single tag policy by ID. Optionally include the policy's current compliance + score via the `include=score` query parameter. Policies belonging to other organizations + cannot be retrieved. + operationId: GetTagPolicy + parameters: + - description: The unique identifier of the tag policy. + example: "123" + in: path + name: policy_id + required: true + schema: + type: string + - description: Comma-separated list of related resources to include alongside the policy. Currently the only supported value is `score`. + example: "score" + in: query + name: include + required: false + schema: + $ref: "#/components/schemas/TagPolicyInclude" + - description: Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. + example: 1779315066097 + in: query + name: ts_start + required: false + schema: + format: int64 + type: integer + - description: End of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Must be in the past and greater than `ts_start`. + example: 1779401466097 + in: query + name: ts_end + required: false + schema: + format: int64 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2026-05-21T22:11:06.108696Z" + created_by: "test-user" + enabled: true + modified_at: "2026-05-21T22:11:06.108696Z" + modified_by: "test-user" + negated: false + policy_name: "Service tag must be one of api or web" + policy_type: "surfacing" + required: true + scope: "env" + source: "logs" + tag_key: "service" + tag_value_patterns: + - "api" + - "web" + version: 1 + id: "123" + relationships: + score: + data: + id: "123-v1-1779315066097-1779401466097" + type: "tag_policy_score" + type: "tag_policy" + included: + - attributes: + score: 80 + ts_end: 1779401466097 + ts_start: 1779315066097 + version: 1 + id: "123-v1-1779315066097-1779401466097" + type: "tag_policy_score" + schema: + $ref: "#/components/schemas/TagPolicyResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get a tag policy + tags: + - Tag Policies + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + patch: + description: |- + Update one or more attributes of an existing tag policy. Only the fields supplied in the + request body are modified; omitted fields retain their current values. The policy's + `source` cannot be changed after creation. + operationId: UpdateTagPolicy + parameters: + - description: The unique identifier of the tag policy to update. + example: "123" + in: path + name: policy_id + required: true + schema: + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + enabled: true + policy_name: "Service tag must be one of api, web, or worker" + id: "123" + type: "tag_policy" + schema: + $ref: "#/components/schemas/TagPolicyUpdateRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2026-05-21T22:11:06.108696Z" + created_by: "test-user" + enabled: true + modified_at: "2026-05-21T22:25:01.000000Z" + modified_by: "test-user" + negated: false + policy_name: "Service tag must be one of api, web, or worker" + policy_type: "surfacing" + required: true + scope: "env" + source: "logs" + tag_key: "service" + tag_value_patterns: + - "api" + - "web" + version: 2 + id: "123" + type: "tag_policy" + schema: + $ref: "#/components/schemas/TagPolicyResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Update a tag policy + tags: + - Tag Policies + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/tag-policies/{policy_id}/score: + get: + description: |- + Retrieve the compliance score for a single tag policy. The score is computed over the + requested time window (or a source-appropriate default) and represents the percentage of + telemetry within that window that conforms to the policy. A `null` score indicates that + no relevant telemetry was found. + operationId: GetTagPolicyScore + parameters: + - description: The unique identifier of the tag policy. + example: "123" + in: path + name: policy_id + required: true + schema: + type: string + - description: Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. + example: 1779315066097 + in: query + name: ts_start + required: false + schema: + format: int64 + type: integer + - description: End of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Must be in the past and greater than `ts_start`. + example: 1779401466097 + in: query + name: ts_end + required: false + schema: + format: int64 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + score: 80 + ts_end: 1779401466097 + ts_start: 1779315066097 + version: 1 + id: "123-v1-1779315066097-1779401466097" + type: "tag_policy_score" + schema: + $ref: "#/components/schemas/TagPolicyScoreResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get a tag policy compliance score + tags: + - Tag Policies + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/tags/enrichment: get: description: List all tag pipeline rulesets - Retrieve a list of all tag pipeline rulesets for the organization @@ -188558,6 +189519,13 @@ tags: You can use the Datadog API to create, manage, and organize tests and test suites programmatically. For more information, see the [Synthetic Monitoring documentation](https://docs.datadoghq.com/synthetics/). name: Synthetics + - description: |- + Tag Policies define rules that govern which tag values are accepted for a given tag key, + scoped to a particular telemetry source (such as logs, spans, or metrics). Policies can be + `blocking` (data not matching the policy is rejected) or `surfacing` (matching data is + highlighted but not blocked). Each policy reports a compliance `score` derived from how + much recent telemetry adheres to the policy. + name: Tag Policies - description: View and manage teams within Datadog. See the [Teams page](https://docs.datadoghq.com/account_management/teams/) for more information. name: Teams - description: |- diff --git a/examples/v2/tag-policies/CreateTagPolicy.rb b/examples/v2/tag-policies/CreateTagPolicy.rb new file mode 100644 index 000000000000..887f9e411594 --- /dev/null +++ b/examples/v2/tag-policies/CreateTagPolicy.rb @@ -0,0 +1,28 @@ +# Create a tag policy returns "Created" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.create_tag_policy".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TagPoliciesAPI.new + +body = DatadogAPIClient::V2::TagPolicyCreateRequest.new({ + data: DatadogAPIClient::V2::TagPolicyCreateData.new({ + attributes: DatadogAPIClient::V2::TagPolicyCreateAttributes.new({ + enabled: true, + negated: false, + policy_name: "Service tag must be one of api or web", + policy_type: DatadogAPIClient::V2::TagPolicyCreateType::SURFACING, + required: true, + scope: "env", + source: DatadogAPIClient::V2::TagPolicySource::LOGS, + tag_key: "service", + tag_value_patterns: [ + "api", + "web", + ], + }), + type: DatadogAPIClient::V2::TagPolicyResourceType::TAG_POLICY, + }), +}) +p api_instance.create_tag_policy(body) diff --git a/examples/v2/tag-policies/DeleteTagPolicy.rb b/examples/v2/tag-policies/DeleteTagPolicy.rb new file mode 100644 index 000000000000..2d2754052515 --- /dev/null +++ b/examples/v2/tag-policies/DeleteTagPolicy.rb @@ -0,0 +1,8 @@ +# Delete a tag policy returns "No Content" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.delete_tag_policy".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TagPoliciesAPI.new +api_instance.delete_tag_policy("policy_id") diff --git a/examples/v2/tag-policies/GetTagPolicy.rb b/examples/v2/tag-policies/GetTagPolicy.rb new file mode 100644 index 000000000000..1fc5dcbfd922 --- /dev/null +++ b/examples/v2/tag-policies/GetTagPolicy.rb @@ -0,0 +1,8 @@ +# Get a tag policy returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_tag_policy".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TagPoliciesAPI.new +p api_instance.get_tag_policy("policy_id") diff --git a/examples/v2/tag-policies/GetTagPolicyScore.rb b/examples/v2/tag-policies/GetTagPolicyScore.rb new file mode 100644 index 000000000000..aa2f99d0d7cf --- /dev/null +++ b/examples/v2/tag-policies/GetTagPolicyScore.rb @@ -0,0 +1,8 @@ +# Get a tag policy compliance score returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_tag_policy_score".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TagPoliciesAPI.new +p api_instance.get_tag_policy_score("policy_id") diff --git a/examples/v2/tag-policies/ListTagPolicies.rb b/examples/v2/tag-policies/ListTagPolicies.rb new file mode 100644 index 000000000000..04aa25b02572 --- /dev/null +++ b/examples/v2/tag-policies/ListTagPolicies.rb @@ -0,0 +1,8 @@ +# List tag policies returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.list_tag_policies".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TagPoliciesAPI.new +p api_instance.list_tag_policies() diff --git a/examples/v2/tag-policies/UpdateTagPolicy.rb b/examples/v2/tag-policies/UpdateTagPolicy.rb new file mode 100644 index 000000000000..4cfaad12eced --- /dev/null +++ b/examples/v2/tag-policies/UpdateTagPolicy.rb @@ -0,0 +1,19 @@ +# Update a tag policy returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.update_tag_policy".to_sym] = true +end +api_instance = DatadogAPIClient::V2::TagPoliciesAPI.new + +body = DatadogAPIClient::V2::TagPolicyUpdateRequest.new({ + data: DatadogAPIClient::V2::TagPolicyUpdateData.new({ + attributes: DatadogAPIClient::V2::TagPolicyUpdateAttributes.new({ + policy_type: DatadogAPIClient::V2::TagPolicyType::SURFACING, + tag_value_patterns: [], + }), + id: "123", + type: DatadogAPIClient::V2::TagPolicyResourceType::TAG_POLICY, + }), +}) +p api_instance.update_tag_policy("policy_id", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index f802d0320694..21b46f9271ec 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -5641,6 +5641,36 @@ "variable_id" => "String", "body" => "GlobalVariableJsonPatchRequest", }, + "v2.ListTagPolicies" => { + "include_disabled" => "Boolean", + "include_deleted" => "Boolean", + "include" => "TagPolicyInclude", + "filter_source" => "TagPolicySource", + "ts_start" => "Integer", + "ts_end" => "Integer", + }, + "v2.CreateTagPolicy" => { + "body" => "TagPolicyCreateRequest", + }, + "v2.DeleteTagPolicy" => { + "policy_id" => "String", + "hard_delete" => "Boolean", + }, + "v2.GetTagPolicy" => { + "policy_id" => "String", + "include" => "TagPolicyInclude", + "ts_start" => "Integer", + "ts_end" => "Integer", + }, + "v2.UpdateTagPolicy" => { + "policy_id" => "String", + "body" => "TagPolicyUpdateRequest", + }, + "v2.GetTagPolicyScore" => { + "policy_id" => "String", + "ts_start" => "Integer", + "ts_end" => "Integer", + }, "v2.ListTeams" => { "page_number" => "Integer", "page_size" => "Integer", diff --git a/features/v2/tag_policies.feature b/features/v2/tag_policies.feature new file mode 100644 index 000000000000..b5d064c202e7 --- /dev/null +++ b/features/v2/tag_policies.feature @@ -0,0 +1,150 @@ +@endpoint(tag-policies) @endpoint(tag-policies-v2) +Feature: Tag Policies + Tag Policies define rules that govern which tag values are accepted for a + given tag key, scoped to a particular telemetry source (such as logs, + spans, or metrics). Policies can be `blocking` (data not matching the + policy is rejected) or `surfacing` (matching data is highlighted but not + blocked). Each policy reports a compliance `score` derived from how much + recent telemetry adheres to the policy. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "TagPolicies" API + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Create a tag policy returns "Bad Request" response + Given operation "CreateTagPolicy" enabled + And new "CreateTagPolicy" request + And body with value {"data": {"attributes": {"enabled": true, "negated": false, "policy_name": "Service tag must be one of api or web", "policy_type": "surfacing", "required": true, "scope": "env", "source": "logs", "tag_key": "service", "tag_value_patterns": ["api", "web"]}, "type": "tag_policy"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Create a tag policy returns "Conflict" response + Given operation "CreateTagPolicy" enabled + And new "CreateTagPolicy" request + And body with value {"data": {"attributes": {"enabled": true, "negated": false, "policy_name": "Service tag must be one of api or web", "policy_type": "surfacing", "required": true, "scope": "env", "source": "logs", "tag_key": "service", "tag_value_patterns": ["api", "web"]}, "type": "tag_policy"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Create a tag policy returns "Created" response + Given operation "CreateTagPolicy" enabled + And new "CreateTagPolicy" request + And body with value {"data": {"attributes": {"enabled": true, "negated": false, "policy_name": "Service tag must be one of api or web", "policy_type": "surfacing", "required": true, "scope": "env", "source": "logs", "tag_key": "service", "tag_value_patterns": ["api", "web"]}, "type": "tag_policy"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Delete a tag policy returns "Bad Request" response + Given operation "DeleteTagPolicy" enabled + And new "DeleteTagPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Delete a tag policy returns "No Content" response + Given operation "DeleteTagPolicy" enabled + And new "DeleteTagPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Delete a tag policy returns "Not Found" response + Given operation "DeleteTagPolicy" enabled + And new "DeleteTagPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Get a tag policy compliance score returns "Bad Request" response + Given operation "GetTagPolicyScore" enabled + And new "GetTagPolicyScore" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Get a tag policy compliance score returns "Not Found" response + Given operation "GetTagPolicyScore" enabled + And new "GetTagPolicyScore" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Get a tag policy compliance score returns "OK" response + Given operation "GetTagPolicyScore" enabled + And new "GetTagPolicyScore" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Get a tag policy returns "Bad Request" response + Given operation "GetTagPolicy" enabled + And new "GetTagPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Get a tag policy returns "Not Found" response + Given operation "GetTagPolicy" enabled + And new "GetTagPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Get a tag policy returns "OK" response + Given operation "GetTagPolicy" enabled + And new "GetTagPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: List tag policies returns "Bad Request" response + Given operation "ListTagPolicies" enabled + And new "ListTagPolicies" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: List tag policies returns "OK" response + Given operation "ListTagPolicies" enabled + And new "ListTagPolicies" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Update a tag policy returns "Bad Request" response + Given operation "UpdateTagPolicy" enabled + And new "UpdateTagPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"policy_type": "surfacing", "tag_value_patterns": []}, "id": "123", "type": "tag_policy"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Update a tag policy returns "Not Found" response + Given operation "UpdateTagPolicy" enabled + And new "UpdateTagPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"policy_type": "surfacing", "tag_value_patterns": []}, "id": "123", "type": "tag_policy"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/aaa-governance-console + Scenario: Update a tag policy returns "OK" response + Given operation "UpdateTagPolicy" enabled + And new "UpdateTagPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"policy_type": "surfacing", "tag_value_patterns": []}, "id": "123", "type": "tag_policy"}} + When the request is sent + Then the response status is 200 OK diff --git a/features/v2/undo.json b/features/v2/undo.json index 8cd923c97fd7..e947f19f57c9 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -8655,6 +8655,49 @@ "type": "safe" } }, + "ListTagPolicies": { + "tag": "Tag Policies", + "undo": { + "type": "safe" + } + }, + "CreateTagPolicy": { + "tag": "Tag Policies", + "undo": { + "operationId": "DeleteTagPolicy", + "parameters": [ + { + "name": "policy_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteTagPolicy": { + "tag": "Tag Policies", + "undo": { + "type": "idempotent" + } + }, + "GetTagPolicy": { + "tag": "Tag Policies", + "undo": { + "type": "safe" + } + }, + "UpdateTagPolicy": { + "tag": "Tag Policies", + "undo": { + "type": "idempotent" + } + }, + "GetTagPolicyScore": { + "tag": "Tag Policies", + "undo": { + "type": "safe" + } + }, "ListTagPipelinesRulesets": { "tag": "Cloud Cost Management", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index b594494ce809..0770973135e9 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -668,6 +668,12 @@ def initialize "v2.revert_custom_rule_revision": false, "v2.update_ai_custom_ruleset": false, "v2.update_custom_ruleset": false, + "v2.create_tag_policy": false, + "v2.delete_tag_policy": false, + "v2.get_tag_policy": false, + "v2.get_tag_policy_score": false, + "v2.list_tag_policies": false, + "v2.update_tag_policy": false, "v2.add_member_team": false, "v2.list_member_teams": false, "v2.remove_member_team": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 895bb2d32be6..11b93a1f2b1a 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -7097,6 +7097,28 @@ def overrides "v2.tag_indexing_rule_update_attributes" => "TagIndexingRuleUpdateAttributes", "v2.tag_indexing_rule_update_data" => "TagIndexingRuleUpdateData", "v2.tag_indexing_rule_update_request" => "TagIndexingRuleUpdateRequest", + "v2.tag_policies_list_response" => "TagPoliciesListResponse", + "v2.tag_policy_attributes" => "TagPolicyAttributes", + "v2.tag_policy_create_attributes" => "TagPolicyCreateAttributes", + "v2.tag_policy_create_data" => "TagPolicyCreateData", + "v2.tag_policy_create_request" => "TagPolicyCreateRequest", + "v2.tag_policy_create_type" => "TagPolicyCreateType", + "v2.tag_policy_data" => "TagPolicyData", + "v2.tag_policy_include" => "TagPolicyInclude", + "v2.tag_policy_relationships" => "TagPolicyRelationships", + "v2.tag_policy_resource_type" => "TagPolicyResourceType", + "v2.tag_policy_response" => "TagPolicyResponse", + "v2.tag_policy_score_attributes" => "TagPolicyScoreAttributes", + "v2.tag_policy_score_data" => "TagPolicyScoreData", + "v2.tag_policy_score_relationship" => "TagPolicyScoreRelationship", + "v2.tag_policy_score_relationship_data" => "TagPolicyScoreRelationshipData", + "v2.tag_policy_score_resource_type" => "TagPolicyScoreResourceType", + "v2.tag_policy_score_response" => "TagPolicyScoreResponse", + "v2.tag_policy_source" => "TagPolicySource", + "v2.tag_policy_type" => "TagPolicyType", + "v2.tag_policy_update_attributes" => "TagPolicyUpdateAttributes", + "v2.tag_policy_update_data" => "TagPolicyUpdateData", + "v2.tag_policy_update_request" => "TagPolicyUpdateRequest", "v2.targeting_rule" => "TargetingRule", "v2.targeting_rule_request" => "TargetingRuleRequest", "v2.team" => "Team", @@ -7793,6 +7815,7 @@ def overrides "v2.stegadography_api" => "StegadographyAPI", "v2.storage_management_api" => "StorageManagementAPI", "v2.synthetics_api" => "SyntheticsAPI", + "v2.tag_policies_api" => "TagPoliciesAPI", "v2.teams_api" => "TeamsAPI", "v2.test_optimization_api" => "TestOptimizationAPI", "v2.usage_metering_api" => "UsageMeteringAPI", diff --git a/lib/datadog_api_client/v2/api/tag_policies_api.rb b/lib/datadog_api_client/v2/api/tag_policies_api.rb new file mode 100644 index 000000000000..6d04a2737644 --- /dev/null +++ b/lib/datadog_api_client/v2/api/tag_policies_api.rb @@ -0,0 +1,505 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'cgi' + +module DatadogAPIClient::V2 + class TagPoliciesAPI + attr_accessor :api_client + + def initialize(api_client = DatadogAPIClient::APIClient.default) + @api_client = api_client + end + + # Create a tag policy. + # + # @see #create_tag_policy_with_http_info + def create_tag_policy(body, opts = {}) + data, _status_code, _headers = create_tag_policy_with_http_info(body, opts) + data + end + + # Create a tag policy. + # + # Create a new tag policy for the organization. The caller's organization is derived from + # the authenticated user; cross-organization creation is not supported. Fields such as + # `policy_id`, `version`, and the timestamp/audit fields are assigned by the server. + # + # @param body [TagPolicyCreateRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(TagPolicyResponse, Integer, Hash)>] TagPolicyResponse data, response status code and response headers + def create_tag_policy_with_http_info(body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.create_tag_policy".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_tag_policy") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_tag_policy")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TagPoliciesAPI.create_tag_policy ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling TagPoliciesAPI.create_tag_policy" + end + # resource path + local_var_path = '/api/v2/tag-policies' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'TagPolicyResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_tag_policy, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TagPoliciesAPI#create_tag_policy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete a tag policy. + # + # @see #delete_tag_policy_with_http_info + def delete_tag_policy(policy_id, opts = {}) + delete_tag_policy_with_http_info(policy_id, opts) + nil + end + + # Delete a tag policy. + # + # Delete a tag policy. By default the policy is soft-deleted so it can be recovered later + # and so that historical score data remains queryable. Pass `hard_delete=true` to remove + # the policy permanently. + # + # @param policy_id [String] The unique identifier of the tag policy to delete. + # @param opts [Hash] the optional parameters + # @option opts [Boolean] :hard_delete Whether to permanently delete the policy instead of performing a soft delete. Defaults to `false`. + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_tag_policy_with_http_info(policy_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.delete_tag_policy".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.delete_tag_policy") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.delete_tag_policy")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TagPoliciesAPI.delete_tag_policy ...' + end + # verify the required parameter 'policy_id' is set + if @api_client.config.client_side_validation && policy_id.nil? + fail ArgumentError, "Missing the required parameter 'policy_id' when calling TagPoliciesAPI.delete_tag_policy" + end + # resource path + local_var_path = '/api/v2/tag-policies/{policy_id}'.sub('{policy_id}', CGI.escape(policy_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'hard_delete'] = opts[:'hard_delete'] if !opts[:'hard_delete'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :delete_tag_policy, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TagPoliciesAPI#delete_tag_policy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get a tag policy. + # + # @see #get_tag_policy_with_http_info + def get_tag_policy(policy_id, opts = {}) + data, _status_code, _headers = get_tag_policy_with_http_info(policy_id, opts) + data + end + + # Get a tag policy. + # + # Retrieve a single tag policy by ID. Optionally include the policy's current compliance + # score via the `include=score` query parameter. Policies belonging to other organizations + # cannot be retrieved. + # + # @param policy_id [String] The unique identifier of the tag policy. + # @param opts [Hash] the optional parameters + # @option opts [TagPolicyInclude] :include Comma-separated list of related resources to include alongside the policy. Currently the only supported value is `score`. + # @option opts [Integer] :ts_start Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. + # @option opts [Integer] :ts_end End of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Must be in the past and greater than `ts_start`. + # @return [Array<(TagPolicyResponse, Integer, Hash)>] TagPolicyResponse data, response status code and response headers + def get_tag_policy_with_http_info(policy_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_tag_policy".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_tag_policy") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_tag_policy")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TagPoliciesAPI.get_tag_policy ...' + end + # verify the required parameter 'policy_id' is set + if @api_client.config.client_side_validation && policy_id.nil? + fail ArgumentError, "Missing the required parameter 'policy_id' when calling TagPoliciesAPI.get_tag_policy" + end + allowable_values = ['score'] + if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include']) + fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}" + end + # resource path + local_var_path = '/api/v2/tag-policies/{policy_id}'.sub('{policy_id}', CGI.escape(policy_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil? + query_params[:'ts_start'] = opts[:'ts_start'] if !opts[:'ts_start'].nil? + query_params[:'ts_end'] = opts[:'ts_end'] if !opts[:'ts_end'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'TagPolicyResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_tag_policy, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TagPoliciesAPI#get_tag_policy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get a tag policy compliance score. + # + # @see #get_tag_policy_score_with_http_info + def get_tag_policy_score(policy_id, opts = {}) + data, _status_code, _headers = get_tag_policy_score_with_http_info(policy_id, opts) + data + end + + # Get a tag policy compliance score. + # + # Retrieve the compliance score for a single tag policy. The score is computed over the + # requested time window (or a source-appropriate default) and represents the percentage of + # telemetry within that window that conforms to the policy. A `null` score indicates that + # no relevant telemetry was found. + # + # @param policy_id [String] The unique identifier of the tag policy. + # @param opts [Hash] the optional parameters + # @option opts [Integer] :ts_start Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. + # @option opts [Integer] :ts_end End of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Must be in the past and greater than `ts_start`. + # @return [Array<(TagPolicyScoreResponse, Integer, Hash)>] TagPolicyScoreResponse data, response status code and response headers + def get_tag_policy_score_with_http_info(policy_id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_tag_policy_score".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_tag_policy_score") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_tag_policy_score")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TagPoliciesAPI.get_tag_policy_score ...' + end + # verify the required parameter 'policy_id' is set + if @api_client.config.client_side_validation && policy_id.nil? + fail ArgumentError, "Missing the required parameter 'policy_id' when calling TagPoliciesAPI.get_tag_policy_score" + end + # resource path + local_var_path = '/api/v2/tag-policies/{policy_id}/score'.sub('{policy_id}', CGI.escape(policy_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'ts_start'] = opts[:'ts_start'] if !opts[:'ts_start'].nil? + query_params[:'ts_end'] = opts[:'ts_end'] if !opts[:'ts_end'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'TagPolicyScoreResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_tag_policy_score, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TagPoliciesAPI#get_tag_policy_score\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List tag policies. + # + # @see #list_tag_policies_with_http_info + def list_tag_policies(opts = {}) + data, _status_code, _headers = list_tag_policies_with_http_info(opts) + data + end + + # List tag policies. + # + # Retrieve all tag policies for the organization. Optionally include disabled or deleted + # policies, filter by telemetry source, and include each policy's current compliance score + # via the `include=score` query parameter. + # + # @param opts [Hash] the optional parameters + # @option opts [Boolean] :include_disabled Whether to include policies that are currently disabled. Defaults to `false`. + # @option opts [Boolean] :include_deleted Whether to include policies that have been soft-deleted. Defaults to `false`. + # @option opts [TagPolicyInclude] :include Comma-separated list of related resources to include alongside each policy in the response. Currently the only supported value is `score`. + # @option opts [TagPolicySource] :filter_source Restrict the result set to policies whose source matches the given value. + # @option opts [Integer] :ts_start Start of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Defaults to a recent window appropriate for the source. + # @option opts [Integer] :ts_end End of the time window used for compliance score computation, as a Unix timestamp in milliseconds. Must be in the past and greater than `ts_start`. + # @return [Array<(TagPoliciesListResponse, Integer, Hash)>] TagPoliciesListResponse data, response status code and response headers + def list_tag_policies_with_http_info(opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.list_tag_policies".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_tag_policies") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_tag_policies")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TagPoliciesAPI.list_tag_policies ...' + end + allowable_values = ['score'] + if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include']) + fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}" + end + allowable_values = ['logs', 'spans', 'metrics', 'rum', 'feed'] + if @api_client.config.client_side_validation && opts[:'filter_source'] && !allowable_values.include?(opts[:'filter_source']) + fail ArgumentError, "invalid value for \"filter_source\", must be one of #{allowable_values}" + end + # resource path + local_var_path = '/api/v2/tag-policies' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'include_disabled'] = opts[:'include_disabled'] if !opts[:'include_disabled'].nil? + query_params[:'include_deleted'] = opts[:'include_deleted'] if !opts[:'include_deleted'].nil? + query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil? + query_params[:'filter[source]'] = opts[:'filter_source'] if !opts[:'filter_source'].nil? + query_params[:'ts_start'] = opts[:'ts_start'] if !opts[:'ts_start'].nil? + query_params[:'ts_end'] = opts[:'ts_end'] if !opts[:'ts_end'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'TagPoliciesListResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :list_tag_policies, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TagPoliciesAPI#list_tag_policies\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update a tag policy. + # + # @see #update_tag_policy_with_http_info + def update_tag_policy(policy_id, body, opts = {}) + data, _status_code, _headers = update_tag_policy_with_http_info(policy_id, body, opts) + data + end + + # Update a tag policy. + # + # Update one or more attributes of an existing tag policy. Only the fields supplied in the + # request body are modified; omitted fields retain their current values. The policy's + # `source` cannot be changed after creation. + # + # @param policy_id [String] The unique identifier of the tag policy to update. + # @param body [TagPolicyUpdateRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(TagPolicyResponse, Integer, Hash)>] TagPolicyResponse data, response status code and response headers + def update_tag_policy_with_http_info(policy_id, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.update_tag_policy".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.update_tag_policy") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.update_tag_policy")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: TagPoliciesAPI.update_tag_policy ...' + end + # verify the required parameter 'policy_id' is set + if @api_client.config.client_side_validation && policy_id.nil? + fail ArgumentError, "Missing the required parameter 'policy_id' when calling TagPoliciesAPI.update_tag_policy" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling TagPoliciesAPI.update_tag_policy" + end + # resource path + local_var_path = '/api/v2/tag-policies/{policy_id}'.sub('{policy_id}', CGI.escape(policy_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'TagPolicyResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :update_tag_policy, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Patch, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: TagPoliciesAPI#update_tag_policy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policies_list_response.rb b/lib/datadog_api_client/v2/models/tag_policies_list_response.rb new file mode 100644 index 000000000000..58f7e00e4be6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policies_list_response.rb @@ -0,0 +1,137 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A page of tag policies. + class TagPoliciesListResponse + include BaseGenericModel + + # An array of tag policy data objects. + attr_reader :data + + # Related resources fetched alongside the primary tag policies. Populated when an `include` query parameter is supplied. + attr_accessor :included + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'included' => :'included' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'included' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPoliciesListResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'included') + if (value = attributes[:'included']).is_a?(Array) + self.included = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + included == o.included && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, included, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_attributes.rb b/lib/datadog_api_client/v2/models/tag_policy_attributes.rb new file mode 100644 index 000000000000..1874b5e5887f --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_attributes.rb @@ -0,0 +1,428 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The attributes of a tag policy resource. + class TagPolicyAttributes + include BaseGenericModel + + # The RFC 3339 timestamp at which the policy was created. + attr_reader :created_at + + # The identifier of the user who created the policy. + attr_reader :created_by + + # The RFC 3339 timestamp at which the policy was soft-deleted. `null` if the policy has not been deleted. Only present when `include_deleted=true` is requested. + attr_accessor :deleted_at + + # The identifier of the user who soft-deleted the policy. `null` if the policy has not been deleted. + attr_accessor :deleted_by + + # Whether the policy is currently enforced. + attr_reader :enabled + + # The RFC 3339 timestamp at which the policy was last modified. + attr_reader :modified_at + + # The identifier of the user who last modified the policy. + attr_reader :modified_by + + # When `true`, the policy matches tag values that do NOT match any of the supplied patterns. + attr_reader :negated + + # Human-readable name for the tag policy. + attr_reader :policy_name + + # How the policy is enforced. `blocking` rejects telemetry that violates the policy. + # `surfacing` only highlights non-compliant telemetry without blocking it. + attr_reader :policy_type + + # When `true`, telemetry without this tag is treated as a violation. + attr_reader :required + + # The scope the policy applies within. + attr_reader :scope + + # The telemetry source that a tag policy applies to. + attr_reader :source + + # The tag key that the policy governs. + attr_reader :tag_key + + # The patterns that valid values for the tag key must match. + attr_reader :tag_value_patterns + + # A monotonically increasing version counter that is incremented on each update. + attr_reader :version + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'created_at' => :'created_at', + :'created_by' => :'created_by', + :'deleted_at' => :'deleted_at', + :'deleted_by' => :'deleted_by', + :'enabled' => :'enabled', + :'modified_at' => :'modified_at', + :'modified_by' => :'modified_by', + :'negated' => :'negated', + :'policy_name' => :'policy_name', + :'policy_type' => :'policy_type', + :'required' => :'required', + :'scope' => :'scope', + :'source' => :'source', + :'tag_key' => :'tag_key', + :'tag_value_patterns' => :'tag_value_patterns', + :'version' => :'version' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'created_at' => :'Time', + :'created_by' => :'String', + :'deleted_at' => :'Time', + :'deleted_by' => :'String', + :'enabled' => :'Boolean', + :'modified_at' => :'Time', + :'modified_by' => :'String', + :'negated' => :'Boolean', + :'policy_name' => :'String', + :'policy_type' => :'TagPolicyType', + :'required' => :'Boolean', + :'scope' => :'String', + :'source' => :'TagPolicySource', + :'tag_key' => :'String', + :'tag_value_patterns' => :'Array', + :'version' => :'Integer' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'deleted_at', + :'deleted_by', + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'created_by') + self.created_by = attributes[:'created_by'] + end + + if attributes.key?(:'deleted_at') + self.deleted_at = attributes[:'deleted_at'] + end + + if attributes.key?(:'deleted_by') + self.deleted_by = attributes[:'deleted_by'] + end + + if attributes.key?(:'enabled') + self.enabled = attributes[:'enabled'] + end + + if attributes.key?(:'modified_at') + self.modified_at = attributes[:'modified_at'] + end + + if attributes.key?(:'modified_by') + self.modified_by = attributes[:'modified_by'] + end + + if attributes.key?(:'negated') + self.negated = attributes[:'negated'] + end + + if attributes.key?(:'policy_name') + self.policy_name = attributes[:'policy_name'] + end + + if attributes.key?(:'policy_type') + self.policy_type = attributes[:'policy_type'] + end + + if attributes.key?(:'required') + self.required = attributes[:'required'] + end + + if attributes.key?(:'scope') + self.scope = attributes[:'scope'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'tag_key') + self.tag_key = attributes[:'tag_key'] + end + + if attributes.key?(:'tag_value_patterns') + if (value = attributes[:'tag_value_patterns']).is_a?(Array) + self.tag_value_patterns = value + end + end + + if attributes.key?(:'version') + self.version = attributes[:'version'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @created_at.nil? + return false if @created_by.nil? + return false if @enabled.nil? + return false if @modified_at.nil? + return false if @modified_by.nil? + return false if @negated.nil? + return false if @policy_name.nil? + return false if @policy_type.nil? + return false if @required.nil? + return false if @scope.nil? + return false if @source.nil? + return false if @tag_key.nil? + return false if @tag_value_patterns.nil? + return false if @version.nil? + true + end + + # Custom attribute writer method with validation + # @param created_at [Object] Object to be assigned + # @!visibility private + def created_at=(created_at) + if created_at.nil? + fail ArgumentError, 'invalid value for "created_at", created_at cannot be nil.' + end + @created_at = created_at + end + + # Custom attribute writer method with validation + # @param created_by [Object] Object to be assigned + # @!visibility private + def created_by=(created_by) + if created_by.nil? + fail ArgumentError, 'invalid value for "created_by", created_by cannot be nil.' + end + @created_by = created_by + end + + # Custom attribute writer method with validation + # @param enabled [Object] Object to be assigned + # @!visibility private + def enabled=(enabled) + if enabled.nil? + fail ArgumentError, 'invalid value for "enabled", enabled cannot be nil.' + end + @enabled = enabled + end + + # Custom attribute writer method with validation + # @param modified_at [Object] Object to be assigned + # @!visibility private + def modified_at=(modified_at) + if modified_at.nil? + fail ArgumentError, 'invalid value for "modified_at", modified_at cannot be nil.' + end + @modified_at = modified_at + end + + # Custom attribute writer method with validation + # @param modified_by [Object] Object to be assigned + # @!visibility private + def modified_by=(modified_by) + if modified_by.nil? + fail ArgumentError, 'invalid value for "modified_by", modified_by cannot be nil.' + end + @modified_by = modified_by + end + + # Custom attribute writer method with validation + # @param negated [Object] Object to be assigned + # @!visibility private + def negated=(negated) + if negated.nil? + fail ArgumentError, 'invalid value for "negated", negated cannot be nil.' + end + @negated = negated + end + + # Custom attribute writer method with validation + # @param policy_name [Object] Object to be assigned + # @!visibility private + def policy_name=(policy_name) + if policy_name.nil? + fail ArgumentError, 'invalid value for "policy_name", policy_name cannot be nil.' + end + @policy_name = policy_name + end + + # Custom attribute writer method with validation + # @param policy_type [Object] Object to be assigned + # @!visibility private + def policy_type=(policy_type) + if policy_type.nil? + fail ArgumentError, 'invalid value for "policy_type", policy_type cannot be nil.' + end + @policy_type = policy_type + end + + # Custom attribute writer method with validation + # @param required [Object] Object to be assigned + # @!visibility private + def required=(required) + if required.nil? + fail ArgumentError, 'invalid value for "required", required cannot be nil.' + end + @required = required + end + + # Custom attribute writer method with validation + # @param scope [Object] Object to be assigned + # @!visibility private + def scope=(scope) + if scope.nil? + fail ArgumentError, 'invalid value for "scope", scope cannot be nil.' + end + @scope = scope + end + + # Custom attribute writer method with validation + # @param source [Object] Object to be assigned + # @!visibility private + def source=(source) + if source.nil? + fail ArgumentError, 'invalid value for "source", source cannot be nil.' + end + @source = source + end + + # Custom attribute writer method with validation + # @param tag_key [Object] Object to be assigned + # @!visibility private + def tag_key=(tag_key) + if tag_key.nil? + fail ArgumentError, 'invalid value for "tag_key", tag_key cannot be nil.' + end + @tag_key = tag_key + end + + # Custom attribute writer method with validation + # @param tag_value_patterns [Object] Object to be assigned + # @!visibility private + def tag_value_patterns=(tag_value_patterns) + if tag_value_patterns.nil? + fail ArgumentError, 'invalid value for "tag_value_patterns", tag_value_patterns cannot be nil.' + end + @tag_value_patterns = tag_value_patterns + end + + # Custom attribute writer method with validation + # @param version [Object] Object to be assigned + # @!visibility private + def version=(version) + if version.nil? + fail ArgumentError, 'invalid value for "version", version cannot be nil.' + end + @version = version + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + created_at == o.created_at && + created_by == o.created_by && + deleted_at == o.deleted_at && + deleted_by == o.deleted_by && + enabled == o.enabled && + modified_at == o.modified_at && + modified_by == o.modified_by && + negated == o.negated && + policy_name == o.policy_name && + policy_type == o.policy_type && + required == o.required && + scope == o.scope && + source == o.source && + tag_key == o.tag_key && + tag_value_patterns == o.tag_value_patterns && + version == o.version && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [created_at, created_by, deleted_at, deleted_by, enabled, modified_at, modified_by, negated, policy_name, policy_type, required, scope, source, tag_key, tag_value_patterns, version, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_create_attributes.rb b/lib/datadog_api_client/v2/models/tag_policy_create_attributes.rb new file mode 100644 index 000000000000..14b0469ee048 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_create_attributes.rb @@ -0,0 +1,267 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes that can be supplied when creating a tag policy. + class TagPolicyCreateAttributes + include BaseGenericModel + + # Whether the policy is currently enforced. Defaults to `true` for newly created policies. + attr_accessor :enabled + + # When `true`, the policy matches tag values that do NOT match any of the supplied patterns. Defaults to `false`. + attr_accessor :negated + + # Human-readable name for the tag policy. + attr_reader :policy_name + + # The policy type allowed when creating a tag policy. Only `surfacing` is accepted at + # creation time. + attr_reader :policy_type + + # When `true`, telemetry without this tag is treated as a violation. Defaults to `false`. + attr_accessor :required + + # The scope the policy applies within. Typically an environment, team, or + # organization-level identifier used to limit where the policy is enforced. + attr_reader :scope + + # The telemetry source that a tag policy applies to. + attr_reader :source + + # The tag key that the policy governs (for example, `service`). + attr_reader :tag_key + + # One or more patterns that valid values for the tag key must match. At least one + # pattern is required. + attr_reader :tag_value_patterns + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'enabled' => :'enabled', + :'negated' => :'negated', + :'policy_name' => :'policy_name', + :'policy_type' => :'policy_type', + :'required' => :'required', + :'scope' => :'scope', + :'source' => :'source', + :'tag_key' => :'tag_key', + :'tag_value_patterns' => :'tag_value_patterns' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'enabled' => :'Boolean', + :'negated' => :'Boolean', + :'policy_name' => :'String', + :'policy_type' => :'TagPolicyCreateType', + :'required' => :'Boolean', + :'scope' => :'String', + :'source' => :'TagPolicySource', + :'tag_key' => :'String', + :'tag_value_patterns' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyCreateAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'enabled') + self.enabled = attributes[:'enabled'] + end + + if attributes.key?(:'negated') + self.negated = attributes[:'negated'] + end + + if attributes.key?(:'policy_name') + self.policy_name = attributes[:'policy_name'] + end + + if attributes.key?(:'policy_type') + self.policy_type = attributes[:'policy_type'] + end + + if attributes.key?(:'required') + self.required = attributes[:'required'] + end + + if attributes.key?(:'scope') + self.scope = attributes[:'scope'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + + if attributes.key?(:'tag_key') + self.tag_key = attributes[:'tag_key'] + end + + if attributes.key?(:'tag_value_patterns') + if (value = attributes[:'tag_value_patterns']).is_a?(Array) + self.tag_value_patterns = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @policy_name.nil? + return false if @policy_type.nil? + return false if @scope.nil? + return false if @source.nil? + return false if @tag_key.nil? + return false if @tag_value_patterns.nil? + return false if @tag_value_patterns.length < 1 + true + end + + # Custom attribute writer method with validation + # @param policy_name [Object] Object to be assigned + # @!visibility private + def policy_name=(policy_name) + if policy_name.nil? + fail ArgumentError, 'invalid value for "policy_name", policy_name cannot be nil.' + end + @policy_name = policy_name + end + + # Custom attribute writer method with validation + # @param policy_type [Object] Object to be assigned + # @!visibility private + def policy_type=(policy_type) + if policy_type.nil? + fail ArgumentError, 'invalid value for "policy_type", policy_type cannot be nil.' + end + @policy_type = policy_type + end + + # Custom attribute writer method with validation + # @param scope [Object] Object to be assigned + # @!visibility private + def scope=(scope) + if scope.nil? + fail ArgumentError, 'invalid value for "scope", scope cannot be nil.' + end + @scope = scope + end + + # Custom attribute writer method with validation + # @param source [Object] Object to be assigned + # @!visibility private + def source=(source) + if source.nil? + fail ArgumentError, 'invalid value for "source", source cannot be nil.' + end + @source = source + end + + # Custom attribute writer method with validation + # @param tag_key [Object] Object to be assigned + # @!visibility private + def tag_key=(tag_key) + if tag_key.nil? + fail ArgumentError, 'invalid value for "tag_key", tag_key cannot be nil.' + end + @tag_key = tag_key + end + + # Custom attribute writer method with validation + # @param tag_value_patterns [Object] Object to be assigned + # @!visibility private + def tag_value_patterns=(tag_value_patterns) + if tag_value_patterns.nil? + fail ArgumentError, 'invalid value for "tag_value_patterns", tag_value_patterns cannot be nil.' + end + if tag_value_patterns.length < 1 + fail ArgumentError, 'invalid value for "tag_value_patterns", number of items must be greater than or equal to 1.' + end + @tag_value_patterns = tag_value_patterns + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + enabled == o.enabled && + negated == o.negated && + policy_name == o.policy_name && + policy_type == o.policy_type && + required == o.required && + scope == o.scope && + source == o.source && + tag_key == o.tag_key && + tag_value_patterns == o.tag_value_patterns && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [enabled, negated, policy_name, policy_type, required, scope, source, tag_key, tag_value_patterns, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_create_data.rb b/lib/datadog_api_client/v2/models/tag_policy_create_data.rb new file mode 100644 index 000000000000..4b78db9c5eb3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_create_data.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Data object for creating a tag policy. + class TagPolicyCreateData + include BaseGenericModel + + # Attributes that can be supplied when creating a tag policy. + attr_reader :attributes + + # JSON:API resource type for a tag policy. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'TagPolicyCreateAttributes', + :'type' => :'TagPolicyResourceType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyCreateData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_create_request.rb b/lib/datadog_api_client/v2/models/tag_policy_create_request.rb new file mode 100644 index 000000000000..09e079e48947 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_create_request.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Payload for creating a new tag policy. + class TagPolicyCreateRequest + include BaseGenericModel + + # Data object for creating a tag policy. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'TagPolicyCreateData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyCreateRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_create_type.rb b/lib/datadog_api_client/v2/models/tag_policy_create_type.rb new file mode 100644 index 000000000000..025a70e6afbc --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_create_type.rb @@ -0,0 +1,27 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The policy type allowed when creating a tag policy. Only `surfacing` is accepted at + # creation time. + class TagPolicyCreateType + include BaseEnumModel + + SURFACING = "surfacing".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_data.rb b/lib/datadog_api_client/v2/models/tag_policy_data.rb new file mode 100644 index 000000000000..89cfa1ff2726 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_data.rb @@ -0,0 +1,175 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A tag policy resource. + class TagPolicyData + include BaseGenericModel + + # The attributes of a tag policy resource. + attr_reader :attributes + + # The unique identifier of the tag policy. + attr_reader :id + + # Related resources for a tag policy. Only present when the corresponding `include` query parameter is supplied. + attr_accessor :relationships + + # JSON:API resource type for a tag policy. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'relationships' => :'relationships', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'TagPolicyAttributes', + :'id' => :'String', + :'relationships' => :'TagPolicyRelationships', + :'type' => :'TagPolicyResourceType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'relationships') + self.relationships = attributes[:'relationships'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + relationships == o.relationships && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, relationships, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_include.rb b/lib/datadog_api_client/v2/models/tag_policy_include.rb new file mode 100644 index 000000000000..a05c72e0fd13 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_include.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A related resource to include alongside a tag policy in the response. Currently the only supported value is `score`. + class TagPolicyInclude + include BaseEnumModel + + SCORE = "score".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_relationships.rb b/lib/datadog_api_client/v2/models/tag_policy_relationships.rb new file mode 100644 index 000000000000..f98680089ab4 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_relationships.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Related resources for a tag policy. Only present when the corresponding `include` query parameter is supplied. + class TagPolicyRelationships + include BaseGenericModel + + # A relationship to the compliance score resource for this policy. + attr_accessor :score + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'score' => :'score' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'score' => :'TagPolicyScoreRelationship' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyRelationships` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'score') + self.score = attributes[:'score'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + score == o.score && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [score, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_resource_type.rb b/lib/datadog_api_client/v2/models/tag_policy_resource_type.rb new file mode 100644 index 000000000000..a14c461fc774 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_resource_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # JSON:API resource type for a tag policy. + class TagPolicyResourceType + include BaseEnumModel + + TAG_POLICY = "tag_policy".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_response.rb b/lib/datadog_api_client/v2/models/tag_policy_response.rb new file mode 100644 index 000000000000..dfcc3e7593aa --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_response.rb @@ -0,0 +1,135 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A single tag policy. + class TagPolicyResponse + include BaseGenericModel + + # A tag policy resource. + attr_reader :data + + # Related resources fetched alongside the primary tag policies. Populated when an `include` query parameter is supplied. + attr_accessor :included + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'included' => :'included' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'TagPolicyData', + :'included' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + + if attributes.key?(:'included') + if (value = attributes[:'included']).is_a?(Array) + self.included = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + included == o.included && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, included, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_score_attributes.rb b/lib/datadog_api_client/v2/models/tag_policy_score_attributes.rb new file mode 100644 index 000000000000..34c02aaa2ad6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_score_attributes.rb @@ -0,0 +1,184 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Attributes of a tag policy compliance score. + class TagPolicyScoreAttributes + include BaseGenericModel + + # The compliance score for the policy over the requested time window, as a percentage + # between 0 and 100. `null` indicates that no relevant telemetry was found. + attr_accessor :score + + # End of the time window the score was computed over, as a Unix timestamp in milliseconds. + attr_reader :ts_end + + # Start of the time window the score was computed over, as a Unix timestamp in milliseconds. + attr_reader :ts_start + + # The version of the tag policy that the score was computed against. + attr_reader :version + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'score' => :'score', + :'ts_end' => :'ts_end', + :'ts_start' => :'ts_start', + :'version' => :'version' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'score' => :'Float', + :'ts_end' => :'Integer', + :'ts_start' => :'Integer', + :'version' => :'Integer' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'score', + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyScoreAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'score') + self.score = attributes[:'score'] + end + + if attributes.key?(:'ts_end') + self.ts_end = attributes[:'ts_end'] + end + + if attributes.key?(:'ts_start') + self.ts_start = attributes[:'ts_start'] + end + + if attributes.key?(:'version') + self.version = attributes[:'version'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @ts_end.nil? + return false if @ts_start.nil? + return false if @version.nil? + true + end + + # Custom attribute writer method with validation + # @param ts_end [Object] Object to be assigned + # @!visibility private + def ts_end=(ts_end) + if ts_end.nil? + fail ArgumentError, 'invalid value for "ts_end", ts_end cannot be nil.' + end + @ts_end = ts_end + end + + # Custom attribute writer method with validation + # @param ts_start [Object] Object to be assigned + # @!visibility private + def ts_start=(ts_start) + if ts_start.nil? + fail ArgumentError, 'invalid value for "ts_start", ts_start cannot be nil.' + end + @ts_start = ts_start + end + + # Custom attribute writer method with validation + # @param version [Object] Object to be assigned + # @!visibility private + def version=(version) + if version.nil? + fail ArgumentError, 'invalid value for "version", version cannot be nil.' + end + @version = version + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + score == o.score && + ts_end == o.ts_end && + ts_start == o.ts_start && + version == o.version && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [score, ts_end, ts_start, version, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_score_data.rb b/lib/datadog_api_client/v2/models/tag_policy_score_data.rb new file mode 100644 index 000000000000..ba9765bcbb59 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_score_data.rb @@ -0,0 +1,165 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A compliance score resource for a tag policy. + class TagPolicyScoreData + include BaseGenericModel + + # Attributes of a tag policy compliance score. + attr_reader :attributes + + # The unique identifier of the compliance score resource. + attr_reader :id + + # JSON:API resource type for a tag policy compliance score. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'TagPolicyScoreAttributes', + :'id' => :'String', + :'type' => :'TagPolicyScoreResourceType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyScoreData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_score_relationship.rb b/lib/datadog_api_client/v2/models/tag_policy_score_relationship.rb new file mode 100644 index 000000000000..a0f0153eb7d5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_score_relationship.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A relationship to the compliance score resource for this policy. + class TagPolicyScoreRelationship + include BaseGenericModel + + # Identifier of the related compliance score resource. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'TagPolicyScoreRelationshipData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyScoreRelationship` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_score_relationship_data.rb b/lib/datadog_api_client/v2/models/tag_policy_score_relationship_data.rb new file mode 100644 index 000000000000..d1ce4536c666 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_score_relationship_data.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Identifier of the related compliance score resource. + class TagPolicyScoreRelationshipData + include BaseGenericModel + + # The unique identifier of the related compliance score resource. + attr_reader :id + + # JSON:API resource type for a tag policy compliance score. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'id' => :'String', + :'type' => :'TagPolicyScoreResourceType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyScoreRelationshipData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_score_resource_type.rb b/lib/datadog_api_client/v2/models/tag_policy_score_resource_type.rb new file mode 100644 index 000000000000..4185e47b90af --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_score_resource_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # JSON:API resource type for a tag policy compliance score. + class TagPolicyScoreResourceType + include BaseEnumModel + + TAG_POLICY_SCORE = "tag_policy_score".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_score_response.rb b/lib/datadog_api_client/v2/models/tag_policy_score_response.rb new file mode 100644 index 000000000000..20be7e49217f --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_score_response.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A tag policy compliance score. + class TagPolicyScoreResponse + include BaseGenericModel + + # A compliance score resource for a tag policy. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'TagPolicyScoreData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyScoreResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_source.rb b/lib/datadog_api_client/v2/models/tag_policy_source.rb new file mode 100644 index 000000000000..142a261a8db6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_source.rb @@ -0,0 +1,30 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The telemetry source that a tag policy applies to. + class TagPolicySource + include BaseEnumModel + + LOGS = "logs".freeze + SPANS = "spans".freeze + METRICS = "metrics".freeze + RUM = "rum".freeze + FEED = "feed".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_type.rb b/lib/datadog_api_client/v2/models/tag_policy_type.rb new file mode 100644 index 000000000000..11a94f3b4a8f --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_type.rb @@ -0,0 +1,28 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # How the policy is enforced. `blocking` rejects telemetry that violates the policy. + # `surfacing` only highlights non-compliant telemetry without blocking it. + class TagPolicyType + include BaseEnumModel + + BLOCKING = "blocking".freeze + SURFACING = "surfacing".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_update_attributes.rb b/lib/datadog_api_client/v2/models/tag_policy_update_attributes.rb new file mode 100644 index 000000000000..882b6a469486 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_update_attributes.rb @@ -0,0 +1,179 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Mutable attributes of a tag policy. Each field is optional; omitting a field leaves its + # current value unchanged. The `source` of a policy cannot be changed. + class TagPolicyUpdateAttributes + include BaseGenericModel + + # Whether the policy is currently enforced. + attr_accessor :enabled + + # When `true`, the policy matches tag values that do NOT match any of the supplied patterns. + attr_accessor :negated + + # Human-readable name for the tag policy. + attr_accessor :policy_name + + # How the policy is enforced. `blocking` rejects telemetry that violates the policy. + # `surfacing` only highlights non-compliant telemetry without blocking it. + attr_accessor :policy_type + + # When `true`, telemetry without this tag is treated as a violation. + attr_accessor :required + + # The scope the policy applies within. + attr_accessor :scope + + # The tag key that the policy governs. + attr_accessor :tag_key + + # One or more patterns that valid values for the tag key must match. + attr_accessor :tag_value_patterns + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'enabled' => :'enabled', + :'negated' => :'negated', + :'policy_name' => :'policy_name', + :'policy_type' => :'policy_type', + :'required' => :'required', + :'scope' => :'scope', + :'tag_key' => :'tag_key', + :'tag_value_patterns' => :'tag_value_patterns' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'enabled' => :'Boolean', + :'negated' => :'Boolean', + :'policy_name' => :'String', + :'policy_type' => :'TagPolicyType', + :'required' => :'Boolean', + :'scope' => :'String', + :'tag_key' => :'String', + :'tag_value_patterns' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyUpdateAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'enabled') + self.enabled = attributes[:'enabled'] + end + + if attributes.key?(:'negated') + self.negated = attributes[:'negated'] + end + + if attributes.key?(:'policy_name') + self.policy_name = attributes[:'policy_name'] + end + + if attributes.key?(:'policy_type') + self.policy_type = attributes[:'policy_type'] + end + + if attributes.key?(:'required') + self.required = attributes[:'required'] + end + + if attributes.key?(:'scope') + self.scope = attributes[:'scope'] + end + + if attributes.key?(:'tag_key') + self.tag_key = attributes[:'tag_key'] + end + + if attributes.key?(:'tag_value_patterns') + if (value = attributes[:'tag_value_patterns']).is_a?(Array) + self.tag_value_patterns = value + end + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + enabled == o.enabled && + negated == o.negated && + policy_name == o.policy_name && + policy_type == o.policy_type && + required == o.required && + scope == o.scope && + tag_key == o.tag_key && + tag_value_patterns == o.tag_value_patterns && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [enabled, negated, policy_name, policy_type, required, scope, tag_key, tag_value_patterns, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_update_data.rb b/lib/datadog_api_client/v2/models/tag_policy_update_data.rb new file mode 100644 index 000000000000..a0bc2be1c418 --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_update_data.rb @@ -0,0 +1,155 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Data object for updating a tag policy. + class TagPolicyUpdateData + include BaseGenericModel + + # Mutable attributes of a tag policy. Each field is optional; omitting a field leaves its + # current value unchanged. The `source` of a policy cannot be changed. + attr_accessor :attributes + + # The unique identifier of the tag policy being updated. + attr_reader :id + + # JSON:API resource type for a tag policy. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'TagPolicyUpdateAttributes', + :'id' => :'String', + :'type' => :'TagPolicyResourceType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyUpdateData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/tag_policy_update_request.rb b/lib/datadog_api_client/v2/models/tag_policy_update_request.rb new file mode 100644 index 000000000000..d1c26e48a10c --- /dev/null +++ b/lib/datadog_api_client/v2/models/tag_policy_update_request.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Payload for updating an existing tag policy. Only the supplied fields are modified. + class TagPolicyUpdateRequest + include BaseGenericModel + + # Data object for updating a tag policy. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'TagPolicyUpdateData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::TagPolicyUpdateRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end