diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index f11972d91d04..b44183d9885f 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -5064,6 +5064,20 @@ components: type: string x-enum-varnames: - ARBITRARY_RULE + Argument: + properties: + description: + description: Base64-encoded argument description + example: YXJndW1lbnQgZGVzY3JpcHRpb24= + type: string + name: + description: Base64-encoded argument name + example: YXJndW1lbnRfbmFtZQ== + type: string + required: + - name + - description + type: object AsanaAccessToken: description: The definition of the `AsanaAccessToken` object. properties: @@ -15879,6 +15893,482 @@ components: - version - name type: object + CustomRule: + properties: + created_at: + description: Creation timestamp + example: '2026-01-09T13:00:57.473141Z' + format: date-time + type: string + created_by: + description: Creator identifier + example: foobarbaz + type: string + last_revision: + $ref: '#/components/schemas/CustomRuleRevision' + description: Most recent revision + nullable: true + name: + description: Rule name + example: my-rule + type: string + required: + - name + - created_at + - created_by + - last_revision + type: object + CustomRuleDataType: + description: Resource type + enum: + - custom_rule + example: custom_rule + type: string + x-enum-varnames: + - CUSTOM_RULE + CustomRuleRequest: + properties: + data: + $ref: '#/components/schemas/CustomRuleRequestData' + type: object + CustomRuleRequestData: + properties: + attributes: + $ref: '#/components/schemas/CustomRuleRequestDataAttributes' + id: + description: Rule identifier + type: string + type: + $ref: '#/components/schemas/CustomRuleDataType' + type: object + CustomRuleRequestDataAttributes: + properties: + name: + description: Rule name + type: string + type: object + CustomRuleResponse: + properties: + data: + $ref: '#/components/schemas/CustomRuleResponseData' + required: + - data + type: object + CustomRuleResponseData: + properties: + attributes: + $ref: '#/components/schemas/CustomRule' + id: + description: Rule identifier + example: my-rule + type: string + type: + $ref: '#/components/schemas/CustomRuleDataType' + required: + - id + - type + - attributes + type: object + CustomRuleRevision: + properties: + attributes: + $ref: '#/components/schemas/CustomRuleRevisionAttributes' + id: + description: Revision identifier + example: revision-123 + type: string + type: + $ref: '#/components/schemas/CustomRuleRevisionDataType' + required: + - id + - type + - attributes + type: object + CustomRuleRevisionAttributes: + properties: + arguments: + description: Rule arguments + items: + $ref: '#/components/schemas/Argument' + type: array + category: + $ref: '#/components/schemas/CustomRuleRevisionAttributesCategory' + checksum: + description: Code checksum + example: 8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99 + type: string + code: + description: Rule code + example: Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ== + type: string + created_at: + description: Creation timestamp + example: '2026-01-09T13:00:57.473141Z' + format: date-time + type: string + created_by: + description: Creator identifier + example: foobarbaz + type: string + creation_message: + description: Revision creation message + example: Initial revision + type: string + cve: + description: Associated CVE + example: CVE-2024-1234 + nullable: true + type: string + cwe: + description: Associated CWE + example: CWE-79 + nullable: true + type: string + description: + description: Full description + example: bG9uZyBkZXNjcmlwdGlvbg== + type: string + documentation_url: + description: Documentation URL + example: https://docs.example.com/rules/my-rule + nullable: true + type: string + is_published: + description: Whether the revision is published + example: false + type: boolean + is_testing: + description: Whether this is a testing revision + example: false + type: boolean + language: + $ref: '#/components/schemas/Language' + severity: + $ref: '#/components/schemas/CustomRuleRevisionAttributesSeverity' + short_description: + description: Short description + example: c2hvcnQgZGVzY3JpcHRpb24= + type: string + should_use_ai_fix: + description: Whether to use AI for fixes + example: false + type: boolean + tags: + description: Rule tags + example: + - security + - custom + items: + type: string + type: array + tests: + description: Rule tests + items: + $ref: '#/components/schemas/CustomRuleRevisionTest' + type: array + tree_sitter_query: + description: Tree-sitter query + example: Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ== + type: string + required: + - creation_message + - short_description + - description + - code + - checksum + - language + - tree_sitter_query + - created_at + - created_by + - severity + - category + - cve + - cwe + - arguments + - tests + - tags + - is_published + - should_use_ai_fix + - documentation_url + - is_testing + type: object + CustomRuleRevisionAttributesCategory: + description: Rule category + enum: + - SECURITY + - BEST_PRACTICES + - CODE_STYLE + - ERROR_PRONE + - PERFORMANCE + example: SECURITY + type: string + x-enum-varnames: + - SECURITY + - BEST_PRACTICES + - CODE_STYLE + - ERROR_PRONE + - PERFORMANCE + CustomRuleRevisionAttributesSeverity: + description: Rule severity + enum: + - ERROR + - WARNING + - NOTICE + example: ERROR + type: string + x-enum-varnames: + - ERROR + - WARNING + - NOTICE + CustomRuleRevisionDataType: + description: Resource type + enum: + - custom_rule_revision + example: custom_rule_revision + type: string + x-enum-varnames: + - CUSTOM_RULE_REVISION + CustomRuleRevisionInputAttributes: + properties: + arguments: + description: Rule arguments + items: + $ref: '#/components/schemas/Argument' + type: array + category: + $ref: '#/components/schemas/CustomRuleRevisionAttributesCategory' + code: + description: Rule code + example: Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ== + type: string + creation_message: + description: Revision creation message + example: Initial revision + type: string + cve: + description: Associated CVE + example: CVE-2024-1234 + nullable: true + type: string + cwe: + description: Associated CWE + example: CWE-79 + nullable: true + type: string + description: + description: Full description + example: bG9uZyBkZXNjcmlwdGlvbg== + type: string + documentation_url: + description: Documentation URL + example: https://docs.example.com/rules/my-rule + nullable: true + type: string + is_published: + description: Whether the revision is published + example: false + type: boolean + is_testing: + description: Whether this is a testing revision + example: false + type: boolean + language: + $ref: '#/components/schemas/Language' + severity: + $ref: '#/components/schemas/CustomRuleRevisionAttributesSeverity' + short_description: + description: Short description + example: c2hvcnQgZGVzY3JpcHRpb24= + type: string + should_use_ai_fix: + description: Whether to use AI for fixes + example: false + type: boolean + tags: + description: Rule tags + example: + - security + - custom + items: + type: string + type: array + tests: + description: Rule tests + items: + $ref: '#/components/schemas/CustomRuleRevisionTest' + type: array + tree_sitter_query: + description: Tree-sitter query + example: Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ== + type: string + required: + - creation_message + - short_description + - description + - code + - language + - tree_sitter_query + - severity + - category + - cve + - cwe + - arguments + - tests + - tags + - is_published + - should_use_ai_fix + - documentation_url + - is_testing + type: object + CustomRuleRevisionRequest: + properties: + data: + $ref: '#/components/schemas/CustomRuleRevisionRequestData' + type: object + CustomRuleRevisionRequestData: + properties: + attributes: + $ref: '#/components/schemas/CustomRuleRevisionInputAttributes' + id: + description: Revision identifier + type: string + type: + $ref: '#/components/schemas/CustomRuleRevisionDataType' + type: object + CustomRuleRevisionResponse: + properties: + data: + $ref: '#/components/schemas/CustomRuleRevision' + required: + - data + type: object + CustomRuleRevisionTest: + properties: + annotation_count: + description: Expected violation count + example: 1 + format: int64 + type: integer + code: + description: Test code + example: Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ== + type: string + filename: + description: Test filename + example: test.yaml + type: string + required: + - filename + - code + - annotation_count + type: object + CustomRuleRevisionsResponse: + properties: + data: + items: + $ref: '#/components/schemas/CustomRuleRevision' + type: array + type: object + CustomRuleset: + properties: + attributes: + $ref: '#/components/schemas/CustomRulesetAttributes' + id: + description: Ruleset identifier + example: my-ruleset + type: string + type: + $ref: '#/components/schemas/CustomRulesetDataType' + required: + - id + - type + - attributes + type: object + CustomRulesetAttributes: + properties: + created_at: + description: Creation timestamp + example: '2026-01-09T13:00:57.473141Z' + format: date-time + type: string + created_by: + description: Creator identifier + example: foobarbaz + type: string + description: + description: Base64-encoded full description + example: bG9uZyBkZXNjcmlwdGlvbg== + type: string + name: + description: Ruleset name + example: my-ruleset + type: string + rules: + description: Rules in the ruleset + items: + $ref: '#/components/schemas/CustomRule' + nullable: true + type: array + short_description: + description: Base64-encoded short description + example: c2hvcnQgZGVzY3JpcHRpb24= + type: string + required: + - name + - short_description + - description + - created_at + - created_by + - rules + type: object + CustomRulesetDataType: + description: Resource type + enum: + - custom_ruleset + example: custom_ruleset + type: string + x-enum-varnames: + - CUSTOM_RULESET + CustomRulesetRequest: + properties: + data: + $ref: '#/components/schemas/CustomRulesetRequestData' + type: object + CustomRulesetRequestData: + properties: + attributes: + $ref: '#/components/schemas/CustomRulesetRequestDataAttributes' + id: + description: Ruleset identifier + type: string + type: + $ref: '#/components/schemas/CustomRulesetDataType' + type: object + CustomRulesetRequestDataAttributes: + properties: + description: + description: Base64-encoded full description + type: string + name: + description: Ruleset name + type: string + rules: + description: Rules in the ruleset + items: + $ref: '#/components/schemas/CustomRule' + nullable: true + type: array + short_description: + description: Base64-encoded short description + type: string + type: object + CustomRulesetResponse: + properties: + data: + $ref: '#/components/schemas/CustomRuleset' + required: + - data + type: object DORACustomTags: description: A list of user-defined tags. The tags must follow the `key:value` pattern. Up to 100 may be added per event. @@ -30058,6 +30548,34 @@ components: format: int64 type: integer type: object + Language: + description: Programming language + enum: + - PYTHON + - JAVASCRIPT + - TYPESCRIPT + - JAVA + - GO + - YAML + - RUBY + - CSHARP + - PHP + - KOTLIN + - SWIFT + example: PYTHON + type: string + x-enum-varnames: + - PYTHON + - JAVASCRIPT + - TYPESCRIPT + - JAVA + - GO + - YAML + - RUBY + - CSHARP + - PHP + - KOTLIN + - SWIFT LaunchDarklyAPIKey: description: The definition of the `LaunchDarklyAPIKey` object. properties: @@ -45480,6 +45998,37 @@ components: - interval - maxRetries type: object + RevertCustomRuleRevisionDataType: + description: Request type + enum: + - revert_custom_rule_revision_request + type: string + x-enum-varnames: + - REVERT_CUSTOM_RULE_REVISION_REQUEST + RevertCustomRuleRevisionRequest: + properties: + data: + $ref: '#/components/schemas/RevertCustomRuleRevisionRequestData' + type: object + RevertCustomRuleRevisionRequestData: + properties: + attributes: + $ref: '#/components/schemas/RevertCustomRuleRevisionRequestDataAttributes' + id: + description: Request identifier + type: string + type: + $ref: '#/components/schemas/RevertCustomRuleRevisionDataType' + type: object + RevertCustomRuleRevisionRequestDataAttributes: + properties: + currentRevision: + description: Current revision ID + type: string + revertToRevision: + description: Target revision ID to revert to + type: string + type: object Role: description: Role object returned by the API. properties: @@ -88424,6 +88973,514 @@ paths: tags: - Static Analysis x-unstable: '**Note**: This endpoint may be subject to changes.' + /api/v2/static-analysis/custom/rulesets/{ruleset_name}: + delete: + description: Delete a custom ruleset + operationId: DeleteCustomRuleset + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + responses: + '200': + description: Successfully deleted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Ruleset not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete Custom Ruleset + tags: + - Static Analysis + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Get a custom ruleset by name + operationId: GetCustomRuleset + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomRulesetResponse' + description: Successful response + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Ruleset not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Show Custom Ruleset + tags: + - Static Analysis + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: Update an existing custom ruleset + operationId: UpdateCustomRuleset + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CustomRulesetRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomRulesetResponse' + description: Successfully updated + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '412': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Precondition failed - validation error or ruleset not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update Custom Ruleset + tags: + - Static Analysis + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules: + put: + description: Create a new custom rule within a ruleset + operationId: CreateCustomRule + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CustomRuleRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomRuleResponse' + description: Successfully created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '409': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Conflict - rule already exists + '412': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Precondition failed - validation error or ruleset not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create Custom Rule + tags: + - Static Analysis + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}: + delete: + description: Delete a custom rule + operationId: DeleteCustomRule + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + - description: The rule name + in: path + name: rule_name + required: true + schema: + type: string + responses: + '200': + description: Successfully deleted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Rule not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete Custom Rule + tags: + - Static Analysis + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Get a custom rule by name + operationId: GetCustomRule + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + - description: The rule name + in: path + name: rule_name + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomRuleResponse' + description: Successful response + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Rule not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Show Custom Rule + tags: + - Static Analysis + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions: + get: + description: Get all revisions for a custom rule + operationId: ListCustomRuleRevisions + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + - description: The rule name + in: path + name: rule_name + required: true + schema: + type: string + - description: Pagination offset + in: query + name: page[offset] + required: false + schema: + default: 0 + type: integer + - description: Pagination limit + in: query + name: page[limit] + required: false + schema: + default: 10 + type: integer + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomRuleRevisionsResponse' + description: Successful response + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Rule not found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Too many requests + summary: List Custom Rule Revisions + tags: + - Static Analysis + x-pagination: + limitParam: page[limit] + pageOffsetParam: page[offset] + resultsPath: data + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + put: + description: Create a new revision for a custom rule + operationId: CreateCustomRuleRevision + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + - description: The rule name + in: path + name: rule_name + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CustomRuleRevisionRequest' + required: true + responses: + '200': + description: Successfully created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Rule not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create Custom Rule Revision + tags: + - Static Analysis + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions/revert: + post: + description: Revert a custom rule to a previous revision + operationId: RevertCustomRuleRevision + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + - description: The rule name + in: path + name: rule_name + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RevertCustomRuleRevisionRequest' + required: true + responses: + '200': + description: Successfully reverted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Revert Custom Rule Revision + tags: + - Static Analysis + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions/{id}: + get: + description: Get a specific revision of a custom rule + operationId: GetCustomRuleRevision + parameters: + - description: The ruleset name + in: path + name: ruleset_name + required: true + schema: + type: string + - description: The rule name + in: path + name: rule_name + required: true + schema: + type: string + - description: The revision ID + in: path + name: id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/CustomRuleRevisionResponse' + description: Successful response + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '401': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Unauthorized - custom rules not enabled + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Revision not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Show Custom Rule Revision + tags: + - Static Analysis + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/static-analysis/rulesets: post: description: Get rules for multiple rulesets in batch. diff --git a/examples/v2/static-analysis/CreateCustomRule.rb b/examples/v2/static-analysis/CreateCustomRule.rb new file mode 100644 index 000000000000..3b086526dc5c --- /dev/null +++ b/examples/v2/static-analysis/CreateCustomRule.rb @@ -0,0 +1,15 @@ +# Create Custom Rule returns "Successfully created" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.create_custom_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new + +body = DatadogAPIClient::V2::CustomRuleRequest.new({ + data: DatadogAPIClient::V2::CustomRuleRequestData.new({ + attributes: DatadogAPIClient::V2::CustomRuleRequestDataAttributes.new({}), + type: DatadogAPIClient::V2::CustomRuleDataType::CUSTOM_RULE, + }), +}) +p api_instance.create_custom_rule("ruleset_name", body) diff --git a/examples/v2/static-analysis/CreateCustomRuleRevision.rb b/examples/v2/static-analysis/CreateCustomRuleRevision.rb new file mode 100644 index 000000000000..5d543c0bb9b2 --- /dev/null +++ b/examples/v2/static-analysis/CreateCustomRuleRevision.rb @@ -0,0 +1,47 @@ +# Create Custom Rule Revision returns "Successfully created" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.create_custom_rule_revision".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new + +body = DatadogAPIClient::V2::CustomRuleRevisionRequest.new({ + data: DatadogAPIClient::V2::CustomRuleRevisionRequestData.new({ + attributes: DatadogAPIClient::V2::CustomRuleRevisionInputAttributes.new({ + arguments: [ + DatadogAPIClient::V2::Argument.new({ + description: "YXJndW1lbnQgZGVzY3JpcHRpb24=", + name: "YXJndW1lbnRfbmFtZQ==", + }), + ], + category: DatadogAPIClient::V2::CustomRuleRevisionAttributesCategory::SECURITY, + code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", + creation_message: "Initial revision", + cve: "CVE-2024-1234", + cwe: "CWE-79", + description: "bG9uZyBkZXNjcmlwdGlvbg==", + documentation_url: "https://docs.example.com/rules/my-rule", + is_published: false, + is_testing: false, + language: DatadogAPIClient::V2::Language::PYTHON, + severity: DatadogAPIClient::V2::CustomRuleRevisionAttributesSeverity::ERROR, + short_description: "c2hvcnQgZGVzY3JpcHRpb24=", + should_use_ai_fix: false, + tags: [ + "security", + "custom", + ], + tests: [ + DatadogAPIClient::V2::CustomRuleRevisionTest.new({ + annotation_count: 1, + code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", + filename: "test.yaml", + }), + ], + tree_sitter_query: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", + }), + type: DatadogAPIClient::V2::CustomRuleRevisionDataType::CUSTOM_RULE_REVISION, + }), +}) +p api_instance.create_custom_rule_revision("ruleset_name", "rule_name", body) diff --git a/examples/v2/static-analysis/DeleteCustomRule.rb b/examples/v2/static-analysis/DeleteCustomRule.rb new file mode 100644 index 000000000000..99e337343a70 --- /dev/null +++ b/examples/v2/static-analysis/DeleteCustomRule.rb @@ -0,0 +1,8 @@ +# Delete Custom Rule returns "Successfully deleted" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.delete_custom_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new +p api_instance.delete_custom_rule("ruleset_name", "rule_name") diff --git a/examples/v2/static-analysis/DeleteCustomRuleset.rb b/examples/v2/static-analysis/DeleteCustomRuleset.rb new file mode 100644 index 000000000000..d072a10f5176 --- /dev/null +++ b/examples/v2/static-analysis/DeleteCustomRuleset.rb @@ -0,0 +1,8 @@ +# Delete Custom Ruleset returns "Successfully deleted" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.delete_custom_ruleset".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new +p api_instance.delete_custom_ruleset("ruleset_name") diff --git a/examples/v2/static-analysis/GetCustomRule.rb b/examples/v2/static-analysis/GetCustomRule.rb new file mode 100644 index 000000000000..69b19fef6d05 --- /dev/null +++ b/examples/v2/static-analysis/GetCustomRule.rb @@ -0,0 +1,8 @@ +# Show Custom Rule returns "Successful response" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_custom_rule".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new +p api_instance.get_custom_rule("ruleset_name", "rule_name") diff --git a/examples/v2/static-analysis/GetCustomRuleRevision.rb b/examples/v2/static-analysis/GetCustomRuleRevision.rb new file mode 100644 index 000000000000..83eb11d7bf6a --- /dev/null +++ b/examples/v2/static-analysis/GetCustomRuleRevision.rb @@ -0,0 +1,8 @@ +# Show Custom Rule Revision returns "Successful response" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_custom_rule_revision".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new +p api_instance.get_custom_rule_revision("ruleset_name", "rule_name", "id") diff --git a/examples/v2/static-analysis/GetCustomRuleset.rb b/examples/v2/static-analysis/GetCustomRuleset.rb new file mode 100644 index 000000000000..9e75051a0169 --- /dev/null +++ b/examples/v2/static-analysis/GetCustomRuleset.rb @@ -0,0 +1,8 @@ +# Show Custom Ruleset returns "Successful response" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_custom_ruleset".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new +p api_instance.get_custom_ruleset("ruleset_name") diff --git a/examples/v2/static-analysis/ListCustomRuleRevisions.rb b/examples/v2/static-analysis/ListCustomRuleRevisions.rb new file mode 100644 index 000000000000..d06bb6ea73ca --- /dev/null +++ b/examples/v2/static-analysis/ListCustomRuleRevisions.rb @@ -0,0 +1,8 @@ +# List Custom Rule Revisions returns "Successful response" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.list_custom_rule_revisions".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new +p api_instance.list_custom_rule_revisions("ruleset_name", "rule_name") diff --git a/examples/v2/static-analysis/ListCustomRuleRevisions_3739033293.rb b/examples/v2/static-analysis/ListCustomRuleRevisions_3739033293.rb new file mode 100644 index 000000000000..9a6d317bbd9d --- /dev/null +++ b/examples/v2/static-analysis/ListCustomRuleRevisions_3739033293.rb @@ -0,0 +1,8 @@ +# List Custom Rule Revisions returns "Successful response" response with pagination + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.list_custom_rule_revisions".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new +api_instance.list_custom_rule_revisions_with_pagination("ruleset_name", "rule_name") { |item| puts item } diff --git a/examples/v2/static-analysis/RevertCustomRuleRevision.rb b/examples/v2/static-analysis/RevertCustomRuleRevision.rb new file mode 100644 index 000000000000..e3b43dbd97f0 --- /dev/null +++ b/examples/v2/static-analysis/RevertCustomRuleRevision.rb @@ -0,0 +1,15 @@ +# Revert Custom Rule Revision returns "Successfully reverted" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.revert_custom_rule_revision".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new + +body = DatadogAPIClient::V2::RevertCustomRuleRevisionRequest.new({ + data: DatadogAPIClient::V2::RevertCustomRuleRevisionRequestData.new({ + attributes: DatadogAPIClient::V2::RevertCustomRuleRevisionRequestDataAttributes.new({}), + type: DatadogAPIClient::V2::RevertCustomRuleRevisionDataType::REVERT_CUSTOM_RULE_REVISION_REQUEST, + }), +}) +p api_instance.revert_custom_rule_revision("ruleset_name", "rule_name", body) diff --git a/examples/v2/static-analysis/UpdateCustomRuleset.rb b/examples/v2/static-analysis/UpdateCustomRuleset.rb new file mode 100644 index 000000000000..7d8c74c2c846 --- /dev/null +++ b/examples/v2/static-analysis/UpdateCustomRuleset.rb @@ -0,0 +1,63 @@ +# Update Custom Ruleset returns "Successfully updated" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.update_custom_ruleset".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new + +body = DatadogAPIClient::V2::CustomRulesetRequest.new({ + data: DatadogAPIClient::V2::CustomRulesetRequestData.new({ + attributes: DatadogAPIClient::V2::CustomRulesetRequestDataAttributes.new({ + rules: [ + DatadogAPIClient::V2::CustomRule.new({ + created_at: "2026-01-09T13:00:57.473141Z", + created_by: "foobarbaz", + last_revision: DatadogAPIClient::V2::CustomRuleRevision.new({ + attributes: DatadogAPIClient::V2::CustomRuleRevisionAttributes.new({ + arguments: [ + DatadogAPIClient::V2::Argument.new({ + description: "YXJndW1lbnQgZGVzY3JpcHRpb24=", + name: "YXJndW1lbnRfbmFtZQ==", + }), + ], + category: DatadogAPIClient::V2::CustomRuleRevisionAttributesCategory::SECURITY, + checksum: "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99", + code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", + created_at: "2026-01-09T13:00:57.473141Z", + created_by: "foobarbaz", + creation_message: "Initial revision", + cve: "CVE-2024-1234", + cwe: "CWE-79", + description: "bG9uZyBkZXNjcmlwdGlvbg==", + documentation_url: "https://docs.example.com/rules/my-rule", + is_published: false, + is_testing: false, + language: DatadogAPIClient::V2::Language::PYTHON, + severity: DatadogAPIClient::V2::CustomRuleRevisionAttributesSeverity::ERROR, + short_description: "c2hvcnQgZGVzY3JpcHRpb24=", + should_use_ai_fix: false, + tags: [ + "security", + "custom", + ], + tests: [ + DatadogAPIClient::V2::CustomRuleRevisionTest.new({ + annotation_count: 1, + code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", + filename: "test.yaml", + }), + ], + tree_sitter_query: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", + }), + id: "revision-123", + type: DatadogAPIClient::V2::CustomRuleRevisionDataType::CUSTOM_RULE_REVISION, + }), + name: "my-rule", + }), + ], + }), + type: DatadogAPIClient::V2::CustomRulesetDataType::CUSTOM_RULESET, + }), +}) +p api_instance.update_custom_ruleset("ruleset_name", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 909e6202543f..a05eb9b804b5 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3259,6 +3259,49 @@ "v2.CreateSCAResolveVulnerableSymbols" => { "body" => "ResolveVulnerableSymbolsRequest", }, + "v2.DeleteCustomRuleset" => { + "ruleset_name" => "String", + }, + "v2.GetCustomRuleset" => { + "ruleset_name" => "String", + }, + "v2.UpdateCustomRuleset" => { + "ruleset_name" => "String", + "body" => "CustomRulesetRequest", + }, + "v2.CreateCustomRule" => { + "ruleset_name" => "String", + "body" => "CustomRuleRequest", + }, + "v2.DeleteCustomRule" => { + "ruleset_name" => "String", + "rule_name" => "String", + }, + "v2.GetCustomRule" => { + "ruleset_name" => "String", + "rule_name" => "String", + }, + "v2.ListCustomRuleRevisions" => { + "ruleset_name" => "String", + "rule_name" => "String", + "page_offset" => "Integer", + "page_limit" => "Integer", + }, + "v2.CreateCustomRuleRevision" => { + "ruleset_name" => "String", + "rule_name" => "String", + "body" => "CustomRuleRevisionRequest", + }, + "v2.RevertCustomRuleRevision" => { + "ruleset_name" => "String", + "rule_name" => "String", + "body" => "RevertCustomRuleRevisionRequest", + }, + "v2.GetCustomRuleRevision" => { + "ruleset_name" => "String", + "rule_name" => "String", + "id" => "String", + }, "v2.SetOnDemandConcurrencyCap" => { "body" => "OnDemandConcurrencyCapAttributes", }, diff --git a/features/v2/static_analysis.feature b/features/v2/static_analysis.feature index 85bf4d83ae13..879e8dca94ff 100644 --- a/features/v2/static_analysis.feature +++ b/features/v2/static_analysis.feature @@ -7,6 +7,159 @@ Feature: Static Analysis And a valid "appKeyAuth" key in the system And an instance of "StaticAnalysis" API + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Create Custom Rule Revision returns "Bad request" response + Given operation "CreateCustomRuleRevision" enabled + And new "CreateCustomRuleRevision" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"arguments": [{"description": "YXJndW1lbnQgZGVzY3JpcHRpb24=", "name": "YXJndW1lbnRfbmFtZQ=="}], "category": "SECURITY", "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "creation_message": "Initial revision", "cve": "CVE-2024-1234", "cwe": "CWE-79", "description": "bG9uZyBkZXNjcmlwdGlvbg==", "documentation_url": "https://docs.example.com/rules/my-rule", "is_published": false, "is_testing": false, "language": "PYTHON", "severity": "ERROR", "short_description": "c2hvcnQgZGVzY3JpcHRpb24=", "should_use_ai_fix": false, "tags": ["security", "custom"], "tests": [{"annotation_count": 1, "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "filename": "test.yaml"}], "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="}, "type": "custom_rule_revision"}} + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Create Custom Rule Revision returns "Rule not found" response + Given operation "CreateCustomRuleRevision" enabled + And new "CreateCustomRuleRevision" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"arguments": [{"description": "YXJndW1lbnQgZGVzY3JpcHRpb24=", "name": "YXJndW1lbnRfbmFtZQ=="}], "category": "SECURITY", "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "creation_message": "Initial revision", "cve": "CVE-2024-1234", "cwe": "CWE-79", "description": "bG9uZyBkZXNjcmlwdGlvbg==", "documentation_url": "https://docs.example.com/rules/my-rule", "is_published": false, "is_testing": false, "language": "PYTHON", "severity": "ERROR", "short_description": "c2hvcnQgZGVzY3JpcHRpb24=", "should_use_ai_fix": false, "tags": ["security", "custom"], "tests": [{"annotation_count": 1, "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "filename": "test.yaml"}], "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="}, "type": "custom_rule_revision"}} + When the request is sent + Then the response status is 404 Rule not found + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Create Custom Rule Revision returns "Successfully created" response + Given operation "CreateCustomRuleRevision" enabled + And new "CreateCustomRuleRevision" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"arguments": [{"description": "YXJndW1lbnQgZGVzY3JpcHRpb24=", "name": "YXJndW1lbnRfbmFtZQ=="}], "category": "SECURITY", "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "creation_message": "Initial revision", "cve": "CVE-2024-1234", "cwe": "CWE-79", "description": "bG9uZyBkZXNjcmlwdGlvbg==", "documentation_url": "https://docs.example.com/rules/my-rule", "is_published": false, "is_testing": false, "language": "PYTHON", "severity": "ERROR", "short_description": "c2hvcnQgZGVzY3JpcHRpb24=", "should_use_ai_fix": false, "tags": ["security", "custom"], "tests": [{"annotation_count": 1, "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "filename": "test.yaml"}], "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="}, "type": "custom_rule_revision"}} + When the request is sent + Then the response status is 200 Successfully created + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Create Custom Rule returns "Bad request" response + Given operation "CreateCustomRule" enabled + And new "CreateCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {}, "type": "custom_rule"}} + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Create Custom Rule returns "Conflict - rule already exists" response + Given operation "CreateCustomRule" enabled + And new "CreateCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {}, "type": "custom_rule"}} + When the request is sent + Then the response status is 409 Conflict - rule already exists + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Create Custom Rule returns "Precondition failed - validation error or ruleset not found" response + Given operation "CreateCustomRule" enabled + And new "CreateCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {}, "type": "custom_rule"}} + When the request is sent + Then the response status is 412 Precondition failed - validation error or ruleset not found + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Create Custom Rule returns "Successfully created" response + Given operation "CreateCustomRule" enabled + And new "CreateCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {}, "type": "custom_rule"}} + When the request is sent + Then the response status is 200 Successfully created + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Delete Custom Rule returns "Bad request" response + Given operation "DeleteCustomRule" enabled + And new "DeleteCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Delete Custom Rule returns "Rule not found" response + Given operation "DeleteCustomRule" enabled + And new "DeleteCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Rule not found + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Delete Custom Rule returns "Successfully deleted" response + Given operation "DeleteCustomRule" enabled + And new "DeleteCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 Successfully deleted + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Delete Custom Ruleset returns "Bad request" response + Given operation "DeleteCustomRuleset" enabled + And new "DeleteCustomRuleset" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Delete Custom Ruleset returns "Ruleset not found" response + Given operation "DeleteCustomRuleset" enabled + And new "DeleteCustomRuleset" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Ruleset not found + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Delete Custom Ruleset returns "Successfully deleted" response + Given operation "DeleteCustomRuleset" enabled + And new "DeleteCustomRuleset" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 Successfully deleted + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: List Custom Rule Revisions returns "Bad request" response + Given operation "ListCustomRuleRevisions" enabled + And new "ListCustomRuleRevisions" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: List Custom Rule Revisions returns "Rule not found" response + Given operation "ListCustomRuleRevisions" enabled + And new "ListCustomRuleRevisions" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Rule not found + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: List Custom Rule Revisions returns "Successful response" response + Given operation "ListCustomRuleRevisions" enabled + And new "ListCustomRuleRevisions" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 Successful response + + @generated @skip @team:DataDog/k9-vm-ast @with-pagination + Scenario: List Custom Rule Revisions returns "Successful response" response with pagination + Given operation "ListCustomRuleRevisions" enabled + And new "ListCustomRuleRevisions" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request with pagination is sent + Then the response status is 200 Successful response + @generated @skip @team:DataDog/k9-vm-sca Scenario: POST request to resolve vulnerable symbols returns "OK" response Given operation "CreateSCAResolveVulnerableSymbols" enabled @@ -22,3 +175,131 @@ Feature: Static Analysis And body with value {"data": {"attributes": {"commit": {}, "dependencies": [{"exclusions": [], "locations": [{"block": {"end": {}, "start": {}}, "name": {"end": {}, "start": {}}, "namespace": {"end": {}, "start": {}}, "version": {"end": {}, "start": {}}}], "reachable_symbol_properties": [{}]}], "files": [{}], "relations": [{"depends_on": []}], "repository": {}, "vulnerabilities": [{"affects": [{}]}]}, "type": "scarequests"}} When the request is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Revert Custom Rule Revision returns "Bad request" response + Given operation "RevertCustomRuleRevision" enabled + And new "RevertCustomRuleRevision" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {}, "type": "revert_custom_rule_revision_request"}} + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Revert Custom Rule Revision returns "Successfully reverted" response + Given operation "RevertCustomRuleRevision" enabled + And new "RevertCustomRuleRevision" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {}, "type": "revert_custom_rule_revision_request"}} + When the request is sent + Then the response status is 200 Successfully reverted + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Show Custom Rule Revision returns "Bad request" response + Given operation "GetCustomRuleRevision" enabled + And new "GetCustomRuleRevision" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Show Custom Rule Revision returns "Revision not found" response + Given operation "GetCustomRuleRevision" enabled + And new "GetCustomRuleRevision" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Revision not found + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Show Custom Rule Revision returns "Successful response" response + Given operation "GetCustomRuleRevision" enabled + And new "GetCustomRuleRevision" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 Successful response + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Show Custom Rule returns "Bad request" response + Given operation "GetCustomRule" enabled + And new "GetCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Show Custom Rule returns "Rule not found" response + Given operation "GetCustomRule" enabled + And new "GetCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Rule not found + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Show Custom Rule returns "Successful response" response + Given operation "GetCustomRule" enabled + And new "GetCustomRule" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And request contains "rule_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 Successful response + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Show Custom Ruleset returns "Bad request" response + Given operation "GetCustomRuleset" enabled + And new "GetCustomRuleset" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Show Custom Ruleset returns "Ruleset not found" response + Given operation "GetCustomRuleset" enabled + And new "GetCustomRuleset" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Ruleset not found + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Show Custom Ruleset returns "Successful response" response + Given operation "GetCustomRuleset" enabled + And new "GetCustomRuleset" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 Successful response + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Update Custom Ruleset returns "Bad request" response + Given operation "UpdateCustomRuleset" enabled + And new "UpdateCustomRuleset" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"rules": [{"created_at": "2026-01-09T13:00:57.473141Z", "created_by": "foobarbaz", "last_revision": {"attributes": {"arguments": [{"description": "YXJndW1lbnQgZGVzY3JpcHRpb24=", "name": "YXJndW1lbnRfbmFtZQ=="}], "category": "SECURITY", "checksum": "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99", "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "created_at": "2026-01-09T13:00:57.473141Z", "created_by": "foobarbaz", "creation_message": "Initial revision", "cve": "CVE-2024-1234", "cwe": "CWE-79", "description": "bG9uZyBkZXNjcmlwdGlvbg==", "documentation_url": "https://docs.example.com/rules/my-rule", "is_published": false, "is_testing": false, "language": "PYTHON", "severity": "ERROR", "short_description": "c2hvcnQgZGVzY3JpcHRpb24=", "should_use_ai_fix": false, "tags": ["security", "custom"], "tests": [{"annotation_count": 1, "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "filename": "test.yaml"}], "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="}, "id": "revision-123", "type": "custom_rule_revision"}, "name": "my-rule"}]}, "type": "custom_ruleset"}} + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Update Custom Ruleset returns "Precondition failed - validation error or ruleset not found" response + Given operation "UpdateCustomRuleset" enabled + And new "UpdateCustomRuleset" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"rules": [{"created_at": "2026-01-09T13:00:57.473141Z", "created_by": "foobarbaz", "last_revision": {"attributes": {"arguments": [{"description": "YXJndW1lbnQgZGVzY3JpcHRpb24=", "name": "YXJndW1lbnRfbmFtZQ=="}], "category": "SECURITY", "checksum": "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99", "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "created_at": "2026-01-09T13:00:57.473141Z", "created_by": "foobarbaz", "creation_message": "Initial revision", "cve": "CVE-2024-1234", "cwe": "CWE-79", "description": "bG9uZyBkZXNjcmlwdGlvbg==", "documentation_url": "https://docs.example.com/rules/my-rule", "is_published": false, "is_testing": false, "language": "PYTHON", "severity": "ERROR", "short_description": "c2hvcnQgZGVzY3JpcHRpb24=", "should_use_ai_fix": false, "tags": ["security", "custom"], "tests": [{"annotation_count": 1, "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "filename": "test.yaml"}], "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="}, "id": "revision-123", "type": "custom_rule_revision"}, "name": "my-rule"}]}, "type": "custom_ruleset"}} + When the request is sent + Then the response status is 412 Precondition failed - validation error or ruleset not found + + @generated @skip @team:DataDog/k9-vm-ast + Scenario: Update Custom Ruleset returns "Successfully updated" response + Given operation "UpdateCustomRuleset" enabled + And new "UpdateCustomRuleset" request + And request contains "ruleset_name" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"rules": [{"created_at": "2026-01-09T13:00:57.473141Z", "created_by": "foobarbaz", "last_revision": {"attributes": {"arguments": [{"description": "YXJndW1lbnQgZGVzY3JpcHRpb24=", "name": "YXJndW1lbnRfbmFtZQ=="}], "category": "SECURITY", "checksum": "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99", "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "created_at": "2026-01-09T13:00:57.473141Z", "created_by": "foobarbaz", "creation_message": "Initial revision", "cve": "CVE-2024-1234", "cwe": "CWE-79", "description": "bG9uZyBkZXNjcmlwdGlvbg==", "documentation_url": "https://docs.example.com/rules/my-rule", "is_published": false, "is_testing": false, "language": "PYTHON", "severity": "ERROR", "short_description": "c2hvcnQgZGVzY3JpcHRpb24=", "should_use_ai_fix": false, "tags": ["security", "custom"], "tests": [{"annotation_count": 1, "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==", "filename": "test.yaml"}], "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="}, "id": "revision-123", "type": "custom_rule_revision"}, "name": "my-rule"}]}, "type": "custom_ruleset"}} + When the request is sent + Then the response status is 200 Successfully updated diff --git a/features/v2/undo.json b/features/v2/undo.json index 421fd8933730..a8d6aa9aa35d 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -4563,6 +4563,68 @@ "type": "safe" } }, + "DeleteCustomRuleset": { + "tag": "Static Analysis", + "undo": { + "type": "idempotent" + } + }, + "GetCustomRuleset": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, + "UpdateCustomRuleset": { + "tag": "Static Analysis", + "undo": { + "type": "idempotent" + } + }, + "CreateCustomRule": { + "tag": "Static Analysis", + "undo": { + "type": "idempotent" + } + }, + "DeleteCustomRule": { + "tag": "Static Analysis", + "undo": { + "type": "idempotent" + } + }, + "GetCustomRule": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, + "ListCustomRuleRevisions": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, + "CreateCustomRuleRevision": { + "tag": "Static Analysis", + "undo": { + "type": "idempotent" + } + }, + "RevertCustomRuleRevision": { + "tag": "Static Analysis", + "undo": { + "operationId": "TODO", + "parameters": [], + "type": "unsafe" + } + }, + "GetCustomRuleRevision": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, "ListMultipleRulesets": { "tag": "Security Monitoring", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index cdd2bdf2c018..d41d14934ccd 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -335,8 +335,18 @@ def initialize "v2.get_slo_report_job_status": false, "v2.get_spa_recommendations": false, "v2.get_spa_recommendations_with_shard": false, + "v2.create_custom_rule": false, + "v2.create_custom_rule_revision": false, "v2.create_sca_resolve_vulnerable_symbols": false, "v2.create_sca_result": false, + "v2.delete_custom_rule": false, + "v2.delete_custom_ruleset": false, + "v2.get_custom_rule": false, + "v2.get_custom_rule_revision": false, + "v2.get_custom_ruleset": false, + "v2.list_custom_rule_revisions": false, + "v2.revert_custom_rule_revision": false, + "v2.update_custom_ruleset": 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 5cfdf83ee17c..d484a384e226 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1137,6 +1137,7 @@ def overrides "v2.arbitrary_rule_response_data_attributes_strategy_based_on_costs_items" => "ArbitraryRuleResponseDataAttributesStrategyBasedOnCostsItems", "v2.arbitrary_rule_response_data_attributes_strategy_evaluate_grouped_by_filters_items" => "ArbitraryRuleResponseDataAttributesStrategyEvaluateGroupedByFiltersItems", "v2.arbitrary_rule_response_data_type" => "ArbitraryRuleResponseDataType", + "v2.argument" => "Argument", "v2.asana_access_token" => "AsanaAccessToken", "v2.asana_access_token_type" => "AsanaAccessTokenType", "v2.asana_access_token_update" => "AsanaAccessTokenUpdate", @@ -1899,6 +1900,31 @@ def overrides "v2.custom_framework_requirement" => "CustomFrameworkRequirement", "v2.custom_framework_type" => "CustomFrameworkType", "v2.custom_framework_without_requirements" => "CustomFrameworkWithoutRequirements", + "v2.custom_rule" => "CustomRule", + "v2.custom_rule_data_type" => "CustomRuleDataType", + "v2.custom_rule_request" => "CustomRuleRequest", + "v2.custom_rule_request_data" => "CustomRuleRequestData", + "v2.custom_rule_request_data_attributes" => "CustomRuleRequestDataAttributes", + "v2.custom_rule_response" => "CustomRuleResponse", + "v2.custom_rule_response_data" => "CustomRuleResponseData", + "v2.custom_rule_revision" => "CustomRuleRevision", + "v2.custom_rule_revision_attributes" => "CustomRuleRevisionAttributes", + "v2.custom_rule_revision_attributes_category" => "CustomRuleRevisionAttributesCategory", + "v2.custom_rule_revision_attributes_severity" => "CustomRuleRevisionAttributesSeverity", + "v2.custom_rule_revision_data_type" => "CustomRuleRevisionDataType", + "v2.custom_rule_revision_input_attributes" => "CustomRuleRevisionInputAttributes", + "v2.custom_rule_revision_request" => "CustomRuleRevisionRequest", + "v2.custom_rule_revision_request_data" => "CustomRuleRevisionRequestData", + "v2.custom_rule_revision_response" => "CustomRuleRevisionResponse", + "v2.custom_rule_revisions_response" => "CustomRuleRevisionsResponse", + "v2.custom_rule_revision_test" => "CustomRuleRevisionTest", + "v2.custom_ruleset" => "CustomRuleset", + "v2.custom_ruleset_attributes" => "CustomRulesetAttributes", + "v2.custom_ruleset_data_type" => "CustomRulesetDataType", + "v2.custom_ruleset_request" => "CustomRulesetRequest", + "v2.custom_ruleset_request_data" => "CustomRulesetRequestData", + "v2.custom_ruleset_request_data_attributes" => "CustomRulesetRequestDataAttributes", + "v2.custom_ruleset_response" => "CustomRulesetResponse", "v2.cvss" => "CVSS", "v2.dashboard_list_add_items_request" => "DashboardListAddItemsRequest", "v2.dashboard_list_add_items_response" => "DashboardListAddItemsResponse", @@ -2794,6 +2820,7 @@ def overrides "v2.kind_metadata" => "KindMetadata", "v2.kind_obj" => "KindObj", "v2.kind_response_meta" => "KindResponseMeta", + "v2.language" => "Language", "v2.launch_darkly_api_key" => "LaunchDarklyAPIKey", "v2.launch_darkly_api_key_type" => "LaunchDarklyAPIKeyType", "v2.launch_darkly_api_key_update" => "LaunchDarklyAPIKeyUpdate", @@ -3765,6 +3792,10 @@ def overrides "v2.retry_strategy" => "RetryStrategy", "v2.retry_strategy_kind" => "RetryStrategyKind", "v2.retry_strategy_linear" => "RetryStrategyLinear", + "v2.revert_custom_rule_revision_data_type" => "RevertCustomRuleRevisionDataType", + "v2.revert_custom_rule_revision_request" => "RevertCustomRuleRevisionRequest", + "v2.revert_custom_rule_revision_request_data" => "RevertCustomRuleRevisionRequestData", + "v2.revert_custom_rule_revision_request_data_attributes" => "RevertCustomRuleRevisionRequestDataAttributes", "v2.role" => "Role", "v2.role_attributes" => "RoleAttributes", "v2.role_clone" => "RoleClone", diff --git a/lib/datadog_api_client/v2/api/static_analysis_api.rb b/lib/datadog_api_client/v2/api/static_analysis_api.rb index 617f9f385170..d778dce9101d 100644 --- a/lib/datadog_api_client/v2/api/static_analysis_api.rb +++ b/lib/datadog_api_client/v2/api/static_analysis_api.rb @@ -23,6 +23,167 @@ def initialize(api_client = DatadogAPIClient::APIClient.default) @api_client = api_client end + # Create Custom Rule. + # + # @see #create_custom_rule_with_http_info + def create_custom_rule(ruleset_name, body, opts = {}) + data, _status_code, _headers = create_custom_rule_with_http_info(ruleset_name, body, opts) + data + end + + # Create Custom Rule. + # + # Create a new custom rule within a ruleset + # + # @param ruleset_name [String] The ruleset name + # @param body [CustomRuleRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(CustomRuleResponse, Integer, Hash)>] CustomRuleResponse data, response status code and response headers + def create_custom_rule_with_http_info(ruleset_name, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.create_custom_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_custom_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_custom_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.create_custom_rule ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.create_custom_rule" + 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 StaticAnalysisAPI.create_custom_rule" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules'.sub('{ruleset_name}', CGI.escape(ruleset_name.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] || 'CustomRuleResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_custom_rule, + :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::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StaticAnalysisAPI#create_custom_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Create Custom Rule Revision. + # + # @see #create_custom_rule_revision_with_http_info + def create_custom_rule_revision(ruleset_name, rule_name, body, opts = {}) + create_custom_rule_revision_with_http_info(ruleset_name, rule_name, body, opts) + nil + end + + # Create Custom Rule Revision. + # + # Create a new revision for a custom rule + # + # @param ruleset_name [String] The ruleset name + # @param rule_name [String] The rule name + # @param body [CustomRuleRevisionRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def create_custom_rule_revision_with_http_info(ruleset_name, rule_name, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.create_custom_rule_revision".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_custom_rule_revision") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_custom_rule_revision")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.create_custom_rule_revision ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.create_custom_rule_revision" + end + # verify the required parameter 'rule_name' is set + if @api_client.config.client_side_validation && rule_name.nil? + fail ArgumentError, "Missing the required parameter 'rule_name' when calling StaticAnalysisAPI.create_custom_rule_revision" + 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 StaticAnalysisAPI.create_custom_rule_revision" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions'.sub('{ruleset_name}', CGI.escape(ruleset_name.to_s).gsub('%2F', '/')).sub('{rule_name}', CGI.escape(rule_name.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(['*/*']) + # 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] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_custom_rule_revision, + :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::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StaticAnalysisAPI#create_custom_rule_revision\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # POST request to resolve vulnerable symbols. # # @see #create_sca_resolve_vulnerable_symbols_with_http_info @@ -162,5 +323,642 @@ def create_sca_result_with_http_info(body, opts = {}) end return data, status_code, headers end + + # Delete Custom Rule. + # + # @see #delete_custom_rule_with_http_info + def delete_custom_rule(ruleset_name, rule_name, opts = {}) + delete_custom_rule_with_http_info(ruleset_name, rule_name, opts) + nil + end + + # Delete Custom Rule. + # + # Delete a custom rule + # + # @param ruleset_name [String] The ruleset name + # @param rule_name [String] The rule name + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_custom_rule_with_http_info(ruleset_name, rule_name, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.delete_custom_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.delete_custom_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.delete_custom_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.delete_custom_rule ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.delete_custom_rule" + end + # verify the required parameter 'rule_name' is set + if @api_client.config.client_side_validation && rule_name.nil? + fail ArgumentError, "Missing the required parameter 'rule_name' when calling StaticAnalysisAPI.delete_custom_rule" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}'.sub('{ruleset_name}', CGI.escape(ruleset_name.to_s).gsub('%2F', '/')).sub('{rule_name}', CGI.escape(rule_name.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(['*/*']) + + # 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_custom_rule, + :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: StaticAnalysisAPI#delete_custom_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Custom Ruleset. + # + # @see #delete_custom_ruleset_with_http_info + def delete_custom_ruleset(ruleset_name, opts = {}) + delete_custom_ruleset_with_http_info(ruleset_name, opts) + nil + end + + # Delete Custom Ruleset. + # + # Delete a custom ruleset + # + # @param ruleset_name [String] The ruleset name + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_custom_ruleset_with_http_info(ruleset_name, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.delete_custom_ruleset".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.delete_custom_ruleset") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.delete_custom_ruleset")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.delete_custom_ruleset ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.delete_custom_ruleset" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}'.sub('{ruleset_name}', CGI.escape(ruleset_name.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(['*/*']) + + # 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_custom_ruleset, + :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: StaticAnalysisAPI#delete_custom_ruleset\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Show Custom Rule. + # + # @see #get_custom_rule_with_http_info + def get_custom_rule(ruleset_name, rule_name, opts = {}) + data, _status_code, _headers = get_custom_rule_with_http_info(ruleset_name, rule_name, opts) + data + end + + # Show Custom Rule. + # + # Get a custom rule by name + # + # @param ruleset_name [String] The ruleset name + # @param rule_name [String] The rule name + # @param opts [Hash] the optional parameters + # @return [Array<(CustomRuleResponse, Integer, Hash)>] CustomRuleResponse data, response status code and response headers + def get_custom_rule_with_http_info(ruleset_name, rule_name, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_custom_rule".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_custom_rule") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_custom_rule")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.get_custom_rule ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.get_custom_rule" + end + # verify the required parameter 'rule_name' is set + if @api_client.config.client_side_validation && rule_name.nil? + fail ArgumentError, "Missing the required parameter 'rule_name' when calling StaticAnalysisAPI.get_custom_rule" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}'.sub('{ruleset_name}', CGI.escape(ruleset_name.to_s).gsub('%2F', '/')).sub('{rule_name}', CGI.escape(rule_name.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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CustomRuleResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_custom_rule, + :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: StaticAnalysisAPI#get_custom_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Show Custom Rule Revision. + # + # @see #get_custom_rule_revision_with_http_info + def get_custom_rule_revision(ruleset_name, rule_name, id, opts = {}) + data, _status_code, _headers = get_custom_rule_revision_with_http_info(ruleset_name, rule_name, id, opts) + data + end + + # Show Custom Rule Revision. + # + # Get a specific revision of a custom rule + # + # @param ruleset_name [String] The ruleset name + # @param rule_name [String] The rule name + # @param id [String] The revision ID + # @param opts [Hash] the optional parameters + # @return [Array<(CustomRuleRevisionResponse, Integer, Hash)>] CustomRuleRevisionResponse data, response status code and response headers + def get_custom_rule_revision_with_http_info(ruleset_name, rule_name, id, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_custom_rule_revision".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_custom_rule_revision") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_custom_rule_revision")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.get_custom_rule_revision ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.get_custom_rule_revision" + end + # verify the required parameter 'rule_name' is set + if @api_client.config.client_side_validation && rule_name.nil? + fail ArgumentError, "Missing the required parameter 'rule_name' when calling StaticAnalysisAPI.get_custom_rule_revision" + end + # verify the required parameter 'id' is set + if @api_client.config.client_side_validation && id.nil? + fail ArgumentError, "Missing the required parameter 'id' when calling StaticAnalysisAPI.get_custom_rule_revision" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions/{id}'.sub('{ruleset_name}', CGI.escape(ruleset_name.to_s).gsub('%2F', '/')).sub('{rule_name}', CGI.escape(rule_name.to_s).gsub('%2F', '/')).sub('{id}', CGI.escape(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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CustomRuleRevisionResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_custom_rule_revision, + :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: StaticAnalysisAPI#get_custom_rule_revision\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Show Custom Ruleset. + # + # @see #get_custom_ruleset_with_http_info + def get_custom_ruleset(ruleset_name, opts = {}) + data, _status_code, _headers = get_custom_ruleset_with_http_info(ruleset_name, opts) + data + end + + # Show Custom Ruleset. + # + # Get a custom ruleset by name + # + # @param ruleset_name [String] The ruleset name + # @param opts [Hash] the optional parameters + # @return [Array<(CustomRulesetResponse, Integer, Hash)>] CustomRulesetResponse data, response status code and response headers + def get_custom_ruleset_with_http_info(ruleset_name, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_custom_ruleset".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_custom_ruleset") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_custom_ruleset")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.get_custom_ruleset ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.get_custom_ruleset" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}'.sub('{ruleset_name}', CGI.escape(ruleset_name.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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CustomRulesetResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_custom_ruleset, + :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: StaticAnalysisAPI#get_custom_ruleset\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Custom Rule Revisions. + # + # @see #list_custom_rule_revisions_with_http_info + def list_custom_rule_revisions(ruleset_name, rule_name, opts = {}) + data, _status_code, _headers = list_custom_rule_revisions_with_http_info(ruleset_name, rule_name, opts) + data + end + + # List Custom Rule Revisions. + # + # Get all revisions for a custom rule + # + # @param ruleset_name [String] The ruleset name + # @param rule_name [String] The rule name + # @param opts [Hash] the optional parameters + # @option opts [Integer] :page_offset Pagination offset + # @option opts [Integer] :page_limit Pagination limit + # @return [Array<(CustomRuleRevisionsResponse, Integer, Hash)>] CustomRuleRevisionsResponse data, response status code and response headers + def list_custom_rule_revisions_with_http_info(ruleset_name, rule_name, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.list_custom_rule_revisions".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_custom_rule_revisions") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_custom_rule_revisions")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.list_custom_rule_revisions ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.list_custom_rule_revisions" + end + # verify the required parameter 'rule_name' is set + if @api_client.config.client_side_validation && rule_name.nil? + fail ArgumentError, "Missing the required parameter 'rule_name' when calling StaticAnalysisAPI.list_custom_rule_revisions" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions'.sub('{ruleset_name}', CGI.escape(ruleset_name.to_s).gsub('%2F', '/')).sub('{rule_name}', CGI.escape(rule_name.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'page[offset]'] = opts[:'page_offset'] if !opts[:'page_offset'].nil? + query_params[:'page[limit]'] = opts[:'page_limit'] if !opts[:'page_limit'].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] || 'CustomRuleRevisionsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :list_custom_rule_revisions, + :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: StaticAnalysisAPI#list_custom_rule_revisions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Custom Rule Revisions. + # + # Provide a paginated version of {#list_custom_rule_revisions}, returning all items. + # + # To use it you need to use a block: list_custom_rule_revisions_with_pagination { |item| p item } + # + # @yield [CustomRuleRevision] Paginated items + def list_custom_rule_revisions_with_pagination(ruleset_name, rule_name, opts = {}) + api_version = "V2" + page_size = @api_client.get_attribute_from_path(opts, "page_limit", 10) + @api_client.set_attribute_from_path(api_version, opts, "page_limit", Integer, page_size) + while true do + response = list_custom_rule_revisions(ruleset_name, rule_name, opts) + @api_client.get_attribute_from_path(response, "data").each { |item| yield(item) } + if @api_client.get_attribute_from_path(response, "data").length < page_size + break + end + @api_client.set_attribute_from_path(api_version, opts, "page_offset", Integer, @api_client.get_attribute_from_path(opts, "page_offset", 0) + page_size) + end + end + + # Revert Custom Rule Revision. + # + # @see #revert_custom_rule_revision_with_http_info + def revert_custom_rule_revision(ruleset_name, rule_name, body, opts = {}) + revert_custom_rule_revision_with_http_info(ruleset_name, rule_name, body, opts) + nil + end + + # Revert Custom Rule Revision. + # + # Revert a custom rule to a previous revision + # + # @param ruleset_name [String] The ruleset name + # @param rule_name [String] The rule name + # @param body [RevertCustomRuleRevisionRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def revert_custom_rule_revision_with_http_info(ruleset_name, rule_name, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.revert_custom_rule_revision".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.revert_custom_rule_revision") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.revert_custom_rule_revision")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.revert_custom_rule_revision ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.revert_custom_rule_revision" + end + # verify the required parameter 'rule_name' is set + if @api_client.config.client_side_validation && rule_name.nil? + fail ArgumentError, "Missing the required parameter 'rule_name' when calling StaticAnalysisAPI.revert_custom_rule_revision" + 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 StaticAnalysisAPI.revert_custom_rule_revision" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions/revert'.sub('{ruleset_name}', CGI.escape(ruleset_name.to_s).gsub('%2F', '/')).sub('{rule_name}', CGI.escape(rule_name.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(['*/*']) + # 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] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :revert_custom_rule_revision, + :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: StaticAnalysisAPI#revert_custom_rule_revision\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Custom Ruleset. + # + # @see #update_custom_ruleset_with_http_info + def update_custom_ruleset(ruleset_name, body, opts = {}) + data, _status_code, _headers = update_custom_ruleset_with_http_info(ruleset_name, body, opts) + data + end + + # Update Custom Ruleset. + # + # Update an existing custom ruleset + # + # @param ruleset_name [String] The ruleset name + # @param body [CustomRulesetRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(CustomRulesetResponse, Integer, Hash)>] CustomRulesetResponse data, response status code and response headers + def update_custom_ruleset_with_http_info(ruleset_name, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.update_custom_ruleset".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.update_custom_ruleset") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.update_custom_ruleset")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.update_custom_ruleset ...' + end + # verify the required parameter 'ruleset_name' is set + if @api_client.config.client_side_validation && ruleset_name.nil? + fail ArgumentError, "Missing the required parameter 'ruleset_name' when calling StaticAnalysisAPI.update_custom_ruleset" + 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 StaticAnalysisAPI.update_custom_ruleset" + end + # resource path + local_var_path = '/api/v2/static-analysis/custom/rulesets/{ruleset_name}'.sub('{ruleset_name}', CGI.escape(ruleset_name.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] || 'CustomRulesetResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :update_custom_ruleset, + :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: StaticAnalysisAPI#update_custom_ruleset\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/argument.rb b/lib/datadog_api_client/v2/models/argument.rb new file mode 100644 index 000000000000..6462efc68fa3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/argument.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 + # + class Argument + include BaseGenericModel + + # Base64-encoded argument description + attr_reader :description + + # Base64-encoded argument name + attr_reader :name + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'description' => :'description', + :'name' => :'name' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'description' => :'String', + :'name' => :'String' + } + 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::Argument` 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?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + 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 @description.nil? + return false if @name.nil? + true + end + + # Custom attribute writer method with validation + # @param description [Object] Object to be assigned + # @!visibility private + def description=(description) + if description.nil? + fail ArgumentError, 'invalid value for "description", description cannot be nil.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + 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 && + description == o.description && + name == o.name && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [description, name, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule.rb b/lib/datadog_api_client/v2/models/custom_rule.rb new file mode 100644 index 000000000000..17d55e8631ab --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule.rb @@ -0,0 +1,186 @@ +=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 + # + class CustomRule + include BaseGenericModel + + # Creation timestamp + attr_reader :created_at + + # Creator identifier + attr_reader :created_by + + # + attr_reader :last_revision + + # Rule name + attr_reader :name + + 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', + :'last_revision' => :'last_revision', + :'name' => :'name' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'created_at' => :'Time', + :'created_by' => :'String', + :'last_revision' => :'CustomRuleRevision', + :'name' => :'String' + } + 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::CustomRule` 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?(:'last_revision') + self.last_revision = attributes[:'last_revision'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + 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 @last_revision.nil? + return false if @name.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 last_revision [Object] Object to be assigned + # @!visibility private + def last_revision=(last_revision) + if last_revision.nil? + fail ArgumentError, 'invalid value for "last_revision", last_revision cannot be nil.' + end + @last_revision = last_revision + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + 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 && + last_revision == o.last_revision && + name == o.name && + 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, last_revision, name, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule_data_type.rb b/lib/datadog_api_client/v2/models/custom_rule_data_type.rb new file mode 100644 index 000000000000..10297e260b61 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_data_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 + # Resource type + class CustomRuleDataType + include BaseEnumModel + + CUSTOM_RULE = "custom_rule".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule_request.rb b/lib/datadog_api_client/v2/models/custom_rule_request.rb new file mode 100644 index 000000000000..a1edd237ab1d --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_request.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 + # + class CustomRuleRequest + include BaseGenericModel + + # + attr_accessor :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' => :'CustomRuleRequestData' + } + 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::CustomRuleRequest` 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 + + # 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/custom_rule_request_data.rb b/lib/datadog_api_client/v2/models/custom_rule_request_data.rb new file mode 100644 index 000000000000..8ebe0fa8d938 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_request_data.rb @@ -0,0 +1,125 @@ +=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 + # + class CustomRuleRequestData + include BaseGenericModel + + # + attr_accessor :attributes + + # Rule identifier + attr_accessor :id + + # Resource type + attr_accessor :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' => :'CustomRuleRequestDataAttributes', + :'id' => :'String', + :'type' => :'CustomRuleDataType' + } + 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::CustomRuleRequestData` 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 + + # 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/custom_rule_request_data_attributes.rb b/lib/datadog_api_client/v2/models/custom_rule_request_data_attributes.rb new file mode 100644 index 000000000000..cc16bc8e25be --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_request_data_attributes.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 + # + class CustomRuleRequestDataAttributes + include BaseGenericModel + + # Rule name + attr_accessor :name + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String' + } + 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::CustomRuleRequestDataAttributes` 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?(:'name') + self.name = attributes[:'name'] + 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 && + name == o.name && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule_response.rb b/lib/datadog_api_client/v2/models/custom_rule_response.rb new file mode 100644 index 000000000000..60a3f6808af0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_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 + # + class CustomRuleResponse + include BaseGenericModel + + # + 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' => :'CustomRuleResponseData' + } + 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::CustomRuleResponse` 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/custom_rule_response_data.rb b/lib/datadog_api_client/v2/models/custom_rule_response_data.rb new file mode 100644 index 000000000000..cac24f852fb3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_response_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 + # + class CustomRuleResponseData + include BaseGenericModel + + # + attr_reader :attributes + + # Rule identifier + attr_reader :id + + # Resource type + 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' => :'CustomRule', + :'id' => :'String', + :'type' => :'CustomRuleDataType' + } + 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::CustomRuleResponseData` 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/custom_rule_revision.rb b/lib/datadog_api_client/v2/models/custom_rule_revision.rb new file mode 100644 index 000000000000..5e00270202d3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision.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 + # + class CustomRuleRevision + include BaseGenericModel + + # + attr_reader :attributes + + # Revision identifier + attr_reader :id + + # Resource type + 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' => :'CustomRuleRevisionAttributes', + :'id' => :'String', + :'type' => :'CustomRuleRevisionDataType' + } + 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::CustomRuleRevision` 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/custom_rule_revision_attributes.rb b/lib/datadog_api_client/v2/models/custom_rule_revision_attributes.rb new file mode 100644 index 000000000000..6e1f0cc577bd --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision_attributes.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 'date' +require 'time' + +module DatadogAPIClient::V2 + # + class CustomRuleRevisionAttributes + include BaseGenericModel + + # Rule arguments + attr_reader :arguments + + # Rule category + attr_reader :category + + # Code checksum + attr_reader :checksum + + # Rule code + attr_reader :code + + # Creation timestamp + attr_reader :created_at + + # Creator identifier + attr_reader :created_by + + # Revision creation message + attr_reader :creation_message + + # Associated CVE + attr_accessor :cve + + # Associated CWE + attr_accessor :cwe + + # Full description + attr_reader :description + + # Documentation URL + attr_accessor :documentation_url + + # Whether the revision is published + attr_reader :is_published + + # Whether this is a testing revision + attr_reader :is_testing + + # Programming language + attr_reader :language + + # Rule severity + attr_reader :severity + + # Short description + attr_reader :short_description + + # Whether to use AI for fixes + attr_reader :should_use_ai_fix + + # Rule tags + attr_reader :tags + + # Rule tests + attr_reader :tests + + # Tree-sitter query + attr_reader :tree_sitter_query + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'arguments' => :'arguments', + :'category' => :'category', + :'checksum' => :'checksum', + :'code' => :'code', + :'created_at' => :'created_at', + :'created_by' => :'created_by', + :'creation_message' => :'creation_message', + :'cve' => :'cve', + :'cwe' => :'cwe', + :'description' => :'description', + :'documentation_url' => :'documentation_url', + :'is_published' => :'is_published', + :'is_testing' => :'is_testing', + :'language' => :'language', + :'severity' => :'severity', + :'short_description' => :'short_description', + :'should_use_ai_fix' => :'should_use_ai_fix', + :'tags' => :'tags', + :'tests' => :'tests', + :'tree_sitter_query' => :'tree_sitter_query' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'arguments' => :'Array', + :'category' => :'CustomRuleRevisionAttributesCategory', + :'checksum' => :'String', + :'code' => :'String', + :'created_at' => :'Time', + :'created_by' => :'String', + :'creation_message' => :'String', + :'cve' => :'String', + :'cwe' => :'String', + :'description' => :'String', + :'documentation_url' => :'String', + :'is_published' => :'Boolean', + :'is_testing' => :'Boolean', + :'language' => :'Language', + :'severity' => :'CustomRuleRevisionAttributesSeverity', + :'short_description' => :'String', + :'should_use_ai_fix' => :'Boolean', + :'tags' => :'Array', + :'tests' => :'Array', + :'tree_sitter_query' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'cve', + :'cwe', + :'documentation_url', + ]) + 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::CustomRuleRevisionAttributes` 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?(:'arguments') + if (value = attributes[:'arguments']).is_a?(Array) + self.arguments = value + end + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'checksum') + self.checksum = attributes[:'checksum'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + 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?(:'creation_message') + self.creation_message = attributes[:'creation_message'] + end + + if attributes.key?(:'cve') + self.cve = attributes[:'cve'] + end + + if attributes.key?(:'cwe') + self.cwe = attributes[:'cwe'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'documentation_url') + self.documentation_url = attributes[:'documentation_url'] + end + + if attributes.key?(:'is_published') + self.is_published = attributes[:'is_published'] + end + + if attributes.key?(:'is_testing') + self.is_testing = attributes[:'is_testing'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + + if attributes.key?(:'severity') + self.severity = attributes[:'severity'] + end + + if attributes.key?(:'short_description') + self.short_description = attributes[:'short_description'] + end + + if attributes.key?(:'should_use_ai_fix') + self.should_use_ai_fix = attributes[:'should_use_ai_fix'] + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + + if attributes.key?(:'tests') + if (value = attributes[:'tests']).is_a?(Array) + self.tests = value + end + end + + if attributes.key?(:'tree_sitter_query') + self.tree_sitter_query = attributes[:'tree_sitter_query'] + 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 @arguments.nil? + return false if @category.nil? + return false if @checksum.nil? + return false if @code.nil? + return false if @created_at.nil? + return false if @created_by.nil? + return false if @creation_message.nil? + return false if @description.nil? + return false if @is_published.nil? + return false if @is_testing.nil? + return false if @language.nil? + return false if @severity.nil? + return false if @short_description.nil? + return false if @should_use_ai_fix.nil? + return false if @tags.nil? + return false if @tests.nil? + return false if @tree_sitter_query.nil? + true + end + + # Custom attribute writer method with validation + # @param arguments [Object] Object to be assigned + # @!visibility private + def arguments=(arguments) + if arguments.nil? + fail ArgumentError, 'invalid value for "arguments", arguments cannot be nil.' + end + @arguments = arguments + end + + # Custom attribute writer method with validation + # @param category [Object] Object to be assigned + # @!visibility private + def category=(category) + if category.nil? + fail ArgumentError, 'invalid value for "category", category cannot be nil.' + end + @category = category + end + + # Custom attribute writer method with validation + # @param checksum [Object] Object to be assigned + # @!visibility private + def checksum=(checksum) + if checksum.nil? + fail ArgumentError, 'invalid value for "checksum", checksum cannot be nil.' + end + @checksum = checksum + end + + # Custom attribute writer method with validation + # @param code [Object] Object to be assigned + # @!visibility private + def code=(code) + if code.nil? + fail ArgumentError, 'invalid value for "code", code cannot be nil.' + end + @code = code + 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 creation_message [Object] Object to be assigned + # @!visibility private + def creation_message=(creation_message) + if creation_message.nil? + fail ArgumentError, 'invalid value for "creation_message", creation_message cannot be nil.' + end + @creation_message = creation_message + end + + # Custom attribute writer method with validation + # @param description [Object] Object to be assigned + # @!visibility private + def description=(description) + if description.nil? + fail ArgumentError, 'invalid value for "description", description cannot be nil.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param is_published [Object] Object to be assigned + # @!visibility private + def is_published=(is_published) + if is_published.nil? + fail ArgumentError, 'invalid value for "is_published", is_published cannot be nil.' + end + @is_published = is_published + end + + # Custom attribute writer method with validation + # @param is_testing [Object] Object to be assigned + # @!visibility private + def is_testing=(is_testing) + if is_testing.nil? + fail ArgumentError, 'invalid value for "is_testing", is_testing cannot be nil.' + end + @is_testing = is_testing + end + + # Custom attribute writer method with validation + # @param language [Object] Object to be assigned + # @!visibility private + def language=(language) + if language.nil? + fail ArgumentError, 'invalid value for "language", language cannot be nil.' + end + @language = language + end + + # Custom attribute writer method with validation + # @param severity [Object] Object to be assigned + # @!visibility private + def severity=(severity) + if severity.nil? + fail ArgumentError, 'invalid value for "severity", severity cannot be nil.' + end + @severity = severity + end + + # Custom attribute writer method with validation + # @param short_description [Object] Object to be assigned + # @!visibility private + def short_description=(short_description) + if short_description.nil? + fail ArgumentError, 'invalid value for "short_description", short_description cannot be nil.' + end + @short_description = short_description + end + + # Custom attribute writer method with validation + # @param should_use_ai_fix [Object] Object to be assigned + # @!visibility private + def should_use_ai_fix=(should_use_ai_fix) + if should_use_ai_fix.nil? + fail ArgumentError, 'invalid value for "should_use_ai_fix", should_use_ai_fix cannot be nil.' + end + @should_use_ai_fix = should_use_ai_fix + end + + # Custom attribute writer method with validation + # @param tags [Object] Object to be assigned + # @!visibility private + def tags=(tags) + if tags.nil? + fail ArgumentError, 'invalid value for "tags", tags cannot be nil.' + end + @tags = tags + end + + # Custom attribute writer method with validation + # @param tests [Object] Object to be assigned + # @!visibility private + def tests=(tests) + if tests.nil? + fail ArgumentError, 'invalid value for "tests", tests cannot be nil.' + end + @tests = tests + end + + # Custom attribute writer method with validation + # @param tree_sitter_query [Object] Object to be assigned + # @!visibility private + def tree_sitter_query=(tree_sitter_query) + if tree_sitter_query.nil? + fail ArgumentError, 'invalid value for "tree_sitter_query", tree_sitter_query cannot be nil.' + end + @tree_sitter_query = tree_sitter_query + 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 && + arguments == o.arguments && + category == o.category && + checksum == o.checksum && + code == o.code && + created_at == o.created_at && + created_by == o.created_by && + creation_message == o.creation_message && + cve == o.cve && + cwe == o.cwe && + description == o.description && + documentation_url == o.documentation_url && + is_published == o.is_published && + is_testing == o.is_testing && + language == o.language && + severity == o.severity && + short_description == o.short_description && + should_use_ai_fix == o.should_use_ai_fix && + tags == o.tags && + tests == o.tests && + tree_sitter_query == o.tree_sitter_query && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [arguments, category, checksum, code, created_at, created_by, creation_message, cve, cwe, description, documentation_url, is_published, is_testing, language, severity, short_description, should_use_ai_fix, tags, tests, tree_sitter_query, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule_revision_attributes_category.rb b/lib/datadog_api_client/v2/models/custom_rule_revision_attributes_category.rb new file mode 100644 index 000000000000..cda3042bb9f4 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision_attributes_category.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 + # Rule category + class CustomRuleRevisionAttributesCategory + include BaseEnumModel + + SECURITY = "SECURITY".freeze + BEST_PRACTICES = "BEST_PRACTICES".freeze + CODE_STYLE = "CODE_STYLE".freeze + ERROR_PRONE = "ERROR_PRONE".freeze + PERFORMANCE = "PERFORMANCE".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule_revision_attributes_severity.rb b/lib/datadog_api_client/v2/models/custom_rule_revision_attributes_severity.rb new file mode 100644 index 000000000000..cb1de2ae71d4 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision_attributes_severity.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 + # Rule severity + class CustomRuleRevisionAttributesSeverity + include BaseEnumModel + + ERROR = "ERROR".freeze + WARNING = "WARNING".freeze + NOTICE = "NOTICE".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule_revision_data_type.rb b/lib/datadog_api_client/v2/models/custom_rule_revision_data_type.rb new file mode 100644 index 000000000000..f817f0fa2414 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision_data_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 + # Resource type + class CustomRuleRevisionDataType + include BaseEnumModel + + CUSTOM_RULE_REVISION = "custom_rule_revision".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule_revision_input_attributes.rb b/lib/datadog_api_client/v2/models/custom_rule_revision_input_attributes.rb new file mode 100644 index 000000000000..3262e3fcabc7 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision_input_attributes.rb @@ -0,0 +1,442 @@ +=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 + # + class CustomRuleRevisionInputAttributes + include BaseGenericModel + + # Rule arguments + attr_reader :arguments + + # Rule category + attr_reader :category + + # Rule code + attr_reader :code + + # Revision creation message + attr_reader :creation_message + + # Associated CVE + attr_accessor :cve + + # Associated CWE + attr_accessor :cwe + + # Full description + attr_reader :description + + # Documentation URL + attr_accessor :documentation_url + + # Whether the revision is published + attr_reader :is_published + + # Whether this is a testing revision + attr_reader :is_testing + + # Programming language + attr_reader :language + + # Rule severity + attr_reader :severity + + # Short description + attr_reader :short_description + + # Whether to use AI for fixes + attr_reader :should_use_ai_fix + + # Rule tags + attr_reader :tags + + # Rule tests + attr_reader :tests + + # Tree-sitter query + attr_reader :tree_sitter_query + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'arguments' => :'arguments', + :'category' => :'category', + :'code' => :'code', + :'creation_message' => :'creation_message', + :'cve' => :'cve', + :'cwe' => :'cwe', + :'description' => :'description', + :'documentation_url' => :'documentation_url', + :'is_published' => :'is_published', + :'is_testing' => :'is_testing', + :'language' => :'language', + :'severity' => :'severity', + :'short_description' => :'short_description', + :'should_use_ai_fix' => :'should_use_ai_fix', + :'tags' => :'tags', + :'tests' => :'tests', + :'tree_sitter_query' => :'tree_sitter_query' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'arguments' => :'Array', + :'category' => :'CustomRuleRevisionAttributesCategory', + :'code' => :'String', + :'creation_message' => :'String', + :'cve' => :'String', + :'cwe' => :'String', + :'description' => :'String', + :'documentation_url' => :'String', + :'is_published' => :'Boolean', + :'is_testing' => :'Boolean', + :'language' => :'Language', + :'severity' => :'CustomRuleRevisionAttributesSeverity', + :'short_description' => :'String', + :'should_use_ai_fix' => :'Boolean', + :'tags' => :'Array', + :'tests' => :'Array', + :'tree_sitter_query' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'cve', + :'cwe', + :'documentation_url', + ]) + 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::CustomRuleRevisionInputAttributes` 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?(:'arguments') + if (value = attributes[:'arguments']).is_a?(Array) + self.arguments = value + end + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'creation_message') + self.creation_message = attributes[:'creation_message'] + end + + if attributes.key?(:'cve') + self.cve = attributes[:'cve'] + end + + if attributes.key?(:'cwe') + self.cwe = attributes[:'cwe'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'documentation_url') + self.documentation_url = attributes[:'documentation_url'] + end + + if attributes.key?(:'is_published') + self.is_published = attributes[:'is_published'] + end + + if attributes.key?(:'is_testing') + self.is_testing = attributes[:'is_testing'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + + if attributes.key?(:'severity') + self.severity = attributes[:'severity'] + end + + if attributes.key?(:'short_description') + self.short_description = attributes[:'short_description'] + end + + if attributes.key?(:'should_use_ai_fix') + self.should_use_ai_fix = attributes[:'should_use_ai_fix'] + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + + if attributes.key?(:'tests') + if (value = attributes[:'tests']).is_a?(Array) + self.tests = value + end + end + + if attributes.key?(:'tree_sitter_query') + self.tree_sitter_query = attributes[:'tree_sitter_query'] + 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 @arguments.nil? + return false if @category.nil? + return false if @code.nil? + return false if @creation_message.nil? + return false if @description.nil? + return false if @is_published.nil? + return false if @is_testing.nil? + return false if @language.nil? + return false if @severity.nil? + return false if @short_description.nil? + return false if @should_use_ai_fix.nil? + return false if @tags.nil? + return false if @tests.nil? + return false if @tree_sitter_query.nil? + true + end + + # Custom attribute writer method with validation + # @param arguments [Object] Object to be assigned + # @!visibility private + def arguments=(arguments) + if arguments.nil? + fail ArgumentError, 'invalid value for "arguments", arguments cannot be nil.' + end + @arguments = arguments + end + + # Custom attribute writer method with validation + # @param category [Object] Object to be assigned + # @!visibility private + def category=(category) + if category.nil? + fail ArgumentError, 'invalid value for "category", category cannot be nil.' + end + @category = category + end + + # Custom attribute writer method with validation + # @param code [Object] Object to be assigned + # @!visibility private + def code=(code) + if code.nil? + fail ArgumentError, 'invalid value for "code", code cannot be nil.' + end + @code = code + end + + # Custom attribute writer method with validation + # @param creation_message [Object] Object to be assigned + # @!visibility private + def creation_message=(creation_message) + if creation_message.nil? + fail ArgumentError, 'invalid value for "creation_message", creation_message cannot be nil.' + end + @creation_message = creation_message + end + + # Custom attribute writer method with validation + # @param description [Object] Object to be assigned + # @!visibility private + def description=(description) + if description.nil? + fail ArgumentError, 'invalid value for "description", description cannot be nil.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param is_published [Object] Object to be assigned + # @!visibility private + def is_published=(is_published) + if is_published.nil? + fail ArgumentError, 'invalid value for "is_published", is_published cannot be nil.' + end + @is_published = is_published + end + + # Custom attribute writer method with validation + # @param is_testing [Object] Object to be assigned + # @!visibility private + def is_testing=(is_testing) + if is_testing.nil? + fail ArgumentError, 'invalid value for "is_testing", is_testing cannot be nil.' + end + @is_testing = is_testing + end + + # Custom attribute writer method with validation + # @param language [Object] Object to be assigned + # @!visibility private + def language=(language) + if language.nil? + fail ArgumentError, 'invalid value for "language", language cannot be nil.' + end + @language = language + end + + # Custom attribute writer method with validation + # @param severity [Object] Object to be assigned + # @!visibility private + def severity=(severity) + if severity.nil? + fail ArgumentError, 'invalid value for "severity", severity cannot be nil.' + end + @severity = severity + end + + # Custom attribute writer method with validation + # @param short_description [Object] Object to be assigned + # @!visibility private + def short_description=(short_description) + if short_description.nil? + fail ArgumentError, 'invalid value for "short_description", short_description cannot be nil.' + end + @short_description = short_description + end + + # Custom attribute writer method with validation + # @param should_use_ai_fix [Object] Object to be assigned + # @!visibility private + def should_use_ai_fix=(should_use_ai_fix) + if should_use_ai_fix.nil? + fail ArgumentError, 'invalid value for "should_use_ai_fix", should_use_ai_fix cannot be nil.' + end + @should_use_ai_fix = should_use_ai_fix + end + + # Custom attribute writer method with validation + # @param tags [Object] Object to be assigned + # @!visibility private + def tags=(tags) + if tags.nil? + fail ArgumentError, 'invalid value for "tags", tags cannot be nil.' + end + @tags = tags + end + + # Custom attribute writer method with validation + # @param tests [Object] Object to be assigned + # @!visibility private + def tests=(tests) + if tests.nil? + fail ArgumentError, 'invalid value for "tests", tests cannot be nil.' + end + @tests = tests + end + + # Custom attribute writer method with validation + # @param tree_sitter_query [Object] Object to be assigned + # @!visibility private + def tree_sitter_query=(tree_sitter_query) + if tree_sitter_query.nil? + fail ArgumentError, 'invalid value for "tree_sitter_query", tree_sitter_query cannot be nil.' + end + @tree_sitter_query = tree_sitter_query + 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 && + arguments == o.arguments && + category == o.category && + code == o.code && + creation_message == o.creation_message && + cve == o.cve && + cwe == o.cwe && + description == o.description && + documentation_url == o.documentation_url && + is_published == o.is_published && + is_testing == o.is_testing && + language == o.language && + severity == o.severity && + short_description == o.short_description && + should_use_ai_fix == o.should_use_ai_fix && + tags == o.tags && + tests == o.tests && + tree_sitter_query == o.tree_sitter_query && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [arguments, category, code, creation_message, cve, cwe, description, documentation_url, is_published, is_testing, language, severity, short_description, should_use_ai_fix, tags, tests, tree_sitter_query, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule_revision_request.rb b/lib/datadog_api_client/v2/models/custom_rule_revision_request.rb new file mode 100644 index 000000000000..c87f25c06023 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision_request.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 + # + class CustomRuleRevisionRequest + include BaseGenericModel + + # + attr_accessor :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' => :'CustomRuleRevisionRequestData' + } + 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::CustomRuleRevisionRequest` 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 + + # 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/custom_rule_revision_request_data.rb b/lib/datadog_api_client/v2/models/custom_rule_revision_request_data.rb new file mode 100644 index 000000000000..7cf6e616ec4e --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision_request_data.rb @@ -0,0 +1,125 @@ +=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 + # + class CustomRuleRevisionRequestData + include BaseGenericModel + + # + attr_accessor :attributes + + # Revision identifier + attr_accessor :id + + # Resource type + attr_accessor :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' => :'CustomRuleRevisionInputAttributes', + :'id' => :'String', + :'type' => :'CustomRuleRevisionDataType' + } + 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::CustomRuleRevisionRequestData` 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 + + # 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/custom_rule_revision_response.rb b/lib/datadog_api_client/v2/models/custom_rule_revision_response.rb new file mode 100644 index 000000000000..e18f076fdaed --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision_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 + # + class CustomRuleRevisionResponse + include BaseGenericModel + + # + 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' => :'CustomRuleRevision' + } + 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::CustomRuleRevisionResponse` 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/custom_rule_revision_test.rb b/lib/datadog_api_client/v2/models/custom_rule_revision_test.rb new file mode 100644 index 000000000000..5106a17bc1a0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revision_test.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 + # + class CustomRuleRevisionTest + include BaseGenericModel + + # Expected violation count + attr_reader :annotation_count + + # Test code + attr_reader :code + + # Test filename + attr_reader :filename + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'annotation_count' => :'annotation_count', + :'code' => :'code', + :'filename' => :'filename' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'annotation_count' => :'Integer', + :'code' => :'String', + :'filename' => :'String' + } + 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::CustomRuleRevisionTest` 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?(:'annotation_count') + self.annotation_count = attributes[:'annotation_count'] + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'filename') + self.filename = attributes[:'filename'] + 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 @annotation_count.nil? + return false if @code.nil? + return false if @filename.nil? + true + end + + # Custom attribute writer method with validation + # @param annotation_count [Object] Object to be assigned + # @!visibility private + def annotation_count=(annotation_count) + if annotation_count.nil? + fail ArgumentError, 'invalid value for "annotation_count", annotation_count cannot be nil.' + end + @annotation_count = annotation_count + end + + # Custom attribute writer method with validation + # @param code [Object] Object to be assigned + # @!visibility private + def code=(code) + if code.nil? + fail ArgumentError, 'invalid value for "code", code cannot be nil.' + end + @code = code + end + + # Custom attribute writer method with validation + # @param filename [Object] Object to be assigned + # @!visibility private + def filename=(filename) + if filename.nil? + fail ArgumentError, 'invalid value for "filename", filename cannot be nil.' + end + @filename = filename + 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 && + annotation_count == o.annotation_count && + code == o.code && + filename == o.filename && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [annotation_count, code, filename, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/custom_rule_revisions_response.rb b/lib/datadog_api_client/v2/models/custom_rule_revisions_response.rb new file mode 100644 index 000000000000..e851175721a1 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_rule_revisions_response.rb @@ -0,0 +1,107 @@ +=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 + # + class CustomRuleRevisionsResponse + include BaseGenericModel + + # + attr_accessor :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' => :'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::CustomRuleRevisionsResponse` 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 + 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/custom_ruleset.rb b/lib/datadog_api_client/v2/models/custom_ruleset.rb new file mode 100644 index 000000000000..3630bd1d1616 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_ruleset.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 + # + class CustomRuleset + include BaseGenericModel + + # + attr_reader :attributes + + # Ruleset identifier + attr_reader :id + + # Resource type + 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' => :'CustomRulesetAttributes', + :'id' => :'String', + :'type' => :'CustomRulesetDataType' + } + 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::CustomRuleset` 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/custom_ruleset_attributes.rb b/lib/datadog_api_client/v2/models/custom_ruleset_attributes.rb new file mode 100644 index 000000000000..947d48579a1d --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_ruleset_attributes.rb @@ -0,0 +1,227 @@ +=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 + # + class CustomRulesetAttributes + include BaseGenericModel + + # Creation timestamp + attr_reader :created_at + + # Creator identifier + attr_reader :created_by + + # Base64-encoded full description + attr_reader :description + + # Ruleset name + attr_reader :name + + # Rules in the ruleset + attr_accessor :rules + + # Base64-encoded short description + attr_reader :short_description + + 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', + :'description' => :'description', + :'name' => :'name', + :'rules' => :'rules', + :'short_description' => :'short_description' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'created_at' => :'Time', + :'created_by' => :'String', + :'description' => :'String', + :'name' => :'String', + :'rules' => :'Array', + :'short_description' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'rules', + ]) + 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::CustomRulesetAttributes` 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?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'rules') + if (value = attributes[:'rules']).is_a?(Array) + self.rules = value + end + end + + if attributes.key?(:'short_description') + self.short_description = attributes[:'short_description'] + 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 @description.nil? + return false if @name.nil? + return false if @short_description.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 description [Object] Object to be assigned + # @!visibility private + def description=(description) + if description.nil? + fail ArgumentError, 'invalid value for "description", description cannot be nil.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param short_description [Object] Object to be assigned + # @!visibility private + def short_description=(short_description) + if short_description.nil? + fail ArgumentError, 'invalid value for "short_description", short_description cannot be nil.' + end + @short_description = short_description + 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 && + description == o.description && + name == o.name && + rules == o.rules && + short_description == o.short_description && + 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, description, name, rules, short_description, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/custom_ruleset_data_type.rb b/lib/datadog_api_client/v2/models/custom_ruleset_data_type.rb new file mode 100644 index 000000000000..e4178f109d58 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_ruleset_data_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 + # Resource type + class CustomRulesetDataType + include BaseEnumModel + + CUSTOM_RULESET = "custom_ruleset".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/custom_ruleset_request.rb b/lib/datadog_api_client/v2/models/custom_ruleset_request.rb new file mode 100644 index 000000000000..0e23a770904c --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_ruleset_request.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 + # + class CustomRulesetRequest + include BaseGenericModel + + # + attr_accessor :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' => :'CustomRulesetRequestData' + } + 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::CustomRulesetRequest` 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 + + # 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/custom_ruleset_request_data.rb b/lib/datadog_api_client/v2/models/custom_ruleset_request_data.rb new file mode 100644 index 000000000000..8c469d080962 --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_ruleset_request_data.rb @@ -0,0 +1,125 @@ +=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 + # + class CustomRulesetRequestData + include BaseGenericModel + + # + attr_accessor :attributes + + # Ruleset identifier + attr_accessor :id + + # Resource type + attr_accessor :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' => :'CustomRulesetRequestDataAttributes', + :'id' => :'String', + :'type' => :'CustomRulesetDataType' + } + 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::CustomRulesetRequestData` 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 + + # 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/custom_ruleset_request_data_attributes.rb b/lib/datadog_api_client/v2/models/custom_ruleset_request_data_attributes.rb new file mode 100644 index 000000000000..b00969d8503a --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_ruleset_request_data_attributes.rb @@ -0,0 +1,145 @@ +=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 + # + class CustomRulesetRequestDataAttributes + include BaseGenericModel + + # Base64-encoded full description + attr_accessor :description + + # Ruleset name + attr_accessor :name + + # Rules in the ruleset + attr_accessor :rules + + # Base64-encoded short description + attr_accessor :short_description + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'description' => :'description', + :'name' => :'name', + :'rules' => :'rules', + :'short_description' => :'short_description' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'description' => :'String', + :'name' => :'String', + :'rules' => :'Array', + :'short_description' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'rules', + ]) + 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::CustomRulesetRequestDataAttributes` 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?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'rules') + if (value = attributes[:'rules']).is_a?(Array) + self.rules = value + end + end + + if attributes.key?(:'short_description') + self.short_description = attributes[:'short_description'] + 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 && + description == o.description && + name == o.name && + rules == o.rules && + short_description == o.short_description && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [description, name, rules, short_description, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/custom_ruleset_response.rb b/lib/datadog_api_client/v2/models/custom_ruleset_response.rb new file mode 100644 index 000000000000..0f8d471df0db --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_ruleset_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 + # + class CustomRulesetResponse + include BaseGenericModel + + # + 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' => :'CustomRuleset' + } + 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::CustomRulesetResponse` 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/language.rb b/lib/datadog_api_client/v2/models/language.rb new file mode 100644 index 000000000000..bad7afd65a7f --- /dev/null +++ b/lib/datadog_api_client/v2/models/language.rb @@ -0,0 +1,36 @@ +=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 + # Programming language + class Language + include BaseEnumModel + + PYTHON = "PYTHON".freeze + JAVASCRIPT = "JAVASCRIPT".freeze + TYPESCRIPT = "TYPESCRIPT".freeze + JAVA = "JAVA".freeze + GO = "GO".freeze + YAML = "YAML".freeze + RUBY = "RUBY".freeze + CSHARP = "CSHARP".freeze + PHP = "PHP".freeze + KOTLIN = "KOTLIN".freeze + SWIFT = "SWIFT".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/revert_custom_rule_revision_data_type.rb b/lib/datadog_api_client/v2/models/revert_custom_rule_revision_data_type.rb new file mode 100644 index 000000000000..b8b2b659d871 --- /dev/null +++ b/lib/datadog_api_client/v2/models/revert_custom_rule_revision_data_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 + # Request type + class RevertCustomRuleRevisionDataType + include BaseEnumModel + + REVERT_CUSTOM_RULE_REVISION_REQUEST = "revert_custom_rule_revision_request".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/revert_custom_rule_revision_request.rb b/lib/datadog_api_client/v2/models/revert_custom_rule_revision_request.rb new file mode 100644 index 000000000000..78c0249593a9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/revert_custom_rule_revision_request.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 + # + class RevertCustomRuleRevisionRequest + include BaseGenericModel + + # + attr_accessor :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' => :'RevertCustomRuleRevisionRequestData' + } + 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::RevertCustomRuleRevisionRequest` 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 + + # 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/revert_custom_rule_revision_request_data.rb b/lib/datadog_api_client/v2/models/revert_custom_rule_revision_request_data.rb new file mode 100644 index 000000000000..fd2c0523f41d --- /dev/null +++ b/lib/datadog_api_client/v2/models/revert_custom_rule_revision_request_data.rb @@ -0,0 +1,125 @@ +=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 + # + class RevertCustomRuleRevisionRequestData + include BaseGenericModel + + # + attr_accessor :attributes + + # Request identifier + attr_accessor :id + + # Request type + attr_accessor :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' => :'RevertCustomRuleRevisionRequestDataAttributes', + :'id' => :'String', + :'type' => :'RevertCustomRuleRevisionDataType' + } + 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::RevertCustomRuleRevisionRequestData` 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 + + # 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/revert_custom_rule_revision_request_data_attributes.rb b/lib/datadog_api_client/v2/models/revert_custom_rule_revision_request_data_attributes.rb new file mode 100644 index 000000000000..4c6e08e47cf8 --- /dev/null +++ b/lib/datadog_api_client/v2/models/revert_custom_rule_revision_request_data_attributes.rb @@ -0,0 +1,115 @@ +=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 + # + class RevertCustomRuleRevisionRequestDataAttributes + include BaseGenericModel + + # Current revision ID + attr_accessor :current_revision + + # Target revision ID to revert to + attr_accessor :revert_to_revision + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'current_revision' => :'currentRevision', + :'revert_to_revision' => :'revertToRevision' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'current_revision' => :'String', + :'revert_to_revision' => :'String' + } + 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::RevertCustomRuleRevisionRequestDataAttributes` 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?(:'current_revision') + self.current_revision = attributes[:'current_revision'] + end + + if attributes.key?(:'revert_to_revision') + self.revert_to_revision = attributes[:'revert_to_revision'] + 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 && + current_revision == o.current_revision && + revert_to_revision == o.revert_to_revision && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [current_revision, revert_to_revision, additional_properties].hash + end + end +end