diff --git a/.apigentools-info b/.apigentools-info index 0f4c0b307..8813f549a 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-28 14:57:27.977823", - "spec_repo_commit": "f832f43e" + "regenerated": "2025-01-28 16:23:28.013868", + "spec_repo_commit": "590dadb7" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-28 14:57:27.993052", - "spec_repo_commit": "f832f43e" + "regenerated": "2025-01-28 16:23:28.029051", + "spec_repo_commit": "590dadb7" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ec0661fe2..28344b419 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -733,6 +733,13 @@ components: type: string requestBodies: {} responses: + AutomationRuleUnprocessableEntityResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: The server cannot process the request because it contains invalid + data. BadRequestResponse: content: application/json: @@ -782,6 +789,28 @@ components: schema: $ref: '#/components/schemas/APIErrorResponse' description: Forbidden + InboxRulesList: + content: + application/json: + schema: + properties: + data: + items: + $ref: '#/components/schemas/InboxRule' + type: array + type: object + description: The list of inbox rules + MuteRulesList: + content: + application/json: + schema: + properties: + data: + items: + $ref: '#/components/schemas/MuteRule' + type: array + type: object + description: The list of mute rules NotAuthorizedResponse: content: application/json: @@ -1748,6 +1777,31 @@ components: oneOf: - $ref: '#/components/schemas/AWSIntegrationUpdate' - $ref: '#/components/schemas/HTTPIntegrationUpdate' + ActionInbox: + description: Action of the inbox rule + properties: + reason_description: + description: Free text to add a reason description. + example: We want to focus on these items. + type: string + type: object + ActionMute: + description: Action of the mute rule + properties: + expire_at: + description: End date of the mute rule (null means mute forever) + example: 1893452400000 + format: int64 + type: integer + reason: + $ref: '#/components/schemas/MuteReason' + reason_description: + description: Free text to add a reason description. + example: Muting for a while + type: string + required: + - reason + type: object ActiveBillingDimensionsAttributes: description: List of active billing dimensions. properties: @@ -2757,6 +2811,49 @@ components: type: string x-enum-varnames: - AUTHN_MAPPINGS + AutomationRule: + description: 'The definition of an automation pipeline rule scope. + + A rule can act on specific issue types, security rule types, security rule + IDs, rule severities, or a query. + + The query can be used to filter resources on tags and attributes. + + The issue type and rule types fields are required.' + properties: + issue_type: + $ref: '#/components/schemas/IssueType' + query: + $ref: '#/components/schemas/RuleQuery' + rule_ids: + $ref: '#/components/schemas/RuleIds' + rule_types: + $ref: '#/components/schemas/SecurityRuleTypes' + severities: + description: The security rules severities to consider + items: + $ref: '#/components/schemas/SecurityRuleSeverity' + type: array + required: + - issue_type + - rule_types + type: object + AutomationRuleName: + description: Name of the pipeline rule + example: Rule 1 + type: string + AutomationRuleUser: + description: User creating or modifying a rule + properties: + handle: + description: The user handle. + example: john.doe@domain.com + type: string + name: + description: The user name. + example: John Doe + type: string + type: object AwsCURConfig: description: AWS CUR config. properties: @@ -7451,6 +7548,76 @@ components: meta: $ref: '#/components/schemas/DataDeletionResponseMeta' type: object + CreateInboxRuleParameters: + description: Body of the inbox rule create request + properties: + data: + $ref: '#/components/schemas/CreateInboxRuleParametersData' + type: object + CreateInboxRuleParametersData: + description: 'Data of the inbox rule create request: the rule type and the rule + attributes. All fields are required.' + properties: + attributes: + $ref: '#/components/schemas/CreateInboxRuleParametersDataAttributes' + type: + $ref: '#/components/schemas/InboxRulesType' + required: + - attributes + - type + type: object + CreateInboxRuleParametersDataAttributes: + description: 'Attributes of the inbox rule create request: the rule name, the + rule details, the associated action, and the optional enabled field.' + properties: + action: + $ref: '#/components/schemas/ActionInbox' + enabled: + $ref: '#/components/schemas/RuleEnabled' + name: + $ref: '#/components/schemas/AutomationRuleName' + rule: + $ref: '#/components/schemas/AutomationRule' + required: + - action + - name + - rule + type: object + CreateMuteRuleParameters: + description: Body of the mute rule create request + properties: + data: + $ref: '#/components/schemas/CreateMuteRuleParametersData' + type: object + CreateMuteRuleParametersData: + description: 'Data of the mute rule create request: the rule type and the rule + attributes. All fields are required.' + properties: + attributes: + $ref: '#/components/schemas/CreateMuteRuleParametersDataAttributes' + type: + $ref: '#/components/schemas/MuteRulesType' + required: + - attributes + - type + type: object + CreateMuteRuleParametersDataAttributes: + description: 'Attributes of the mute rule create request: the rule name, the + rule details, the associated action, and the optional enabled field.' + properties: + action: + $ref: '#/components/schemas/ActionMute' + enabled: + $ref: '#/components/schemas/RuleEnabled' + name: + $ref: '#/components/schemas/AutomationRuleName' + rule: + $ref: '#/components/schemas/AutomationRule' + required: + - action + - name + - rule + type: object CreateNotificationRuleParameters: description: Body of the notification rule create request. properties: @@ -13271,6 +13438,67 @@ components: type: string x-mimetype: application/xml type: object + InboxRule: + description: 'Inbox rules are used to prioritize and add relevant vulnerabilities + to your Security Inbox. + + An inbox rule is composed of a rule UUID, a rule type, and the rule attributes. + All fields are required.' + properties: + attributes: + $ref: '#/components/schemas/InboxRuleAttributes' + id: + $ref: '#/components/schemas/UUID' + type: + $ref: '#/components/schemas/InboxRulesType' + required: + - attributes + - id + - type + type: object + InboxRuleAttributes: + description: Attributes of the inbox rule + properties: + action: + $ref: '#/components/schemas/ActionInbox' + created_at: + $ref: '#/components/schemas/RuleModificationDate' + created_by: + $ref: '#/components/schemas/AutomationRuleUser' + enabled: + $ref: '#/components/schemas/RuleEnabled' + modified_at: + $ref: '#/components/schemas/RuleModificationDate' + modified_by: + $ref: '#/components/schemas/AutomationRuleUser' + name: + $ref: '#/components/schemas/AutomationRuleName' + rule: + $ref: '#/components/schemas/AutomationRule' + required: + - action + - created_at + - created_by + - enabled + - modified_at + - modified_by + - name + - rule + type: object + InboxRuleResponse: + description: Response object which includes an inbox rule. + properties: + data: + $ref: '#/components/schemas/InboxRule' + type: object + InboxRulesType: + description: The pipeline rule type associated to inbox rules + enum: + - inbox_rules + example: inbox_rules + type: string + x-enum-varnames: + - INBOX_RULES IncidentAttachmentAttachmentType: description: The type of the incident attachment attributes. enum: @@ -15405,6 +15633,14 @@ components: - DOWN - WARNING - 'OFF' + IssueType: + description: The type of issues on which the rule applies + enum: + - vulnerability + example: vulnerability + type: string + x-enum-varnames: + - VULNERABILITY JSONAPIErrorItem: description: API error response body properties: @@ -19255,6 +19491,91 @@ components: meta: $ref: '#/components/schemas/MonthlyCostAttributionMeta' type: object + MuteReason: + description: Reason for muting a vulnerability + enum: + - duplicate + - external_solution + - false_positive + - internal_solution + - no_fix_available + - other + - pending_fix + - risk_accepted + example: duplicate + type: string + x-enum-varnames: + - DUPLICATE + - EXTERNAL_SOLUTION + - FALSE_POSITIVE + - INTERNAL_SOLUTION + - NO_FIX_AVAILABLE + - OTHER + - PENDING_FIX + - RISK_ACCEPTED + MuteRule: + description: 'Mute rules are used to proactively filter out known false positives + or accepted risks. + + A mute rule is composed of a rule UUID, a rule type, and the rule attributes. + All fields are required. + + ' + properties: + attributes: + $ref: '#/components/schemas/MuteRuleAttributes' + id: + $ref: '#/components/schemas/UUID' + type: + $ref: '#/components/schemas/MuteRulesType' + required: + - attributes + - id + - type + type: object + MuteRuleAttributes: + description: Attributes of the mute rule + properties: + action: + $ref: '#/components/schemas/ActionMute' + created_at: + $ref: '#/components/schemas/RuleModificationDate' + created_by: + $ref: '#/components/schemas/AutomationRuleUser' + enabled: + $ref: '#/components/schemas/RuleEnabled' + modified_at: + $ref: '#/components/schemas/RuleModificationDate' + modified_by: + $ref: '#/components/schemas/AutomationRuleUser' + name: + $ref: '#/components/schemas/AutomationRuleName' + rule: + $ref: '#/components/schemas/AutomationRule' + required: + - action + - created_at + - created_by + - enabled + - modified_at + - modified_by + - name + - rule + type: object + MuteRuleResponse: + description: Response object which includes a mute rule. + properties: + data: + $ref: '#/components/schemas/MuteRule' + type: object + MuteRulesType: + description: The pipeline rule type associated to mute rules + enum: + - mute_rules + example: mute_rules + type: string + x-enum-varnames: + - MUTE_RULES NotificationRule: description: 'Notification rules allow full control over notifications generated by the various Datadog security products. @@ -20186,6 +20507,74 @@ components: $ref: '#/components/schemas/ApplicationKeyResponseIncludedItem' type: array type: object + PatchInboxRulesParameters: + description: Body of the inbox rule patch request + properties: + data: + $ref: '#/components/schemas/PatchInboxRulesParametersData' + type: object + PatchInboxRulesParametersData: + description: 'Data of the inbox rule patch request: the rule UUID, the rule + type, and the rule attributes. All fields are required.' + properties: + attributes: + $ref: '#/components/schemas/PatchInboxRulesParametersDataAttributes' + id: + $ref: '#/components/schemas/UUID' + type: + $ref: '#/components/schemas/InboxRulesType' + required: + - attributes + - id + - type + type: object + PatchInboxRulesParametersDataAttributes: + description: 'Attributes of the inbox rule patch request: the rule name, the + rule details, the associated action, and the enabled field.' + properties: + action: + $ref: '#/components/schemas/ActionInbox' + enabled: + $ref: '#/components/schemas/RuleEnabled' + name: + $ref: '#/components/schemas/AutomationRuleName' + rule: + $ref: '#/components/schemas/AutomationRule' + type: object + PatchMuteRuleParameters: + description: Body of the mute rule patch request + properties: + data: + $ref: '#/components/schemas/PatchMuteRuleParametersData' + type: object + PatchMuteRuleParametersData: + description: 'Data of the mute rule patch request: the rule UUID, the rule type, + and the rule attributes. All fields are required.' + properties: + attributes: + $ref: '#/components/schemas/PatchMuteRuleParametersDataAttributes' + id: + $ref: '#/components/schemas/UUID' + type: + $ref: '#/components/schemas/MuteRulesType' + required: + - attributes + - id + - type + type: object + PatchMuteRuleParametersDataAttributes: + description: 'Attributes of the mute rule patch request: the rule name, the + rule details, the associated action, and the enabled field.' + properties: + action: + $ref: '#/components/schemas/ActionMute' + enabled: + $ref: '#/components/schemas/RuleEnabled' + name: + $ref: '#/components/schemas/AutomationRuleName' + rule: + $ref: '#/components/schemas/AutomationRule' + type: object PatchNotificationRuleParameters: description: Body of the notification rule patch request. properties: @@ -22227,6 +22616,50 @@ components: - new_advisories - avoided_advisories type: object + ReorderInboxRulesParameters: + description: 'Body of the inbox rule reorder request: the full list of inbox + rules, which must be provided in the new order.' + properties: + data: + description: The `ReorderInboxRulesParameters` `data`. + items: + $ref: '#/components/schemas/ReorderInboxRulesParametersData' + type: array + type: object + ReorderInboxRulesParametersData: + description: 'Data of the inbox rule reorder request: the rule UUID, the rule + type, and the rule attributes. All fields are required.' + properties: + id: + $ref: '#/components/schemas/UUID' + type: + $ref: '#/components/schemas/InboxRulesType' + required: + - id + - type + type: object + ReorderMuteRulesParameters: + description: 'Body of the mute rule reorder request: the full list of mute rules, + which must be provided in the new order.' + properties: + data: + description: The `ReorderMuteRulesParameters` `data`. + items: + $ref: '#/components/schemas/ReorderMuteRulesParametersData' + type: array + type: object + ReorderMuteRulesParametersData: + description: 'Data of the mute rule reorder request: a rule UUID and its type. + All fields are required.' + properties: + id: + $ref: '#/components/schemas/UUID' + type: + $ref: '#/components/schemas/MuteRulesType' + required: + - id + - type + type: object ReorderRetentionFiltersRequest: description: A list of retention filters to reorder. properties: @@ -22911,10 +23344,26 @@ components: example: Deployments automated via Deployment Trains type: string type: object + RuleEnabled: + description: Field used to enable or disable the rule. + example: true + type: boolean RuleId: description: The unique ID for a scorecard rule. example: q8MQxk8TCqrHnWkx type: string + RuleIds: + description: Security rule ids + items: + description: Id of a rule + example: rule-id-1 + type: string + type: array + RuleModificationDate: + description: Date as Unix timestamp in milliseconds + example: 1722439510282 + format: int64 + type: integer RuleName: description: Name of the notification rule. example: Rule 1 @@ -22925,6 +23374,11 @@ components: rule: $ref: '#/components/schemas/RelationshipToOutcome' type: object + RuleQuery: + description: The query is composed of one or several key:value pairs, which + can be used to filter resources on tags and attributes. + example: key:val + type: string RuleSeverity: description: Severity of a security rule. enum: @@ -25894,6 +26348,52 @@ components: nullable: true type: string type: object + SecurityRuleSeverity: + description: Severity of a security rule + enum: + - critical + - high + - medium + - low + - unknown + - info + example: critical + type: string + x-enum-varnames: + - CRITICAL + - HIGH + - MEDIUM + - LOW + - UNKNOWN + - INFO + SecurityRuleTypes: + description: Security rule types + example: + - application_code_vulnerability + items: + $ref: '#/components/schemas/SecurityRuleTypesItems' + type: array + SecurityRuleTypesItems: + description: Security rule type + enum: + - application_code_vulnerability + - application_library_vulnerability + - attack_path + - container_image_vulnerability + - host_vulnerability + - identity_risk + - misconfiguration + - api_security + type: string + x-enum-varnames: + - APPLICATION_CODE_VULNERABILITY + - APPLICATION_LIBRARY_VULNERABILITY + - ATTACK_PATH + - CONTAINER_IMAGE_VULNERABILITY + - HOST_VULNERABILITY + - IDENTITY_RISK + - MISCONFIGURATION + - API_SECURITY Selectors: description: 'Selectors are used to filter security issues for which notifications should be generated. @@ -29421,6 +29921,11 @@ components: x-enum-varnames: - SECURITY_FINDINGS - SECURITY_SIGNALS + UUID: + description: The ID of a pipeline rule + example: 123e4567-e89b-12d3-a456-426655440000 + format: uuid + type: string Unit: description: Object containing the metric unit family, scale factor, name, and short name. @@ -29641,6 +30146,48 @@ components: type: string type: array type: object + UpdateInboxRuleParameters: + description: Body of the inbox rule update request + properties: + data: + $ref: '#/components/schemas/UpdateInboxRuleParametersData' + type: object + UpdateInboxRuleParametersData: + description: 'Data of the inbox rule update request: the rule id, the rule type, + and the rule attributes. All fields are required.' + properties: + attributes: + $ref: '#/components/schemas/CreateInboxRuleParametersDataAttributes' + id: + $ref: '#/components/schemas/UUID' + type: + $ref: '#/components/schemas/InboxRulesType' + required: + - id + - attributes + - type + type: object + UpdateMuteRuleParameters: + description: Body of the mute rule update request + properties: + data: + $ref: '#/components/schemas/UpdateMuteRuleParametersData' + type: object + UpdateMuteRuleParametersData: + description: 'Data of the mute rule update request: the rule id, the rule type, + and the rule attributes. All fields are required.' + properties: + attributes: + $ref: '#/components/schemas/CreateMuteRuleParametersDataAttributes' + id: + $ref: '#/components/schemas/UUID' + type: + $ref: '#/components/schemas/MuteRulesType' + required: + - id + - attributes + - type + type: object UpdateOpenAPIResponse: description: Response for `UpdateOpenAPI`. properties: @@ -44442,6 +44989,559 @@ paths: operator: OR permissions: - security_monitoring_notification_profiles_write + /api/v2/security/vulnerabilities/pipelines/inbox_rules: + get: + description: Returns the ordered list of inbox rules in the pipeline (first + match applies) + operationId: GetInboxRules + responses: + '200': + $ref: '#/components/responses/InboxRulesList' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_read + summary: Get the ordered list of inbox rules + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_pipelines_read + post: + description: Create a new inbox rule and return the created rule. + operationId: CreateInboxRule + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateInboxRuleParameters' + description: 'Mandatory fields are the rule type and the required attributes: + rule name, rule details, and action. + + The rule details are composed of issue types and security rule types on + which the rule applies. Optional security rule IDs, severities, and a tag + or attribute query can be provided. + + The action is composed of the optional reason description. + + ' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/InboxRuleResponse' + description: Successfully created the inbox rule + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Create a new inbox rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_pipelines_write + /api/v2/security/vulnerabilities/pipelines/inbox_rules/reorder: + post: + description: 'Reorder the list of inbox rules in the pipeline and return the + reordered list of rules. + + To reorder fields, you must provide the full list of pipeline rules in the + new order.' + operationId: ReorderInboxRules + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ReorderInboxRulesParameters' + description: 'The list of rules to reorder. The order of the rules in the + list becomes the new order in the pipeline. + + ' + required: true + responses: + '200': + $ref: '#/components/responses/InboxRulesList' + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Reorder the list of inbox rules in the pipeline + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_pipelines_write + /api/v2/security/vulnerabilities/pipelines/inbox_rules/{inbox_rule_id}: + delete: + description: Delete an inbox rule + operationId: DeleteInboxRule + parameters: + - description: ID of the inbox rule + in: path + name: inbox_rule_id + required: true + schema: + format: uuid + type: string + responses: + '204': + description: Rule successfully deleted + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Delete an inbox rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_pipelines_write + get: + description: Get the details of an inbox rule. + operationId: GetInboxRule + parameters: + - description: ID of the inbox rule + in: path + name: inbox_rule_id + required: true + schema: + format: uuid + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/InboxRuleResponse' + description: Inbox rule details + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_read + summary: Get details of an inbox rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_pipelines_read + patch: + description: Partially update the inbox rule. All fields are optional; if a + field is not provided, it is not updated. + operationId: PatchInboxRule + parameters: + - description: ID of the inbox rule + in: path + name: inbox_rule_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatchInboxRulesParameters' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/InboxRuleResponse' + description: Inbox rule successfully patched + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '422': + $ref: '#/components/responses/AutomationRuleUnprocessableEntityResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Patch an inbox rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_pipelines_write + put: + description: Update the whole inbox rule. If an optional field is not provided, + it is set to its default value. + operationId: UpdateInboxRule + parameters: + - description: ID of the inbox rule + in: path + name: inbox_rule_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateInboxRuleParameters' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/InboxRuleResponse' + description: Inbox rule successfully updated + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '422': + $ref: '#/components/responses/AutomationRuleUnprocessableEntityResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Update an inbox rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_pipelines_write + /api/v2/security/vulnerabilities/pipelines/mute_rules: + get: + description: Returns the ordered list of mute rules in the pipeline (first match + applies) + operationId: GetMuteRules + responses: + '200': + $ref: '#/components/responses/MuteRulesList' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_read + summary: Get the ordered list of mute rules + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_pipelines_read + post: + description: Create a new mute rule and return the created rule. + operationId: CreateMuteRule + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateMuteRuleParameters' + description: 'Mandatory fields are the rule type and the required attributes: + rule name, rule details, and action. + + The rule details are composed of issue types and security rule types on + which the rule applies. Optional security rule IDs, severities, and a tag + or attribute query can be provided. + + The action is composed of the reason for muting and the rule expiration + date, and optionally a description of the rule. + + ' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/MuteRuleResponse' + description: Successfully created the mute rule + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Create a new mute rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_pipelines_write + /api/v2/security/vulnerabilities/pipelines/mute_rules/reorder: + post: + description: 'Reorder the list of mute rules in the pipeline and return the + reordered list of rules. + + To reorder fields, you must provide the full list of pipeline rules in the + new order.' + operationId: ReorderMuteRules + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ReorderMuteRulesParameters' + description: 'The list of rules to reorder. The order of the rules in the + list becomes the new order in the pipeline. + + ' + required: true + responses: + '200': + $ref: '#/components/responses/MuteRulesList' + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Reorder the list of mute rules in the pipeline + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_pipelines_write + /api/v2/security/vulnerabilities/pipelines/mute_rules/{mute_rule_id}: + delete: + description: Delete a mute rule + operationId: DeleteMuteRule + parameters: + - description: ID of the mute rule + in: path + name: mute_rule_id + required: true + schema: + format: uuid + type: string + responses: + '204': + description: Rule successfully deleted + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Delete a mute rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_pipelines_write + get: + description: Get the details of a mute rule. + operationId: GetMuteRule + parameters: + - description: ID of the mute rule + in: path + name: mute_rule_id + required: true + schema: + format: uuid + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/MuteRuleResponse' + description: Mute rule details + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_read + summary: Get details of a mute rule + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_pipelines_read + patch: + description: Partially update the mute rule. All fields are optional; if a field + is not provided, it is not updated. + operationId: PatchMuteRule + parameters: + - description: ID of the mute rule + in: path + name: mute_rule_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PatchMuteRuleParameters' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/MuteRuleResponse' + description: Mute rule successfully patched + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '422': + $ref: '#/components/responses/AutomationRuleUnprocessableEntityResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Patch a mute rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_pipelines_write + put: + description: Update the whole mute rule. If an optional field is not provided, + it is set to its default value. + operationId: UpdateMuteRule + parameters: + - description: ID of the mute rule + in: path + name: mute_rule_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateMuteRuleParameters' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/MuteRuleResponse' + description: Mute rule successfully updated + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '422': + $ref: '#/components/responses/AutomationRuleUnprocessableEntityResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_pipelines_write + summary: Update a mute rule + tags: + - Security Monitoring + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - security_pipelines_write /api/v2/security_monitoring/cloud_workload_security/agent_rules: get: description: Get the list of Agent rules. diff --git a/examples/v2_security-monitoring_CreateInboxRule.rs b/examples/v2_security-monitoring_CreateInboxRule.rs new file mode 100644 index 000000000..f1f798fa5 --- /dev/null +++ b/examples/v2_security-monitoring_CreateInboxRule.rs @@ -0,0 +1,39 @@ +// Create a new inbox rule returns "Successfully created the inbox rule" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; +use datadog_api_client::datadogV2::model::ActionInbox; +use datadog_api_client::datadogV2::model::AutomationRule; +use datadog_api_client::datadogV2::model::CreateInboxRuleParameters; +use datadog_api_client::datadogV2::model::CreateInboxRuleParametersData; +use datadog_api_client::datadogV2::model::CreateInboxRuleParametersDataAttributes; +use datadog_api_client::datadogV2::model::InboxRulesType; +use datadog_api_client::datadogV2::model::IssueType; +use datadog_api_client::datadogV2::model::SecurityRuleSeverity; +use datadog_api_client::datadogV2::model::SecurityRuleTypesItems; + +#[tokio::main] +async fn main() { + let body = CreateInboxRuleParameters::new().data(CreateInboxRuleParametersData::new( + CreateInboxRuleParametersDataAttributes::new( + ActionInbox::new().reason_description("We want to focus on these items.".to_string()), + "Rule 1".to_string(), + AutomationRule::new( + IssueType::VULNERABILITY, + vec![SecurityRuleTypesItems::APPLICATION_CODE_VULNERABILITY], + ) + .query("key:val".to_string()) + .rule_ids(vec!["rule-id-1".to_string()]) + .severities(vec![SecurityRuleSeverity::CRITICAL]), + ) + .enabled(true), + InboxRulesType::INBOX_RULES, + )); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api.create_inbox_rule(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_CreateMuteRule.rs b/examples/v2_security-monitoring_CreateMuteRule.rs new file mode 100644 index 000000000..66d5abaef --- /dev/null +++ b/examples/v2_security-monitoring_CreateMuteRule.rs @@ -0,0 +1,42 @@ +// Create a new mute rule returns "Successfully created the mute rule" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; +use datadog_api_client::datadogV2::model::ActionMute; +use datadog_api_client::datadogV2::model::AutomationRule; +use datadog_api_client::datadogV2::model::CreateMuteRuleParameters; +use datadog_api_client::datadogV2::model::CreateMuteRuleParametersData; +use datadog_api_client::datadogV2::model::CreateMuteRuleParametersDataAttributes; +use datadog_api_client::datadogV2::model::IssueType; +use datadog_api_client::datadogV2::model::MuteReason; +use datadog_api_client::datadogV2::model::MuteRulesType; +use datadog_api_client::datadogV2::model::SecurityRuleSeverity; +use datadog_api_client::datadogV2::model::SecurityRuleTypesItems; + +#[tokio::main] +async fn main() { + let body = CreateMuteRuleParameters::new().data(CreateMuteRuleParametersData::new( + CreateMuteRuleParametersDataAttributes::new( + ActionMute::new(MuteReason::DUPLICATE) + .expire_at(1893452400000) + .reason_description("Muting for a while".to_string()), + "Rule 1".to_string(), + AutomationRule::new( + IssueType::VULNERABILITY, + vec![SecurityRuleTypesItems::APPLICATION_CODE_VULNERABILITY], + ) + .query("key:val".to_string()) + .rule_ids(vec!["rule-id-1".to_string()]) + .severities(vec![SecurityRuleSeverity::CRITICAL]), + ) + .enabled(true), + MuteRulesType::MUTE_RULES, + )); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api.create_mute_rule(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_DeleteInboxRule.rs b/examples/v2_security-monitoring_DeleteInboxRule.rs new file mode 100644 index 000000000..90302023b --- /dev/null +++ b/examples/v2_security-monitoring_DeleteInboxRule.rs @@ -0,0 +1,21 @@ +// Delete an inbox rule returns "Rule successfully deleted" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; + +#[tokio::main] +async fn main() { + // there is a valid "valid_inbox_rule" in the system + let valid_inbox_rule_data_id = + uuid::Uuid::parse_str(&std::env::var("VALID_INBOX_RULE_DATA_ID").unwrap()) + .expect("Invalid UUID"); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api + .delete_inbox_rule(valid_inbox_rule_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_DeleteMuteRule.rs b/examples/v2_security-monitoring_DeleteMuteRule.rs new file mode 100644 index 000000000..5e62c879a --- /dev/null +++ b/examples/v2_security-monitoring_DeleteMuteRule.rs @@ -0,0 +1,19 @@ +// Delete a mute rule returns "Rule successfully deleted" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; + +#[tokio::main] +async fn main() { + // there is a valid "valid_mute_rule" in the system + let valid_mute_rule_data_id = + uuid::Uuid::parse_str(&std::env::var("VALID_MUTE_RULE_DATA_ID").unwrap()) + .expect("Invalid UUID"); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api.delete_mute_rule(valid_mute_rule_data_id.clone()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_GetInboxRule.rs b/examples/v2_security-monitoring_GetInboxRule.rs new file mode 100644 index 000000000..1b032b783 --- /dev/null +++ b/examples/v2_security-monitoring_GetInboxRule.rs @@ -0,0 +1,19 @@ +// Get details of an inbox rule returns "Inbox rule details" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; + +#[tokio::main] +async fn main() { + // there is a valid "valid_inbox_rule" in the system + let valid_inbox_rule_data_id = + uuid::Uuid::parse_str(&std::env::var("VALID_INBOX_RULE_DATA_ID").unwrap()) + .expect("Invalid UUID"); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api.get_inbox_rule(valid_inbox_rule_data_id.clone()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_GetInboxRules.rs b/examples/v2_security-monitoring_GetInboxRules.rs new file mode 100644 index 000000000..d57a6ce4f --- /dev/null +++ b/examples/v2_security-monitoring_GetInboxRules.rs @@ -0,0 +1,15 @@ +// Get the ordered list of inbox rules returns "The list of inbox rules" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api.get_inbox_rules().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_GetMuteRule.rs b/examples/v2_security-monitoring_GetMuteRule.rs new file mode 100644 index 000000000..8f10620de --- /dev/null +++ b/examples/v2_security-monitoring_GetMuteRule.rs @@ -0,0 +1,19 @@ +// Get details of a mute rule returns "Mute rule details" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; + +#[tokio::main] +async fn main() { + // there is a valid "valid_mute_rule" in the system + let valid_mute_rule_data_id = + uuid::Uuid::parse_str(&std::env::var("VALID_MUTE_RULE_DATA_ID").unwrap()) + .expect("Invalid UUID"); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api.get_mute_rule(valid_mute_rule_data_id.clone()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_GetMuteRules.rs b/examples/v2_security-monitoring_GetMuteRules.rs new file mode 100644 index 000000000..44366eb06 --- /dev/null +++ b/examples/v2_security-monitoring_GetMuteRules.rs @@ -0,0 +1,15 @@ +// Get the ordered list of mute rules returns "The list of mute rules" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api.get_mute_rules().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_PatchInboxRule.rs b/examples/v2_security-monitoring_PatchInboxRule.rs new file mode 100644 index 000000000..66f129d0b --- /dev/null +++ b/examples/v2_security-monitoring_PatchInboxRule.rs @@ -0,0 +1,50 @@ +// Patch an inbox rule returns "Inbox rule successfully patched" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; +use datadog_api_client::datadogV2::model::ActionInbox; +use datadog_api_client::datadogV2::model::AutomationRule; +use datadog_api_client::datadogV2::model::InboxRulesType; +use datadog_api_client::datadogV2::model::IssueType; +use datadog_api_client::datadogV2::model::PatchInboxRulesParameters; +use datadog_api_client::datadogV2::model::PatchInboxRulesParametersData; +use datadog_api_client::datadogV2::model::PatchInboxRulesParametersDataAttributes; +use datadog_api_client::datadogV2::model::SecurityRuleSeverity; +use datadog_api_client::datadogV2::model::SecurityRuleTypesItems; + +#[tokio::main] +async fn main() { + // there is a valid "valid_inbox_rule" in the system + let valid_inbox_rule_data_id = + uuid::Uuid::parse_str(&std::env::var("VALID_INBOX_RULE_DATA_ID").unwrap()) + .expect("Invalid UUID"); + let body = PatchInboxRulesParameters::new().data(PatchInboxRulesParametersData::new( + PatchInboxRulesParametersDataAttributes::new() + .action( + ActionInbox::new() + .reason_description("We want to focus on these items.".to_string()), + ) + .enabled(true) + .name("Rule 1".to_string()) + .rule( + AutomationRule::new( + IssueType::VULNERABILITY, + vec![SecurityRuleTypesItems::APPLICATION_CODE_VULNERABILITY], + ) + .query("key:val".to_string()) + .rule_ids(vec!["rule-id-1".to_string()]) + .severities(vec![SecurityRuleSeverity::CRITICAL]), + ), + valid_inbox_rule_data_id.clone(), + InboxRulesType::INBOX_RULES, + )); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api + .patch_inbox_rule(valid_inbox_rule_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_PatchMuteRule.rs b/examples/v2_security-monitoring_PatchMuteRule.rs new file mode 100644 index 000000000..ffe62c6b4 --- /dev/null +++ b/examples/v2_security-monitoring_PatchMuteRule.rs @@ -0,0 +1,52 @@ +// Patch a mute rule returns "Mute rule successfully patched" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; +use datadog_api_client::datadogV2::model::ActionMute; +use datadog_api_client::datadogV2::model::AutomationRule; +use datadog_api_client::datadogV2::model::IssueType; +use datadog_api_client::datadogV2::model::MuteReason; +use datadog_api_client::datadogV2::model::MuteRulesType; +use datadog_api_client::datadogV2::model::PatchMuteRuleParameters; +use datadog_api_client::datadogV2::model::PatchMuteRuleParametersData; +use datadog_api_client::datadogV2::model::PatchMuteRuleParametersDataAttributes; +use datadog_api_client::datadogV2::model::SecurityRuleSeverity; +use datadog_api_client::datadogV2::model::SecurityRuleTypesItems; + +#[tokio::main] +async fn main() { + // there is a valid "valid_mute_rule" in the system + let valid_mute_rule_data_id = + uuid::Uuid::parse_str(&std::env::var("VALID_MUTE_RULE_DATA_ID").unwrap()) + .expect("Invalid UUID"); + let body = PatchMuteRuleParameters::new().data(PatchMuteRuleParametersData::new( + PatchMuteRuleParametersDataAttributes::new() + .action( + ActionMute::new(MuteReason::DUPLICATE) + .expire_at(1893452400000) + .reason_description("Muting for a while".to_string()), + ) + .enabled(true) + .name("Rule 1".to_string()) + .rule( + AutomationRule::new( + IssueType::VULNERABILITY, + vec![SecurityRuleTypesItems::APPLICATION_CODE_VULNERABILITY], + ) + .query("key:val".to_string()) + .rule_ids(vec!["rule-id-1".to_string()]) + .severities(vec![SecurityRuleSeverity::CRITICAL]), + ), + valid_mute_rule_data_id.clone(), + MuteRulesType::MUTE_RULES, + )); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api + .patch_mute_rule(valid_mute_rule_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_ReorderInboxRules.rs b/examples/v2_security-monitoring_ReorderInboxRules.rs new file mode 100644 index 000000000..de037288a --- /dev/null +++ b/examples/v2_security-monitoring_ReorderInboxRules.rs @@ -0,0 +1,24 @@ +// Reorder the list of inbox rules in the pipeline returns "The list of inbox +// rules" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; +use datadog_api_client::datadogV2::model::InboxRulesType; +use datadog_api_client::datadogV2::model::ReorderInboxRulesParameters; +use datadog_api_client::datadogV2::model::ReorderInboxRulesParametersData; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = ReorderInboxRulesParameters::new().data(vec![ReorderInboxRulesParametersData::new( + Uuid::parse_str("123e4567-e89b-12d3-a456-426655440000").expect("invalid UUID"), + InboxRulesType::INBOX_RULES, + )]); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api.reorder_inbox_rules(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_ReorderMuteRules.rs b/examples/v2_security-monitoring_ReorderMuteRules.rs new file mode 100644 index 000000000..cab93464d --- /dev/null +++ b/examples/v2_security-monitoring_ReorderMuteRules.rs @@ -0,0 +1,24 @@ +// Reorder the list of mute rules in the pipeline returns "The list of mute rules" +// response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; +use datadog_api_client::datadogV2::model::MuteRulesType; +use datadog_api_client::datadogV2::model::ReorderMuteRulesParameters; +use datadog_api_client::datadogV2::model::ReorderMuteRulesParametersData; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = ReorderMuteRulesParameters::new().data(vec![ReorderMuteRulesParametersData::new( + Uuid::parse_str("123e4567-e89b-12d3-a456-426655440000").expect("invalid UUID"), + MuteRulesType::MUTE_RULES, + )]); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api.reorder_mute_rules(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_UpdateInboxRule.rs b/examples/v2_security-monitoring_UpdateInboxRule.rs new file mode 100644 index 000000000..0726296e7 --- /dev/null +++ b/examples/v2_security-monitoring_UpdateInboxRule.rs @@ -0,0 +1,46 @@ +// Update an inbox rule returns "Inbox rule successfully updated" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; +use datadog_api_client::datadogV2::model::ActionInbox; +use datadog_api_client::datadogV2::model::AutomationRule; +use datadog_api_client::datadogV2::model::CreateInboxRuleParametersDataAttributes; +use datadog_api_client::datadogV2::model::InboxRulesType; +use datadog_api_client::datadogV2::model::IssueType; +use datadog_api_client::datadogV2::model::SecurityRuleSeverity; +use datadog_api_client::datadogV2::model::SecurityRuleTypesItems; +use datadog_api_client::datadogV2::model::UpdateInboxRuleParameters; +use datadog_api_client::datadogV2::model::UpdateInboxRuleParametersData; + +#[tokio::main] +async fn main() { + // there is a valid "valid_inbox_rule" in the system + let valid_inbox_rule_data_id = + uuid::Uuid::parse_str(&std::env::var("VALID_INBOX_RULE_DATA_ID").unwrap()) + .expect("Invalid UUID"); + let body = UpdateInboxRuleParameters::new().data(UpdateInboxRuleParametersData::new( + CreateInboxRuleParametersDataAttributes::new( + ActionInbox::new().reason_description("We want to focus on these items.".to_string()), + "Rule 1".to_string(), + AutomationRule::new( + IssueType::VULNERABILITY, + vec![SecurityRuleTypesItems::APPLICATION_CODE_VULNERABILITY], + ) + .query("key:val".to_string()) + .rule_ids(vec!["rule-id-1".to_string()]) + .severities(vec![SecurityRuleSeverity::CRITICAL]), + ) + .enabled(true), + valid_inbox_rule_data_id.clone(), + InboxRulesType::INBOX_RULES, + )); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api + .update_inbox_rule(valid_inbox_rule_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_security-monitoring_UpdateMuteRule.rs b/examples/v2_security-monitoring_UpdateMuteRule.rs new file mode 100644 index 000000000..880985acc --- /dev/null +++ b/examples/v2_security-monitoring_UpdateMuteRule.rs @@ -0,0 +1,49 @@ +// Update a mute rule returns "Mute rule successfully updated" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_security_monitoring::SecurityMonitoringAPI; +use datadog_api_client::datadogV2::model::ActionMute; +use datadog_api_client::datadogV2::model::AutomationRule; +use datadog_api_client::datadogV2::model::CreateMuteRuleParametersDataAttributes; +use datadog_api_client::datadogV2::model::IssueType; +use datadog_api_client::datadogV2::model::MuteReason; +use datadog_api_client::datadogV2::model::MuteRulesType; +use datadog_api_client::datadogV2::model::SecurityRuleSeverity; +use datadog_api_client::datadogV2::model::SecurityRuleTypesItems; +use datadog_api_client::datadogV2::model::UpdateMuteRuleParameters; +use datadog_api_client::datadogV2::model::UpdateMuteRuleParametersData; + +#[tokio::main] +async fn main() { + // there is a valid "valid_mute_rule" in the system + let valid_mute_rule_data_id = + uuid::Uuid::parse_str(&std::env::var("VALID_MUTE_RULE_DATA_ID").unwrap()) + .expect("Invalid UUID"); + let body = UpdateMuteRuleParameters::new().data(UpdateMuteRuleParametersData::new( + CreateMuteRuleParametersDataAttributes::new( + ActionMute::new(MuteReason::DUPLICATE) + .expire_at(1893452400000) + .reason_description("Muting for a while".to_string()), + "Rule 1".to_string(), + AutomationRule::new( + IssueType::VULNERABILITY, + vec![SecurityRuleTypesItems::APPLICATION_CODE_VULNERABILITY], + ) + .query("key:val".to_string()) + .rule_ids(vec!["rule-id-1".to_string()]) + .severities(vec![SecurityRuleSeverity::CRITICAL]), + ) + .enabled(true), + valid_mute_rule_data_id.clone(), + MuteRulesType::MUTE_RULES, + )); + let configuration = datadog::Configuration::new(); + let api = SecurityMonitoringAPI::with_config(configuration); + let resp = api + .update_mute_rule(valid_mute_rule_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_security_monitoring.rs b/src/datadogV2/api/api_security_monitoring.rs index 8549fe979..20e21a88a 100644 --- a/src/datadogV2/api/api_security_monitoring.rs +++ b/src/datadogV2/api/api_security_monitoring.rs @@ -730,6 +730,22 @@ pub enum ConvertSecurityMonitoringRuleFromJSONToTerraformError { UnknownValue(serde_json::Value), } +/// CreateInboxRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::create_inbox_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateInboxRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// CreateMuteRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::create_mute_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateMuteRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::create_security_filter`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -778,6 +794,22 @@ pub enum DeleteHistoricalJobError { UnknownValue(serde_json::Value), } +/// DeleteInboxRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_inbox_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteInboxRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteMuteRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_mute_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteMuteRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// DeleteSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::delete_security_filter`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -858,6 +890,38 @@ pub enum GetHistoricalJobError { UnknownValue(serde_json::Value), } +/// GetInboxRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_inbox_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetInboxRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetInboxRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::get_inbox_rules`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetInboxRulesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetMuteRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::get_mute_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetMuteRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetMuteRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::get_mute_rules`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetMuteRulesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetSBOMError is a struct for typed errors of method [`SecurityMonitoringAPI::get_sbom`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1005,6 +1069,24 @@ pub enum MuteFindingsError { UnknownValue(serde_json::Value), } +/// PatchInboxRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::patch_inbox_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchInboxRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// PatchMuteRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::patch_mute_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchMuteRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + UnknownValue(serde_json::Value), +} + /// PatchSignalNotificationRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::patch_signal_notification_rule`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1023,6 +1105,22 @@ pub enum PatchVulnerabilityNotificationRuleError { UnknownValue(serde_json::Value), } +/// ReorderInboxRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::reorder_inbox_rules`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ReorderInboxRulesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ReorderMuteRulesError is a struct for typed errors of method [`SecurityMonitoringAPI::reorder_mute_rules`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ReorderMuteRulesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// RunHistoricalJobError is a struct for typed errors of method [`SecurityMonitoringAPI::run_historical_job`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1055,6 +1153,24 @@ pub enum TestSecurityMonitoringRuleError { UnknownValue(serde_json::Value), } +/// UpdateInboxRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::update_inbox_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateInboxRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpdateMuteRuleError is a struct for typed errors of method [`SecurityMonitoringAPI::update_mute_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateMuteRuleError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpdateSecurityFilterError is a struct for typed errors of method [`SecurityMonitoringAPI::update_security_filter`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1664,18 +1780,13 @@ impl SecurityMonitoringAPI { } } - /// Create a security filter. - /// - /// See the [security filter guide]() - /// for more examples. - pub async fn create_security_filter( + /// Create a new inbox rule and return the created rule. + pub async fn create_inbox_rule( &self, - body: crate::datadogV2::model::SecurityFilterCreateRequest, - ) -> Result< - crate::datadogV2::model::SecurityFilterResponse, - datadog::Error, - > { - match self.create_security_filter_with_http_info(body).await { + body: crate::datadogV2::model::CreateInboxRuleParameters, + ) -> Result> + { + match self.create_inbox_rule_with_http_info(body).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -1689,24 +1800,21 @@ impl SecurityMonitoringAPI { } } - /// Create a security filter. - /// - /// See the [security filter guide]() - /// for more examples. - pub async fn create_security_filter_with_http_info( + /// Create a new inbox rule and return the created rule. + pub async fn create_inbox_rule_with_http_info( &self, - body: crate::datadogV2::model::SecurityFilterCreateRequest, + body: crate::datadogV2::model::CreateInboxRuleParameters, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.create_security_filter"; + let operation_id = "v2.create_inbox_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/configuration/security_filters", + "{}/api/v2/security/vulnerabilities/pipelines/inbox_rules", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -1800,9 +1908,8 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -1813,7 +1920,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -1824,18 +1931,13 @@ impl SecurityMonitoringAPI { } } - /// Create a detection rule. - pub async fn create_security_monitoring_rule( + /// Create a new mute rule and return the created rule. + pub async fn create_mute_rule( &self, - body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload, - ) -> Result< - crate::datadogV2::model::SecurityMonitoringRuleResponse, - datadog::Error, - > { - match self - .create_security_monitoring_rule_with_http_info(body) - .await - { + body: crate::datadogV2::model::CreateMuteRuleParameters, + ) -> Result> + { + match self.create_mute_rule_with_http_info(body).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -1849,21 +1951,21 @@ impl SecurityMonitoringAPI { } } - /// Create a detection rule. - pub async fn create_security_monitoring_rule_with_http_info( + /// Create a new mute rule and return the created rule. + pub async fn create_mute_rule_with_http_info( &self, - body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload, + body: crate::datadogV2::model::CreateMuteRuleParameters, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.create_security_monitoring_rule"; + let operation_id = "v2.create_mute_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/rules", + "{}/api/v2/security/vulnerabilities/pipelines/mute_rules", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -1957,9 +2059,8 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -1970,7 +2071,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -1981,18 +2082,18 @@ impl SecurityMonitoringAPI { } } - /// Create a new suppression rule. - pub async fn create_security_monitoring_suppression( + /// Create a security filter. + /// + /// See the [security filter guide]() + /// for more examples. + pub async fn create_security_filter( &self, - body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest, + body: crate::datadogV2::model::SecurityFilterCreateRequest, ) -> Result< - crate::datadogV2::model::SecurityMonitoringSuppressionResponse, - datadog::Error, + crate::datadogV2::model::SecurityFilterResponse, + datadog::Error, > { - match self - .create_security_monitoring_suppression_with_http_info(body) - .await - { + match self.create_security_filter_with_http_info(body).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -2006,21 +2107,24 @@ impl SecurityMonitoringAPI { } } - /// Create a new suppression rule. - pub async fn create_security_monitoring_suppression_with_http_info( + /// Create a security filter. + /// + /// See the [security filter guide]() + /// for more examples. + pub async fn create_security_filter_with_http_info( &self, - body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest, + body: crate::datadogV2::model::SecurityFilterCreateRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.create_security_monitoring_suppression"; + let operation_id = "v2.create_security_filter"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/configuration/suppressions", + "{}/api/v2/security_monitoring/configuration/security_filters", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -2114,10 +2218,9 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::< - crate::datadogV2::model::SecurityMonitoringSuppressionResponse, - >(&local_content) - { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -2128,7 +2231,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2139,16 +2242,16 @@ impl SecurityMonitoringAPI { } } - /// Create a new notification rule for security signals and return the created rule. - pub async fn create_signal_notification_rule( + /// Create a detection rule. + pub async fn create_security_monitoring_rule( &self, - body: crate::datadogV2::model::CreateNotificationRuleParameters, + body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload, ) -> Result< - crate::datadogV2::model::NotificationRuleResponse, - datadog::Error, + crate::datadogV2::model::SecurityMonitoringRuleResponse, + datadog::Error, > { match self - .create_signal_notification_rule_with_http_info(body) + .create_security_monitoring_rule_with_http_info(body) .await { Ok(response_content) => { @@ -2164,21 +2267,21 @@ impl SecurityMonitoringAPI { } } - /// Create a new notification rule for security signals and return the created rule. - pub async fn create_signal_notification_rule_with_http_info( + /// Create a detection rule. + pub async fn create_security_monitoring_rule_with_http_info( &self, - body: crate::datadogV2::model::CreateNotificationRuleParameters, + body: crate::datadogV2::model::SecurityMonitoringRuleCreatePayload, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.create_signal_notification_rule"; + let operation_id = "v2.create_security_monitoring_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/signals/notification_rules", + "{}/api/v2/security_monitoring/rules", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -2272,7 +2375,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -2285,7 +2388,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2296,16 +2399,16 @@ impl SecurityMonitoringAPI { } } - /// Create a new notification rule for security vulnerabilities and return the created rule. - pub async fn create_vulnerability_notification_rule( + /// Create a new suppression rule. + pub async fn create_security_monitoring_suppression( &self, - body: crate::datadogV2::model::CreateNotificationRuleParameters, + body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest, ) -> Result< - crate::datadogV2::model::NotificationRuleResponse, - datadog::Error, + crate::datadogV2::model::SecurityMonitoringSuppressionResponse, + datadog::Error, > { match self - .create_vulnerability_notification_rule_with_http_info(body) + .create_security_monitoring_suppression_with_http_info(body) .await { Ok(response_content) => { @@ -2321,21 +2424,21 @@ impl SecurityMonitoringAPI { } } - /// Create a new notification rule for security vulnerabilities and return the created rule. - pub async fn create_vulnerability_notification_rule_with_http_info( + /// Create a new suppression rule. + pub async fn create_security_monitoring_suppression_with_http_info( &self, - body: crate::datadogV2::model::CreateNotificationRuleParameters, + body: crate::datadogV2::model::SecurityMonitoringSuppressionCreateRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.create_vulnerability_notification_rule"; + let operation_id = "v2.create_security_monitoring_suppression"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/vulnerabilities/notification_rules", + "{}/api/v2/security_monitoring/configuration/suppressions", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -2429,9 +2532,10 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::< + crate::datadogV2::model::SecurityMonitoringSuppressionResponse, + >(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -2442,7 +2546,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2453,46 +2557,55 @@ impl SecurityMonitoringAPI { } } - /// Delete an existing job. - pub async fn delete_historical_job( + /// Create a new notification rule for security signals and return the created rule. + pub async fn create_signal_notification_rule( &self, - job_id: String, - ) -> Result<(), datadog::Error> { - match self.delete_historical_job_with_http_info(job_id).await { - Ok(_) => Ok(()), + body: crate::datadogV2::model::CreateNotificationRuleParameters, + ) -> Result< + crate::datadogV2::model::NotificationRuleResponse, + datadog::Error, + > { + match self + .create_signal_notification_rule_with_http_info(body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } - /// Delete an existing job. - pub async fn delete_historical_job_with_http_info( + /// Create a new notification rule for security signals and return the created rule. + pub async fn create_signal_notification_rule_with_http_info( &self, - job_id: String, - ) -> Result, datadog::Error> { + body: crate::datadogV2::model::CreateNotificationRuleParameters, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { let local_configuration = &self.config; - let operation_id = "v2.delete_historical_job"; - if local_configuration.is_unstable_operation_enabled(operation_id) { - warn!("Using unstable operation {operation_id}"); - } else { - let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.delete_historical_job' is not enabled".to_string(), - }; - return Err(datadog::Error::UnstableOperationDisabledError(local_error)); - } + let operation_id = "v2.create_signal_notification_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/siem-historical-detections/jobs/{job_id}", - local_configuration.get_operation_host(operation_id), - job_id = datadog::urlencode(job_id) + "{}/api/v2/security/signals/notification_rules", + local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("*/*")); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -2522,6 +2635,51 @@ impl SecurityMonitoringAPI { ); }; + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; log::debug!("request content: {:?}", local_req.body()); @@ -2532,13 +2690,20 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: None, - }) + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2549,41 +2714,55 @@ impl SecurityMonitoringAPI { } } - /// Delete a specific security filter. - pub async fn delete_security_filter( + /// Create a new notification rule for security vulnerabilities and return the created rule. + pub async fn create_vulnerability_notification_rule( &self, - security_filter_id: String, - ) -> Result<(), datadog::Error> { + body: crate::datadogV2::model::CreateNotificationRuleParameters, + ) -> Result< + crate::datadogV2::model::NotificationRuleResponse, + datadog::Error, + > { match self - .delete_security_filter_with_http_info(security_filter_id) + .create_vulnerability_notification_rule_with_http_info(body) .await { - Ok(_) => Ok(()), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } - /// Delete a specific security filter. - pub async fn delete_security_filter_with_http_info( + /// Create a new notification rule for security vulnerabilities and return the created rule. + pub async fn create_vulnerability_notification_rule_with_http_info( &self, - security_filter_id: String, - ) -> Result, datadog::Error> { + body: crate::datadogV2::model::CreateNotificationRuleParameters, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { let local_configuration = &self.config; - let operation_id = "v2.delete_security_filter"; + let operation_id = "v2.create_vulnerability_notification_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}", - local_configuration.get_operation_host(operation_id), - security_filter_id = datadog::urlencode(security_filter_id) + "{}/api/v2/security/vulnerabilities/notification_rules", + local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("*/*")); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -2613,6 +2792,51 @@ impl SecurityMonitoringAPI { ); }; + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; log::debug!("request content: {:?}", local_req.body()); @@ -2623,13 +2847,20 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: None, - }) + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2640,35 +2871,39 @@ impl SecurityMonitoringAPI { } } - /// Delete an existing rule. Default rules cannot be deleted. - pub async fn delete_security_monitoring_rule( + /// Delete an existing job. + pub async fn delete_historical_job( &self, - rule_id: String, - ) -> Result<(), datadog::Error> { - match self - .delete_security_monitoring_rule_with_http_info(rule_id) - .await - { + job_id: String, + ) -> Result<(), datadog::Error> { + match self.delete_historical_job_with_http_info(job_id).await { Ok(_) => Ok(()), Err(err) => Err(err), } } - /// Delete an existing rule. Default rules cannot be deleted. - pub async fn delete_security_monitoring_rule_with_http_info( + /// Delete an existing job. + pub async fn delete_historical_job_with_http_info( &self, - rule_id: String, - ) -> Result, datadog::Error> - { + job_id: String, + ) -> Result, datadog::Error> { let local_configuration = &self.config; - let operation_id = "v2.delete_security_monitoring_rule"; + let operation_id = "v2.delete_historical_job"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_historical_job' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/rules/{rule_id}", + "{}/api/v2/siem-historical-detections/jobs/{job_id}", local_configuration.get_operation_host(operation_id), - rule_id = datadog::urlencode(rule_id) + job_id = datadog::urlencode(job_id) ); let mut local_req_builder = local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); @@ -2721,7 +2956,7 @@ impl SecurityMonitoringAPI { entity: None, }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2732,37 +2967,31 @@ impl SecurityMonitoringAPI { } } - /// Delete a specific suppression rule. - pub async fn delete_security_monitoring_suppression( + /// Delete an inbox rule + pub async fn delete_inbox_rule( &self, - suppression_id: String, - ) -> Result<(), datadog::Error> { - match self - .delete_security_monitoring_suppression_with_http_info(suppression_id) - .await - { + inbox_rule_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self.delete_inbox_rule_with_http_info(inbox_rule_id).await { Ok(_) => Ok(()), Err(err) => Err(err), } } - /// Delete a specific suppression rule. - pub async fn delete_security_monitoring_suppression_with_http_info( + /// Delete an inbox rule + pub async fn delete_inbox_rule_with_http_info( &self, - suppression_id: String, - ) -> Result< - datadog::ResponseContent<()>, - datadog::Error, - > { + inbox_rule_id: uuid::Uuid, + ) -> Result, datadog::Error> { let local_configuration = &self.config; - let operation_id = "v2.delete_security_monitoring_suppression"; + let operation_id = "v2.delete_inbox_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}", + "{}/api/v2/security/vulnerabilities/pipelines/inbox_rules/{inbox_rule_id}", local_configuration.get_operation_host(operation_id), - suppression_id = datadog::urlencode(suppression_id) + inbox_rule_id = datadog::urlencode(inbox_rule_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); @@ -2815,7 +3044,7 @@ impl SecurityMonitoringAPI { entity: None, }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2826,35 +3055,31 @@ impl SecurityMonitoringAPI { } } - /// Delete a notification rule for security signals. - pub async fn delete_signal_notification_rule( + /// Delete a mute rule + pub async fn delete_mute_rule( &self, - id: String, - ) -> Result<(), datadog::Error> { - match self - .delete_signal_notification_rule_with_http_info(id) - .await - { + mute_rule_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self.delete_mute_rule_with_http_info(mute_rule_id).await { Ok(_) => Ok(()), Err(err) => Err(err), } } - /// Delete a notification rule for security signals. - pub async fn delete_signal_notification_rule_with_http_info( + /// Delete a mute rule + pub async fn delete_mute_rule_with_http_info( &self, - id: String, - ) -> Result, datadog::Error> - { + mute_rule_id: uuid::Uuid, + ) -> Result, datadog::Error> { let local_configuration = &self.config; - let operation_id = "v2.delete_signal_notification_rule"; + let operation_id = "v2.delete_mute_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/signals/notification_rules/{id}", + "{}/api/v2/security/vulnerabilities/pipelines/mute_rules/{mute_rule_id}", local_configuration.get_operation_host(operation_id), - id = datadog::urlencode(id) + mute_rule_id = datadog::urlencode(mute_rule_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); @@ -2907,7 +3132,7 @@ impl SecurityMonitoringAPI { entity: None, }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2918,13 +3143,13 @@ impl SecurityMonitoringAPI { } } - /// Delete a notification rule for security vulnerabilities. - pub async fn delete_vulnerability_notification_rule( + /// Delete a specific security filter. + pub async fn delete_security_filter( &self, - id: String, - ) -> Result<(), datadog::Error> { + security_filter_id: String, + ) -> Result<(), datadog::Error> { match self - .delete_vulnerability_notification_rule_with_http_info(id) + .delete_security_filter_with_http_info(security_filter_id) .await { Ok(_) => Ok(()), @@ -2932,23 +3157,20 @@ impl SecurityMonitoringAPI { } } - /// Delete a notification rule for security vulnerabilities. - pub async fn delete_vulnerability_notification_rule_with_http_info( + /// Delete a specific security filter. + pub async fn delete_security_filter_with_http_info( &self, - id: String, - ) -> Result< - datadog::ResponseContent<()>, - datadog::Error, - > { + security_filter_id: String, + ) -> Result, datadog::Error> { let local_configuration = &self.config; - let operation_id = "v2.delete_vulnerability_notification_rule"; + let operation_id = "v2.delete_security_filter"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/vulnerabilities/notification_rules/{id}", + "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}", local_configuration.get_operation_host(operation_id), - id = datadog::urlencode(id) + security_filter_id = datadog::urlencode(security_filter_id) ); let mut local_req_builder = local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); @@ -3001,7 +3223,7 @@ impl SecurityMonitoringAPI { entity: None, }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3012,60 +3234,42 @@ impl SecurityMonitoringAPI { } } - /// Modify the triage assignee of a security signal. - pub async fn edit_security_monitoring_signal_assignee( + /// Delete an existing rule. Default rules cannot be deleted. + pub async fn delete_security_monitoring_rule( &self, - signal_id: String, - body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest, - ) -> Result< - crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - datadog::Error, - > { + rule_id: String, + ) -> Result<(), datadog::Error> { match self - .edit_security_monitoring_signal_assignee_with_http_info(signal_id, body) + .delete_security_monitoring_rule_with_http_info(rule_id) .await { - Ok(response_content) => { - if let Some(e) = response_content.entity { - Ok(e) - } else { - Err(datadog::Error::Serde(serde::de::Error::custom( - "response content was None", - ))) - } - } + Ok(_) => Ok(()), Err(err) => Err(err), } } - /// Modify the triage assignee of a security signal. - pub async fn edit_security_monitoring_signal_assignee_with_http_info( + /// Delete an existing rule. Default rules cannot be deleted. + pub async fn delete_security_monitoring_rule_with_http_info( &self, - signal_id: String, - body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest, - ) -> Result< - datadog::ResponseContent< - crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - >, - datadog::Error, - > { + rule_id: String, + ) -> Result, datadog::Error> + { let local_configuration = &self.config; - let operation_id = "v2.edit_security_monitoring_signal_assignee"; + let operation_id = "v2.delete_security_monitoring_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/signals/{signal_id}/assignee", + "{}/api/v2/security_monitoring/rules/{rule_id}", local_configuration.get_operation_host(operation_id), - signal_id = datadog::urlencode(signal_id) + rule_id = datadog::urlencode(rule_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); - headers.insert("Content-Type", HeaderValue::from_static("application/json")); - headers.insert("Accept", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -3095,51 +3299,6 @@ impl SecurityMonitoringAPI { ); }; - // build body parameters - let output = Vec::new(); - let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); - if body.serialize(&mut ser).is_ok() { - if let Some(content_encoding) = headers.get("Content-Encoding") { - match content_encoding.to_str().unwrap_or_default() { - "gzip" => { - let mut enc = GzEncoder::new(Vec::new(), Compression::default()); - let _ = enc.write_all(ser.into_inner().as_slice()); - match enc.finish() { - Ok(buf) => { - local_req_builder = local_req_builder.body(buf); - } - Err(e) => return Err(datadog::Error::Io(e)), - } - } - "deflate" => { - let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); - let _ = enc.write_all(ser.into_inner().as_slice()); - match enc.finish() { - Ok(buf) => { - local_req_builder = local_req_builder.body(buf); - } - Err(e) => return Err(datadog::Error::Io(e)), - } - } - "zstd1" => { - let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); - let _ = enc.write_all(ser.into_inner().as_slice()); - match enc.finish() { - Ok(buf) => { - local_req_builder = local_req_builder.body(buf); - } - Err(e) => return Err(datadog::Error::Io(e)), - } - } - _ => { - local_req_builder = local_req_builder.body(ser.into_inner()); - } - } - } else { - local_req_builder = local_req_builder.body(ser.into_inner()); - } - } - local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; log::debug!("request content: {:?}", local_req.body()); @@ -3150,21 +3309,13 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::< - crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - >(&local_content) - { - Ok(e) => { - return Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: Some(e), - }) - } - Err(e) => return Err(datadog::Error::Serde(e)), - }; + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3175,60 +3326,44 @@ impl SecurityMonitoringAPI { } } - /// Change the related incidents for a security signal. - pub async fn edit_security_monitoring_signal_incidents( + /// Delete a specific suppression rule. + pub async fn delete_security_monitoring_suppression( &self, - signal_id: String, - body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest, - ) -> Result< - crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - datadog::Error, - > { + suppression_id: String, + ) -> Result<(), datadog::Error> { match self - .edit_security_monitoring_signal_incidents_with_http_info(signal_id, body) + .delete_security_monitoring_suppression_with_http_info(suppression_id) .await { - Ok(response_content) => { - if let Some(e) = response_content.entity { - Ok(e) - } else { - Err(datadog::Error::Serde(serde::de::Error::custom( - "response content was None", - ))) - } - } + Ok(_) => Ok(()), Err(err) => Err(err), } } - /// Change the related incidents for a security signal. - pub async fn edit_security_monitoring_signal_incidents_with_http_info( + /// Delete a specific suppression rule. + pub async fn delete_security_monitoring_suppression_with_http_info( &self, - signal_id: String, - body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest, + suppression_id: String, ) -> Result< - datadog::ResponseContent< - crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - >, - datadog::Error, + datadog::ResponseContent<()>, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.edit_security_monitoring_signal_incidents"; + let operation_id = "v2.delete_security_monitoring_suppression"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/signals/{signal_id}/incidents", + "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}", local_configuration.get_operation_host(operation_id), - signal_id = datadog::urlencode(signal_id) + suppression_id = datadog::urlencode(suppression_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); - headers.insert("Content-Type", HeaderValue::from_static("application/json")); - headers.insert("Accept", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -3258,50 +3393,97 @@ impl SecurityMonitoringAPI { ); }; - // build body parameters - let output = Vec::new(); - let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); - if body.serialize(&mut ser).is_ok() { - if let Some(content_encoding) = headers.get("Content-Encoding") { - match content_encoding.to_str().unwrap_or_default() { - "gzip" => { - let mut enc = GzEncoder::new(Vec::new(), Compression::default()); - let _ = enc.write_all(ser.into_inner().as_slice()); - match enc.finish() { - Ok(buf) => { - local_req_builder = local_req_builder.body(buf); - } - Err(e) => return Err(datadog::Error::Io(e)), - } - } - "deflate" => { - let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); - let _ = enc.write_all(ser.into_inner().as_slice()); - match enc.finish() { - Ok(buf) => { - local_req_builder = local_req_builder.body(buf); - } - Err(e) => return Err(datadog::Error::Io(e)), - } - } - "zstd1" => { - let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); - let _ = enc.write_all(ser.into_inner().as_slice()); - match enc.finish() { - Ok(buf) => { - local_req_builder = local_req_builder.body(buf); - } - Err(e) => return Err(datadog::Error::Io(e)), - } - } - _ => { - local_req_builder = local_req_builder.body(ser.into_inner()); - } - } - } else { - local_req_builder = local_req_builder.body(ser.into_inner()); - } + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete a notification rule for security signals. + pub async fn delete_signal_notification_rule( + &self, + id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_signal_notification_rule_with_http_info(id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), } + } + + /// Delete a notification rule for security signals. + pub async fn delete_signal_notification_rule_with_http_info( + &self, + id: String, + ) -> Result, datadog::Error> + { + let local_configuration = &self.config; + let operation_id = "v2.delete_signal_notification_rule"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security/signals/notification_rules/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; @@ -3313,21 +3495,107 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::< - crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - >(&local_content) - { - Ok(e) => { - return Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: Some(e), - }) - } - Err(e) => return Err(datadog::Error::Serde(e)), + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete a notification rule for security vulnerabilities. + pub async fn delete_vulnerability_notification_rule( + &self, + id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_vulnerability_notification_rule_with_http_info(id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete a notification rule for security vulnerabilities. + pub async fn delete_vulnerability_notification_rule_with_http_info( + &self, + id: String, + ) -> Result< + datadog::ResponseContent<()>, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.delete_vulnerability_notification_rule"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security/vulnerabilities/notification_rules/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3338,17 +3606,17 @@ impl SecurityMonitoringAPI { } } - /// Change the triage state of a security signal. - pub async fn edit_security_monitoring_signal_state( + /// Modify the triage assignee of a security signal. + pub async fn edit_security_monitoring_signal_assignee( &self, signal_id: String, - body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest, + body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest, ) -> Result< crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, - datadog::Error, + datadog::Error, > { match self - .edit_security_monitoring_signal_state_with_http_info(signal_id, body) + .edit_security_monitoring_signal_assignee_with_http_info(signal_id, body) .await { Ok(response_content) => { @@ -3364,24 +3632,24 @@ impl SecurityMonitoringAPI { } } - /// Change the triage state of a security signal. - pub async fn edit_security_monitoring_signal_state_with_http_info( + /// Modify the triage assignee of a security signal. + pub async fn edit_security_monitoring_signal_assignee_with_http_info( &self, signal_id: String, - body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest, + body: crate::datadogV2::model::SecurityMonitoringSignalAssigneeUpdateRequest, ) -> Result< datadog::ResponseContent< crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, >, - datadog::Error, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.edit_security_monitoring_signal_state"; + let operation_id = "v2.edit_security_monitoring_signal_assignee"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/signals/{signal_id}/state", + "{}/api/v2/security_monitoring/signals/{signal_id}/assignee", local_configuration.get_operation_host(operation_id), signal_id = datadog::urlencode(signal_id) ); @@ -3490,7 +3758,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3501,15 +3769,21 @@ impl SecurityMonitoringAPI { } } - /// Returns a single finding with message and resource configuration. - pub async fn get_finding( + /// Change the related incidents for a security signal. + pub async fn edit_security_monitoring_signal_incidents( &self, - finding_id: String, - params: GetFindingOptionalParams, - ) -> Result> { - match self.get_finding_with_http_info(finding_id, params).await { - Ok(response_content) => { - if let Some(e) = response_content.entity { + signal_id: String, + body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest, + ) -> Result< + crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, + datadog::Error, + > { + match self + .edit_security_monitoring_signal_incidents_with_http_info(signal_id, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { Ok(e) } else { Err(datadog::Error::Serde(serde::de::Error::custom( @@ -3521,46 +3795,33 @@ impl SecurityMonitoringAPI { } } - /// Returns a single finding with message and resource configuration. - pub async fn get_finding_with_http_info( + /// Change the related incidents for a security signal. + pub async fn edit_security_monitoring_signal_incidents_with_http_info( &self, - finding_id: String, - params: GetFindingOptionalParams, + signal_id: String, + body: crate::datadogV2::model::SecurityMonitoringSignalIncidentsUpdateRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent< + crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, + >, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_finding"; - if local_configuration.is_unstable_operation_enabled(operation_id) { - warn!("Using unstable operation {operation_id}"); - } else { - let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.get_finding' is not enabled".to_string(), - }; - return Err(datadog::Error::UnstableOperationDisabledError(local_error)); - } - - // unbox and build optional parameters - let snapshot_timestamp = params.snapshot_timestamp; + let operation_id = "v2.edit_security_monitoring_signal_incidents"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/posture_management/findings/{finding_id}", + "{}/api/v2/security_monitoring/signals/{signal_id}/incidents", local_configuration.get_operation_host(operation_id), - finding_id = datadog::urlencode(finding_id) + signal_id = datadog::urlencode(signal_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - - if let Some(ref local_query_param) = snapshot_timestamp { - local_req_builder = - local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]); - }; + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent @@ -3591,6 +3852,51 @@ impl SecurityMonitoringAPI { ); }; + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; log::debug!("request content: {:?}", local_req.body()); @@ -3601,9 +3907,10 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::< + crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, + >(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -3614,7 +3921,8 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_entity: Option = + serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -3624,13 +3932,19 @@ impl SecurityMonitoringAPI { } } - /// Get a job's details. - pub async fn get_historical_job( + /// Change the triage state of a security signal. + pub async fn edit_security_monitoring_signal_state( &self, - job_id: String, - ) -> Result> - { - match self.get_historical_job_with_http_info(job_id).await { + signal_id: String, + body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest, + ) -> Result< + crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, + datadog::Error, + > { + match self + .edit_security_monitoring_signal_state_with_http_info(signal_id, body) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -3644,37 +3958,33 @@ impl SecurityMonitoringAPI { } } - /// Get a job's details. - pub async fn get_historical_job_with_http_info( + /// Change the triage state of a security signal. + pub async fn edit_security_monitoring_signal_state_with_http_info( &self, - job_id: String, + signal_id: String, + body: crate::datadogV2::model::SecurityMonitoringSignalStateUpdateRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent< + crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, + >, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_historical_job"; - if local_configuration.is_unstable_operation_enabled(operation_id) { - warn!("Using unstable operation {operation_id}"); - } else { - let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.get_historical_job' is not enabled".to_string(), - }; - return Err(datadog::Error::UnstableOperationDisabledError(local_error)); - } + let operation_id = "v2.edit_security_monitoring_signal_state"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/siem-historical-detections/jobs/{job_id}", + "{}/api/v2/security_monitoring/signals/{signal_id}/state", local_configuration.get_operation_host(operation_id), - job_id = datadog::urlencode(job_id) + signal_id = datadog::urlencode(signal_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent @@ -3705,6 +4015,51 @@ impl SecurityMonitoringAPI { ); }; + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; log::debug!("request content: {:?}", local_req.body()); @@ -3715,9 +4070,10 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::< + crate::datadogV2::model::SecurityMonitoringSignalTriageUpdateResponse, + >(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -3728,7 +4084,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3739,18 +4095,13 @@ impl SecurityMonitoringAPI { } } - /// Get a single SBOM related to an asset by its type and name. - /// - pub async fn get_sbom( + /// Returns a single finding with message and resource configuration. + pub async fn get_finding( &self, - asset_type: crate::datadogV2::model::AssetType, - filter_asset_name: String, - params: GetSBOMOptionalParams, - ) -> Result> { - match self - .get_sbom_with_http_info(asset_type, filter_asset_name, params) - .await - { + finding_id: String, + params: GetFindingOptionalParams, + ) -> Result> { + match self.get_finding_with_http_info(finding_id, params).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -3764,46 +4115,42 @@ impl SecurityMonitoringAPI { } } - /// Get a single SBOM related to an asset by its type and name. - /// - pub async fn get_sbom_with_http_info( + /// Returns a single finding with message and resource configuration. + pub async fn get_finding_with_http_info( &self, - asset_type: crate::datadogV2::model::AssetType, - filter_asset_name: String, - params: GetSBOMOptionalParams, + finding_id: String, + params: GetFindingOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_sbom"; + let operation_id = "v2.get_finding"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.get_sbom' is not enabled".to_string(), + msg: "Operation 'v2.get_finding' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } // unbox and build optional parameters - let filter_repo_digest = params.filter_repo_digest; + let snapshot_timestamp = params.snapshot_timestamp; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/sboms/{asset_type}", + "{}/api/v2/posture_management/findings/{finding_id}", local_configuration.get_operation_host(operation_id), - asset_type = datadog::urlencode(asset_type.to_string()) + finding_id = datadog::urlencode(finding_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - local_req_builder = - local_req_builder.query(&[("filter[asset_name]", &filter_asset_name.to_string())]); - if let Some(ref local_query_param) = filter_repo_digest { + if let Some(ref local_query_param) = snapshot_timestamp { local_req_builder = - local_req_builder.query(&[("filter[repo_digest]", &local_query_param.to_string())]); + local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]); }; // build headers @@ -3848,7 +4195,9 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -3859,7 +4208,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -3869,21 +4218,13 @@ impl SecurityMonitoringAPI { } } - /// Get the details of a specific security filter. - /// - /// See the [security filter guide]() - /// for more examples. - pub async fn get_security_filter( + /// Get a job's details. + pub async fn get_historical_job( &self, - security_filter_id: String, - ) -> Result< - crate::datadogV2::model::SecurityFilterResponse, - datadog::Error, - > { - match self - .get_security_filter_with_http_info(security_filter_id) - .await - { + job_id: String, + ) -> Result> + { + match self.get_historical_job_with_http_info(job_id).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -3897,26 +4238,31 @@ impl SecurityMonitoringAPI { } } - /// Get the details of a specific security filter. - /// - /// See the [security filter guide]() - /// for more examples. - pub async fn get_security_filter_with_http_info( + /// Get a job's details. + pub async fn get_historical_job_with_http_info( &self, - security_filter_id: String, + job_id: String, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_security_filter"; + let operation_id = "v2.get_historical_job"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_historical_job' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}", + "{}/api/v2/siem-historical-detections/jobs/{job_id}", local_configuration.get_operation_host(operation_id), - security_filter_id = datadog::urlencode(security_filter_id) + job_id = datadog::urlencode(job_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -3963,7 +4309,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -3976,7 +4322,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3987,18 +4333,12 @@ impl SecurityMonitoringAPI { } } - /// Get a rule's details. - pub async fn get_security_monitoring_rule( + /// Get the details of an inbox rule. + pub async fn get_inbox_rule( &self, - rule_id: String, - ) -> Result< - crate::datadogV2::model::SecurityMonitoringRuleResponse, - datadog::Error, - > { - match self - .get_security_monitoring_rule_with_http_info(rule_id) - .await - { + inbox_rule_id: uuid::Uuid, + ) -> Result> { + match self.get_inbox_rule_with_http_info(inbox_rule_id).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -4012,23 +4352,23 @@ impl SecurityMonitoringAPI { } } - /// Get a rule's details. - pub async fn get_security_monitoring_rule_with_http_info( + /// Get the details of an inbox rule. + pub async fn get_inbox_rule_with_http_info( &self, - rule_id: String, + inbox_rule_id: uuid::Uuid, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_security_monitoring_rule"; + let operation_id = "v2.get_inbox_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/rules/{rule_id}", + "{}/api/v2/security/vulnerabilities/pipelines/inbox_rules/{inbox_rule_id}", local_configuration.get_operation_host(operation_id), - rule_id = datadog::urlencode(rule_id) + inbox_rule_id = datadog::urlencode(inbox_rule_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -4075,9 +4415,8 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -4088,8 +4427,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -4099,18 +4437,14 @@ impl SecurityMonitoringAPI { } } - /// Get a signal's details. - pub async fn get_security_monitoring_signal( + /// Returns the ordered list of inbox rules in the pipeline (first match applies) + pub async fn get_inbox_rules( &self, - signal_id: String, ) -> Result< - crate::datadogV2::model::SecurityMonitoringSignalResponse, - datadog::Error, + std::collections::BTreeMap, + datadog::Error, > { - match self - .get_security_monitoring_signal_with_http_info(signal_id) - .await - { + match self.get_inbox_rules_with_http_info().await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -4124,23 +4458,21 @@ impl SecurityMonitoringAPI { } } - /// Get a signal's details. - pub async fn get_security_monitoring_signal_with_http_info( + /// Returns the ordered list of inbox rules in the pipeline (first match applies) + pub async fn get_inbox_rules_with_http_info( &self, - signal_id: String, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent>, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_security_monitoring_signal"; + let operation_id = "v2.get_inbox_rules"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/signals/{signal_id}", - local_configuration.get_operation_host(operation_id), - signal_id = datadog::urlencode(signal_id) + "{}/api/v2/security/vulnerabilities/pipelines/inbox_rules", + local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -4187,7 +4519,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::>( &local_content, ) { Ok(e) => { @@ -4200,7 +4532,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -4211,18 +4543,12 @@ impl SecurityMonitoringAPI { } } - /// Get the details of a specific suppression rule. - pub async fn get_security_monitoring_suppression( + /// Get the details of a mute rule. + pub async fn get_mute_rule( &self, - suppression_id: String, - ) -> Result< - crate::datadogV2::model::SecurityMonitoringSuppressionResponse, - datadog::Error, - > { - match self - .get_security_monitoring_suppression_with_http_info(suppression_id) - .await - { + mute_rule_id: uuid::Uuid, + ) -> Result> { + match self.get_mute_rule_with_http_info(mute_rule_id).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -4236,23 +4562,23 @@ impl SecurityMonitoringAPI { } } - /// Get the details of a specific suppression rule. - pub async fn get_security_monitoring_suppression_with_http_info( + /// Get the details of a mute rule. + pub async fn get_mute_rule_with_http_info( &self, - suppression_id: String, + mute_rule_id: uuid::Uuid, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_security_monitoring_suppression"; + let operation_id = "v2.get_mute_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}", + "{}/api/v2/security/vulnerabilities/pipelines/mute_rules/{mute_rule_id}", local_configuration.get_operation_host(operation_id), - suppression_id = datadog::urlencode(suppression_id) + mute_rule_id = datadog::urlencode(mute_rule_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -4299,9 +4625,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::< - crate::datadogV2::model::SecurityMonitoringSuppressionResponse, - >(&local_content) + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { @@ -4313,8 +4637,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -4324,15 +4647,14 @@ impl SecurityMonitoringAPI { } } - /// Get the details of a notification rule for security signals. - pub async fn get_signal_notification_rule( + /// Returns the ordered list of mute rules in the pipeline (first match applies) + pub async fn get_mute_rules( &self, - id: String, ) -> Result< - crate::datadogV2::model::NotificationRuleResponse, - datadog::Error, + std::collections::BTreeMap, + datadog::Error, > { - match self.get_signal_notification_rule_with_http_info(id).await { + match self.get_mute_rules_with_http_info().await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -4346,23 +4668,21 @@ impl SecurityMonitoringAPI { } } - /// Get the details of a notification rule for security signals. - pub async fn get_signal_notification_rule_with_http_info( + /// Returns the ordered list of mute rules in the pipeline (first match applies) + pub async fn get_mute_rules_with_http_info( &self, - id: String, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent>, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_signal_notification_rule"; + let operation_id = "v2.get_mute_rules"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/signals/notification_rules/{id}", - local_configuration.get_operation_host(operation_id), - id = datadog::urlencode(id) + "{}/api/v2/security/vulnerabilities/pipelines/mute_rules", + local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -4409,7 +4729,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::>( &local_content, ) { Ok(e) => { @@ -4422,8 +4742,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -4433,14 +4752,18 @@ impl SecurityMonitoringAPI { } } - /// Returns the list of notification rules for security signals. - pub async fn get_signal_notification_rules( + /// Get a single SBOM related to an asset by its type and name. + /// + pub async fn get_sbom( &self, - ) -> Result< - std::collections::BTreeMap, - datadog::Error, - > { - match self.get_signal_notification_rules_with_http_info().await { + asset_type: crate::datadogV2::model::AssetType, + filter_asset_name: String, + params: GetSBOMOptionalParams, + ) -> Result> { + match self + .get_sbom_with_http_info(asset_type, filter_asset_name, params) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -4454,25 +4777,48 @@ impl SecurityMonitoringAPI { } } - /// Returns the list of notification rules for security signals. - pub async fn get_signal_notification_rules_with_http_info( + /// Get a single SBOM related to an asset by its type and name. + /// + pub async fn get_sbom_with_http_info( &self, + asset_type: crate::datadogV2::model::AssetType, + filter_asset_name: String, + params: GetSBOMOptionalParams, ) -> Result< - datadog::ResponseContent>, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_signal_notification_rules"; + let operation_id = "v2.get_sbom"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_sbom' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let filter_repo_digest = params.filter_repo_digest; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/signals/notification_rules", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/security/sboms/{asset_type}", + local_configuration.get_operation_host(operation_id), + asset_type = datadog::urlencode(asset_type.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + local_req_builder = + local_req_builder.query(&[("filter[asset_name]", &filter_asset_name.to_string())]); + if let Some(ref local_query_param) = filter_repo_digest { + local_req_builder = + local_req_builder.query(&[("filter[repo_digest]", &local_query_param.to_string())]); + }; + // build headers let mut headers = HeaderMap::new(); headers.insert("Accept", HeaderValue::from_static("application/json")); @@ -4515,9 +4861,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::>( - &local_content, - ) { + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -4528,8 +4872,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -4539,16 +4882,19 @@ impl SecurityMonitoringAPI { } } - /// Get the details of a notification rule for security vulnerabilities. - pub async fn get_vulnerability_notification_rule( + /// Get the details of a specific security filter. + /// + /// See the [security filter guide]() + /// for more examples. + pub async fn get_security_filter( &self, - id: String, + security_filter_id: String, ) -> Result< - crate::datadogV2::model::NotificationRuleResponse, - datadog::Error, + crate::datadogV2::model::SecurityFilterResponse, + datadog::Error, > { match self - .get_vulnerability_notification_rule_with_http_info(id) + .get_security_filter_with_http_info(security_filter_id) .await { Ok(response_content) => { @@ -4564,23 +4910,26 @@ impl SecurityMonitoringAPI { } } - /// Get the details of a notification rule for security vulnerabilities. - pub async fn get_vulnerability_notification_rule_with_http_info( + /// Get the details of a specific security filter. + /// + /// See the [security filter guide]() + /// for more examples. + pub async fn get_security_filter_with_http_info( &self, - id: String, + security_filter_id: String, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_vulnerability_notification_rule"; + let operation_id = "v2.get_security_filter"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/vulnerabilities/notification_rules/{id}", + "{}/api/v2/security_monitoring/configuration/security_filters/{security_filter_id}", local_configuration.get_operation_host(operation_id), - id = datadog::urlencode(id) + security_filter_id = datadog::urlencode(security_filter_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -4627,7 +4976,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -4640,7 +4989,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -4651,15 +5000,16 @@ impl SecurityMonitoringAPI { } } - /// Returns the list of notification rules for security vulnerabilities. - pub async fn get_vulnerability_notification_rules( + /// Get a rule's details. + pub async fn get_security_monitoring_rule( &self, + rule_id: String, ) -> Result< - std::collections::BTreeMap, - datadog::Error, + crate::datadogV2::model::SecurityMonitoringRuleResponse, + datadog::Error, > { match self - .get_vulnerability_notification_rules_with_http_info() + .get_security_monitoring_rule_with_http_info(rule_id) .await { Ok(response_content) => { @@ -4675,21 +5025,23 @@ impl SecurityMonitoringAPI { } } - /// Returns the list of notification rules for security vulnerabilities. - pub async fn get_vulnerability_notification_rules_with_http_info( + /// Get a rule's details. + pub async fn get_security_monitoring_rule_with_http_info( &self, + rule_id: String, ) -> Result< - datadog::ResponseContent>, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_vulnerability_notification_rules"; + let operation_id = "v2.get_security_monitoring_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/vulnerabilities/notification_rules", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/security_monitoring/rules/{rule_id}", + local_configuration.get_operation_host(operation_id), + rule_id = datadog::urlencode(rule_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -4736,7 +5088,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::>( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -4749,7 +5101,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -4760,45 +5112,18 @@ impl SecurityMonitoringAPI { } } - /// Get a list of findings. These include both misconfigurations and identity risks. - /// - /// **Note**: To filter and return only identity risks, add the following query parameter: `?filter[tags]=dd_rule_type:ciem` - /// - /// ### Filtering - /// - /// Filters can be applied by appending query parameters to the URL. - /// - /// - Using a single filter: `?filter[attribute_key]=attribute_value` - /// - Chaining filters: `?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value...` - /// - Filtering on tags: `?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2` - /// - /// Here, `attribute_key` can be any of the filter keys described further below. - /// - /// Query parameters of type `integer` support comparison operators (`>`, `>=`, `<`, `<=`). This is particularly useful when filtering by `evaluation_changed_at` or `resource_discovery_timestamp`. For example: `?filter[evaluation_changed_at]=>20123123121`. - /// - /// You can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*` to filter for any non-AWS resources. - /// - /// The operator must come after the equal sign. For example, to filter with the `>=` operator, add the operator after the equal sign: `filter[evaluation_changed_at]=>=1678809373257`. - /// - /// Query parameters must be only among the documented ones and with values of correct types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`) are not allowed. - /// - /// ### Response - /// - /// The response includes an array of finding objects, pagination metadata, and a count of items that match the query. - /// - /// Each finding object contains the following: - /// - /// - The finding ID that can be used in a `GetFinding` request to retrieve the full finding details. - /// - Core attributes, including status, evaluation, high-level resource details, muted state, and rule details. - /// - `evaluation_changed_at` and `resource_discovery_date` time stamps. - /// - An array of associated tags. - /// - pub async fn list_findings( + /// Get a signal's details. + pub async fn get_security_monitoring_signal( &self, - params: ListFindingsOptionalParams, - ) -> Result> - { - match self.list_findings_with_http_info(params).await { + signal_id: String, + ) -> Result< + crate::datadogV2::model::SecurityMonitoringSignalResponse, + datadog::Error, + > { + match self + .get_security_monitoring_signal_with_http_info(signal_id) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -4812,173 +5137,27 @@ impl SecurityMonitoringAPI { } } - pub fn list_findings_with_pagination( - &self, - mut params: ListFindingsOptionalParams, - ) -> impl Stream< - Item = Result>, - > + '_ { - try_stream! { - let mut page_size: i64 = 100; - if params.page_limit.is_none() { - params.page_limit = Some(page_size); - } else { - page_size = params.page_limit.unwrap().clone(); - } - loop { - let resp = self.list_findings(params.clone()).await?; - - let r = resp.data; - let count = r.len(); - for team in r { - yield team; - } - - if count < page_size as usize { - break; - } - let Some(page) = resp.meta.page else { break }; - let Some(cursor) = page.cursor else { break }; - - params.page_cursor = Some(cursor); - } - } - } - - /// Get a list of findings. These include both misconfigurations and identity risks. - /// - /// **Note**: To filter and return only identity risks, add the following query parameter: `?filter[tags]=dd_rule_type:ciem` - /// - /// ### Filtering - /// - /// Filters can be applied by appending query parameters to the URL. - /// - /// - Using a single filter: `?filter[attribute_key]=attribute_value` - /// - Chaining filters: `?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value...` - /// - Filtering on tags: `?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2` - /// - /// Here, `attribute_key` can be any of the filter keys described further below. - /// - /// Query parameters of type `integer` support comparison operators (`>`, `>=`, `<`, `<=`). This is particularly useful when filtering by `evaluation_changed_at` or `resource_discovery_timestamp`. For example: `?filter[evaluation_changed_at]=>20123123121`. - /// - /// You can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*` to filter for any non-AWS resources. - /// - /// The operator must come after the equal sign. For example, to filter with the `>=` operator, add the operator after the equal sign: `filter[evaluation_changed_at]=>=1678809373257`. - /// - /// Query parameters must be only among the documented ones and with values of correct types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`) are not allowed. - /// - /// ### Response - /// - /// The response includes an array of finding objects, pagination metadata, and a count of items that match the query. - /// - /// Each finding object contains the following: - /// - /// - The finding ID that can be used in a `GetFinding` request to retrieve the full finding details. - /// - Core attributes, including status, evaluation, high-level resource details, muted state, and rule details. - /// - `evaluation_changed_at` and `resource_discovery_date` time stamps. - /// - An array of associated tags. - /// - pub async fn list_findings_with_http_info( + /// Get a signal's details. + pub async fn get_security_monitoring_signal_with_http_info( &self, - params: ListFindingsOptionalParams, + signal_id: String, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_findings"; - if local_configuration.is_unstable_operation_enabled(operation_id) { - warn!("Using unstable operation {operation_id}"); - } else { - let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.list_findings' is not enabled".to_string(), - }; - return Err(datadog::Error::UnstableOperationDisabledError(local_error)); - } - - // unbox and build optional parameters - let page_limit = params.page_limit; - let snapshot_timestamp = params.snapshot_timestamp; - let page_cursor = params.page_cursor; - let filter_tags = params.filter_tags; - let filter_evaluation_changed_at = params.filter_evaluation_changed_at; - let filter_muted = params.filter_muted; - let filter_rule_id = params.filter_rule_id; - let filter_rule_name = params.filter_rule_name; - let filter_resource_type = params.filter_resource_type; - let filter_discovery_timestamp = params.filter_discovery_timestamp; - let filter_evaluation = params.filter_evaluation; - let filter_status = params.filter_status; - let filter_vulnerability_type = params.filter_vulnerability_type; + let operation_id = "v2.get_security_monitoring_signal"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/posture_management/findings", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/security_monitoring/signals/{signal_id}", + local_configuration.get_operation_host(operation_id), + signal_id = datadog::urlencode(signal_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - if let Some(ref local_query_param) = page_limit { - local_req_builder = - local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = snapshot_timestamp { - local_req_builder = - local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_cursor { - local_req_builder = - local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_tags { - local_req_builder = - local_req_builder.query(&[("filter[tags]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_evaluation_changed_at { - local_req_builder = local_req_builder.query(&[( - "filter[evaluation_changed_at]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_muted { - local_req_builder = - local_req_builder.query(&[("filter[muted]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_id { - local_req_builder = - local_req_builder.query(&[("filter[rule_id]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_rule_name { - local_req_builder = - local_req_builder.query(&[("filter[rule_name]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_resource_type { - local_req_builder = local_req_builder - .query(&[("filter[resource_type]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_discovery_timestamp { - local_req_builder = local_req_builder.query(&[( - "filter[discovery_timestamp]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_evaluation { - local_req_builder = - local_req_builder.query(&[("filter[evaluation]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_status { - local_req_builder = - local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]); - }; - if let Some(ref local) = filter_vulnerability_type { - for param in local { - local_req_builder = - local_req_builder.query(&[("filter[vulnerability_type]", ¶m.to_string())]); - } - }; - // build headers let mut headers = HeaderMap::new(); headers.insert("Accept", HeaderValue::from_static("application/json")); @@ -5021,7 +5200,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -5034,7 +5213,8 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_entity: Option = + serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -5044,16 +5224,19 @@ impl SecurityMonitoringAPI { } } - /// List historical jobs. - pub async fn list_historical_jobs( + /// Get the details of a specific suppression rule. + pub async fn get_security_monitoring_suppression( &self, - params: ListHistoricalJobsOptionalParams, + suppression_id: String, ) -> Result< - crate::datadogV2::model::ListHistoricalJobsResponse, - datadog::Error, + crate::datadogV2::model::SecurityMonitoringSuppressionResponse, + datadog::Error, > { - match self.list_historical_jobs_with_http_info(params).await { - Ok(response_content) => { + match self + .get_security_monitoring_suppression_with_http_info(suppression_id) + .await + { + Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) } else { @@ -5066,57 +5249,27 @@ impl SecurityMonitoringAPI { } } - /// List historical jobs. - pub async fn list_historical_jobs_with_http_info( + /// Get the details of a specific suppression rule. + pub async fn get_security_monitoring_suppression_with_http_info( &self, - params: ListHistoricalJobsOptionalParams, + suppression_id: String, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_historical_jobs"; - if local_configuration.is_unstable_operation_enabled(operation_id) { - warn!("Using unstable operation {operation_id}"); - } else { - let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.list_historical_jobs' is not enabled".to_string(), - }; - return Err(datadog::Error::UnstableOperationDisabledError(local_error)); - } - - // unbox and build optional parameters - let page_size = params.page_size; - let page_number = params.page_number; - let sort = params.sort; - let filter_query = params.filter_query; + let operation_id = "v2.get_security_monitoring_suppression"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/siem-historical-detections/jobs", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/security_monitoring/configuration/suppressions/{suppression_id}", + local_configuration.get_operation_host(operation_id), + suppression_id = datadog::urlencode(suppression_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - if let Some(ref local_query_param) = page_size { - local_req_builder = - local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_number { - local_req_builder = - local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = sort { - local_req_builder = - local_req_builder.query(&[("sort", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_query { - local_req_builder = - local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]); - }; - // build headers let mut headers = HeaderMap::new(); headers.insert("Accept", HeaderValue::from_static("application/json")); @@ -5159,9 +5312,10 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::< + crate::datadogV2::model::SecurityMonitoringSuppressionResponse, + >(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -5172,7 +5326,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -5183,14 +5337,15 @@ impl SecurityMonitoringAPI { } } - /// Get the list of configured security filters with their definitions. - pub async fn list_security_filters( + /// Get the details of a notification rule for security signals. + pub async fn get_signal_notification_rule( &self, + id: String, ) -> Result< - crate::datadogV2::model::SecurityFiltersResponse, - datadog::Error, + crate::datadogV2::model::NotificationRuleResponse, + datadog::Error, > { - match self.list_security_filters_with_http_info().await { + match self.get_signal_notification_rule_with_http_info(id).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -5204,21 +5359,23 @@ impl SecurityMonitoringAPI { } } - /// Get the list of configured security filters with their definitions. - pub async fn list_security_filters_with_http_info( + /// Get the details of a notification rule for security signals. + pub async fn get_signal_notification_rule_with_http_info( &self, + id: String, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_security_filters"; + let operation_id = "v2.get_signal_notification_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/configuration/security_filters", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/security/signals/notification_rules/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -5265,7 +5422,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -5278,7 +5435,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -5289,18 +5446,14 @@ impl SecurityMonitoringAPI { } } - /// List rules. - pub async fn list_security_monitoring_rules( + /// Returns the list of notification rules for security signals. + pub async fn get_signal_notification_rules( &self, - params: ListSecurityMonitoringRulesOptionalParams, ) -> Result< - crate::datadogV2::model::SecurityMonitoringListRulesResponse, - datadog::Error, + std::collections::BTreeMap, + datadog::Error, > { - match self - .list_security_monitoring_rules_with_http_info(params) - .await - { + match self.get_signal_notification_rules_with_http_info().await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -5314,39 +5467,25 @@ impl SecurityMonitoringAPI { } } - /// List rules. - pub async fn list_security_monitoring_rules_with_http_info( + /// Returns the list of notification rules for security signals. + pub async fn get_signal_notification_rules_with_http_info( &self, - params: ListSecurityMonitoringRulesOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent>, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_security_monitoring_rules"; - - // unbox and build optional parameters - let page_size = params.page_size; - let page_number = params.page_number; + let operation_id = "v2.get_signal_notification_rules"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/rules", + "{}/api/v2/security/signals/notification_rules", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - if let Some(ref local_query_param) = page_size { - local_req_builder = - local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_number { - local_req_builder = - local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); - }; - // build headers let mut headers = HeaderMap::new(); headers.insert("Accept", HeaderValue::from_static("application/json")); @@ -5389,7 +5528,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::>( &local_content, ) { Ok(e) => { @@ -5402,7 +5541,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -5413,18 +5552,16 @@ impl SecurityMonitoringAPI { } } - /// The list endpoint returns security signals that match a search query. - /// Both this endpoint and the POST endpoint can be used interchangeably when listing - /// security signals. - pub async fn list_security_monitoring_signals( + /// Get the details of a notification rule for security vulnerabilities. + pub async fn get_vulnerability_notification_rule( &self, - params: ListSecurityMonitoringSignalsOptionalParams, + id: String, ) -> Result< - crate::datadogV2::model::SecurityMonitoringSignalsListResponse, - datadog::Error, + crate::datadogV2::model::NotificationRuleResponse, + datadog::Error, > { match self - .list_security_monitoring_signals_with_http_info(params) + .get_vulnerability_notification_rule_with_http_info(id) .await { Ok(response_content) => { @@ -5440,103 +5577,27 @@ impl SecurityMonitoringAPI { } } - pub fn list_security_monitoring_signals_with_pagination( - &self, - mut params: ListSecurityMonitoringSignalsOptionalParams, - ) -> impl Stream< - Item = Result< - crate::datadogV2::model::SecurityMonitoringSignal, - datadog::Error, - >, - > + '_ { - try_stream! { - let mut page_size: i32 = 10; - if params.page_limit.is_none() { - params.page_limit = Some(page_size); - } else { - page_size = params.page_limit.unwrap().clone(); - } - loop { - let resp = self.list_security_monitoring_signals(params.clone()).await?; - let Some(data) = resp.data else { break }; - - let r = data; - let count = r.len(); - for team in r { - yield team; - } - - if count < page_size as usize { - break; - } - let Some(meta) = resp.meta else { break }; - let Some(page) = meta.page else { break }; - let Some(after) = page.after else { break }; - - params.page_cursor = Some(after); - } - } - } - - /// The list endpoint returns security signals that match a search query. - /// Both this endpoint and the POST endpoint can be used interchangeably when listing - /// security signals. - pub async fn list_security_monitoring_signals_with_http_info( + /// Get the details of a notification rule for security vulnerabilities. + pub async fn get_vulnerability_notification_rule_with_http_info( &self, - params: ListSecurityMonitoringSignalsOptionalParams, + id: String, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_security_monitoring_signals"; - - // unbox and build optional parameters - let filter_query = params.filter_query; - let filter_from = params.filter_from; - let filter_to = params.filter_to; - let sort = params.sort; - let page_cursor = params.page_cursor; - let page_limit = params.page_limit; + let operation_id = "v2.get_vulnerability_notification_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/signals", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/security/vulnerabilities/notification_rules/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - if let Some(ref local_query_param) = filter_query { - local_req_builder = - local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_from { - local_req_builder = local_req_builder.query(&[( - "filter[from]", - &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true), - )]); - }; - if let Some(ref local_query_param) = filter_to { - local_req_builder = local_req_builder.query(&[( - "filter[to]", - &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true), - )]); - }; - if let Some(ref local_query_param) = sort { - local_req_builder = - local_req_builder.query(&[("sort", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_cursor { - local_req_builder = - local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_limit { - local_req_builder = - local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); - }; - // build headers let mut headers = HeaderMap::new(); headers.insert("Accept", HeaderValue::from_static("application/json")); @@ -5579,10 +5640,9 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::< - crate::datadogV2::model::SecurityMonitoringSignalsListResponse, - >(&local_content) - { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -5593,7 +5653,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -5604,15 +5664,15 @@ impl SecurityMonitoringAPI { } } - /// Get the list of all suppression rules. - pub async fn list_security_monitoring_suppressions( + /// Returns the list of notification rules for security vulnerabilities. + pub async fn get_vulnerability_notification_rules( &self, ) -> Result< - crate::datadogV2::model::SecurityMonitoringSuppressionsResponse, - datadog::Error, + std::collections::BTreeMap, + datadog::Error, > { match self - .list_security_monitoring_suppressions_with_http_info() + .get_vulnerability_notification_rules_with_http_info() .await { Ok(response_content) => { @@ -5628,20 +5688,20 @@ impl SecurityMonitoringAPI { } } - /// Get the list of all suppression rules. - pub async fn list_security_monitoring_suppressions_with_http_info( + /// Returns the list of notification rules for security vulnerabilities. + pub async fn get_vulnerability_notification_rules_with_http_info( &self, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent>, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_security_monitoring_suppressions"; + let operation_id = "v2.get_vulnerability_notification_rules"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/configuration/suppressions", + "{}/api/v2/security/vulnerabilities/notification_rules", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -5689,10 +5749,9 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::< - crate::datadogV2::model::SecurityMonitoringSuppressionsResponse, - >(&local_content) - { + match serde_json::from_str::>( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -5703,7 +5762,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -5714,95 +5773,45 @@ impl SecurityMonitoringAPI { } } - /// Get a list of vulnerabilities. - /// - /// ### Pagination - /// - /// Pagination is enabled by default in both `vulnerabilities` and `assets`. The size of the page varies depending on the endpoint and cannot be modified. To automate the request of the next page, you can use the links section in the response. - /// - /// This endpoint will return paginated responses. The pages are stored in the links section of the response: - /// - /// ```JSON - /// { - /// "data": [...], - /// "meta": {...}, - /// "links": { - /// "self": " - /// "first": " - /// "last": " - /// "next": " - /// } - /// } - /// ``` - /// - /// - /// - `links.previous` is empty if the first page is requested. - /// - `links.next` is empty if the last page is requested. - /// - /// #### Token - /// - /// Vulnerabilities can be created, updated or deleted at any point in time. - /// - /// Upon the first request, a token is created to ensure consistency across subsequent paginated requests. - /// - /// A token is valid only for 24 hours. - /// - /// #### First request - /// - /// We consider a request to be the first request when there is no `page[token]` parameter. - /// - /// The response of this first request contains the newly created token in the `links` section. - /// - /// This token can then be used in the subsequent paginated requests. - /// - /// #### Subsequent requests - /// - /// Any request containing valid `page[token]` and `page[number]` parameters will be considered a subsequent request. - /// - /// If the `token` is invalid, a `404` response will be returned. + /// Get a list of findings. These include both misconfigurations and identity risks. /// - /// If the page `number` is invalid, a `400` response will be returned. + /// **Note**: To filter and return only identity risks, add the following query parameter: `?filter[tags]=dd_rule_type:ciem` /// /// ### Filtering /// - /// The request can include some filter parameters to filter the data to be retrieved. The format of the filter parameters follows the [JSON:API format](): `filter[$prop_name]`, where `prop_name` is the property name in the entity being filtered by. + /// Filters can be applied by appending query parameters to the URL. /// - /// All filters can include multiple values, where data will be filtered with an OR clause: `filter[title]=Title1,Title2` will filter all vulnerabilities where title is equal to `Title1` OR `Title2`. + /// - Using a single filter: `?filter[attribute_key]=attribute_value` + /// - Chaining filters: `?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value...` + /// - Filtering on tags: `?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2` /// - /// String filters are case sensitive. + /// Here, `attribute_key` can be any of the filter keys described further below. /// - /// Boolean filters accept `true` or `false` as values. + /// Query parameters of type `integer` support comparison operators (`>`, `>=`, `<`, `<=`). This is particularly useful when filtering by `evaluation_changed_at` or `resource_discovery_timestamp`. For example: `?filter[evaluation_changed_at]=>20123123121`. /// - /// Number filters must include an operator as a second filter input: `filter[$prop_name][$operator]`. For example, for the vulnerabilities endpoint: `filter[cvss.base.score][lte]=8`. + /// You can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*` to filter for any non-AWS resources. /// - /// Available operators are: `eq` (==), `lt` (<), `lte` (<=), `gt` (>) and `gte` (>=). + /// The operator must come after the equal sign. For example, to filter with the `>=` operator, add the operator after the equal sign: `filter[evaluation_changed_at]=>=1678809373257`. /// - /// ### Metadata + /// Query parameters must be only among the documented ones and with values of correct types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`) are not allowed. /// - /// Following [JSON:API format](), object including non-standard meta-information. + /// ### Response /// - /// This endpoint includes the meta member in the response. For more details on each of the properties included in this section, check the endpoints response tables. + /// The response includes an array of finding objects, pagination metadata, and a count of items that match the query. /// - /// ```JSON - /// { - /// "data": [...], - /// "meta": { - /// "total": 1500, - /// "count": 18732, - /// "token": "some_token" - /// }, - /// "links": {...} - /// } - /// ``` + /// Each finding object contains the following: /// - pub async fn list_vulnerabilities( + /// - The finding ID that can be used in a `GetFinding` request to retrieve the full finding details. + /// - Core attributes, including status, evaluation, high-level resource details, muted state, and rule details. + /// - `evaluation_changed_at` and `resource_discovery_date` time stamps. + /// - An array of associated tags. + /// + pub async fn list_findings( &self, - params: ListVulnerabilitiesOptionalParams, - ) -> Result< - crate::datadogV2::model::ListVulnerabilitiesResponse, - datadog::Error, - > { - match self.list_vulnerabilities_with_http_info(params).await { + params: ListFindingsOptionalParams, + ) -> Result> + { + match self.list_findings_with_http_info(params).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -5816,362 +5825,417 @@ impl SecurityMonitoringAPI { } } - /// Get a list of vulnerabilities. - /// - /// ### Pagination - /// - /// Pagination is enabled by default in both `vulnerabilities` and `assets`. The size of the page varies depending on the endpoint and cannot be modified. To automate the request of the next page, you can use the links section in the response. - /// - /// This endpoint will return paginated responses. The pages are stored in the links section of the response: - /// - /// ```JSON - /// { - /// "data": [...], - /// "meta": {...}, - /// "links": { - /// "self": " - /// "first": " - /// "last": " - /// "next": " - /// } - /// } - /// ``` - /// - /// - /// - `links.previous` is empty if the first page is requested. - /// - `links.next` is empty if the last page is requested. - /// - /// #### Token - /// - /// Vulnerabilities can be created, updated or deleted at any point in time. - /// - /// Upon the first request, a token is created to ensure consistency across subsequent paginated requests. - /// - /// A token is valid only for 24 hours. - /// - /// #### First request - /// - /// We consider a request to be the first request when there is no `page[token]` parameter. - /// - /// The response of this first request contains the newly created token in the `links` section. - /// - /// This token can then be used in the subsequent paginated requests. - /// - /// #### Subsequent requests - /// - /// Any request containing valid `page[token]` and `page[number]` parameters will be considered a subsequent request. - /// - /// If the `token` is invalid, a `404` response will be returned. + pub fn list_findings_with_pagination( + &self, + mut params: ListFindingsOptionalParams, + ) -> impl Stream< + Item = Result>, + > + '_ { + try_stream! { + let mut page_size: i64 = 100; + if params.page_limit.is_none() { + params.page_limit = Some(page_size); + } else { + page_size = params.page_limit.unwrap().clone(); + } + loop { + let resp = self.list_findings(params.clone()).await?; + + let r = resp.data; + let count = r.len(); + for team in r { + yield team; + } + + if count < page_size as usize { + break; + } + let Some(page) = resp.meta.page else { break }; + let Some(cursor) = page.cursor else { break }; + + params.page_cursor = Some(cursor); + } + } + } + + /// Get a list of findings. These include both misconfigurations and identity risks. /// - /// If the page `number` is invalid, a `400` response will be returned. + /// **Note**: To filter and return only identity risks, add the following query parameter: `?filter[tags]=dd_rule_type:ciem` /// /// ### Filtering /// - /// The request can include some filter parameters to filter the data to be retrieved. The format of the filter parameters follows the [JSON:API format](): `filter[$prop_name]`, where `prop_name` is the property name in the entity being filtered by. + /// Filters can be applied by appending query parameters to the URL. /// - /// All filters can include multiple values, where data will be filtered with an OR clause: `filter[title]=Title1,Title2` will filter all vulnerabilities where title is equal to `Title1` OR `Title2`. + /// - Using a single filter: `?filter[attribute_key]=attribute_value` + /// - Chaining filters: `?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value...` + /// - Filtering on tags: `?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2` /// - /// String filters are case sensitive. + /// Here, `attribute_key` can be any of the filter keys described further below. /// - /// Boolean filters accept `true` or `false` as values. + /// Query parameters of type `integer` support comparison operators (`>`, `>=`, `<`, `<=`). This is particularly useful when filtering by `evaluation_changed_at` or `resource_discovery_timestamp`. For example: `?filter[evaluation_changed_at]=>20123123121`. /// - /// Number filters must include an operator as a second filter input: `filter[$prop_name][$operator]`. For example, for the vulnerabilities endpoint: `filter[cvss.base.score][lte]=8`. + /// You can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*` to filter for any non-AWS resources. /// - /// Available operators are: `eq` (==), `lt` (<), `lte` (<=), `gt` (>) and `gte` (>=). + /// The operator must come after the equal sign. For example, to filter with the `>=` operator, add the operator after the equal sign: `filter[evaluation_changed_at]=>=1678809373257`. /// - /// ### Metadata + /// Query parameters must be only among the documented ones and with values of correct types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`) are not allowed. /// - /// Following [JSON:API format](), object including non-standard meta-information. + /// ### Response /// - /// This endpoint includes the meta member in the response. For more details on each of the properties included in this section, check the endpoints response tables. + /// The response includes an array of finding objects, pagination metadata, and a count of items that match the query. /// - /// ```JSON - /// { - /// "data": [...], - /// "meta": { - /// "total": 1500, - /// "count": 18732, - /// "token": "some_token" - /// }, - /// "links": {...} - /// } - /// ``` + /// Each finding object contains the following: /// - pub async fn list_vulnerabilities_with_http_info( + /// - The finding ID that can be used in a `GetFinding` request to retrieve the full finding details. + /// - Core attributes, including status, evaluation, high-level resource details, muted state, and rule details. + /// - `evaluation_changed_at` and `resource_discovery_date` time stamps. + /// - An array of associated tags. + /// + pub async fn list_findings_with_http_info( &self, - params: ListVulnerabilitiesOptionalParams, + params: ListFindingsOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_vulnerabilities"; + let operation_id = "v2.list_findings"; if local_configuration.is_unstable_operation_enabled(operation_id) { warn!("Using unstable operation {operation_id}"); } else { let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.list_vulnerabilities' is not enabled".to_string(), + msg: "Operation 'v2.list_findings' is not enabled".to_string(), }; return Err(datadog::Error::UnstableOperationDisabledError(local_error)); } // unbox and build optional parameters - let page_token = params.page_token; - let page_number = params.page_number; - let filter_type = params.filter_type; - let filter_cvss_base_score_op = params.filter_cvss_base_score_op; - let filter_cvss_base_severity = params.filter_cvss_base_severity; - let filter_cvss_base_vector = params.filter_cvss_base_vector; - let filter_cvss_datadog_score_op = params.filter_cvss_datadog_score_op; - let filter_cvss_datadog_severity = params.filter_cvss_datadog_severity; - let filter_cvss_datadog_vector = params.filter_cvss_datadog_vector; + let page_limit = params.page_limit; + let snapshot_timestamp = params.snapshot_timestamp; + let page_cursor = params.page_cursor; + let filter_tags = params.filter_tags; + let filter_evaluation_changed_at = params.filter_evaluation_changed_at; + let filter_muted = params.filter_muted; + let filter_rule_id = params.filter_rule_id; + let filter_rule_name = params.filter_rule_name; + let filter_resource_type = params.filter_resource_type; + let filter_discovery_timestamp = params.filter_discovery_timestamp; + let filter_evaluation = params.filter_evaluation; let filter_status = params.filter_status; - let filter_tool = params.filter_tool; - let filter_library_name = params.filter_library_name; - let filter_library_version = params.filter_library_version; - let filter_advisory_id = params.filter_advisory_id; - let filter_risks_exploitation_probability = params.filter_risks_exploitation_probability; - let filter_risks_poc_exploit_available = params.filter_risks_poc_exploit_available; - let filter_risks_exploit_available = params.filter_risks_exploit_available; - let filter_risks_epss_score_op = params.filter_risks_epss_score_op; - let filter_risks_epss_severity = params.filter_risks_epss_severity; - let filter_language = params.filter_language; - let filter_ecosystem = params.filter_ecosystem; - let filter_code_location_location = params.filter_code_location_location; - let filter_code_location_file_path = params.filter_code_location_file_path; - let filter_code_location_method = params.filter_code_location_method; - let filter_fix_available = params.filter_fix_available; - let filter_repo_digests = params.filter_repo_digests; - let filter_asset_name = params.filter_asset_name; - let filter_asset_type = params.filter_asset_type; - let filter_asset_version_first = params.filter_asset_version_first; - let filter_asset_version_last = params.filter_asset_version_last; - let filter_asset_repository_url = params.filter_asset_repository_url; - let filter_asset_risks_in_production = params.filter_asset_risks_in_production; - let filter_asset_risks_under_attack = params.filter_asset_risks_under_attack; - let filter_asset_risks_is_publicly_accessible = - params.filter_asset_risks_is_publicly_accessible; - let filter_asset_risks_has_privileged_access = - params.filter_asset_risks_has_privileged_access; - let filter_asset_risks_has_access_to_sensitive_data = - params.filter_asset_risks_has_access_to_sensitive_data; - let filter_asset_environments = params.filter_asset_environments; - let filter_asset_arch = params.filter_asset_arch; - let filter_asset_operating_system_name = params.filter_asset_operating_system_name; - let filter_asset_operating_system_version = params.filter_asset_operating_system_version; + let filter_vulnerability_type = params.filter_vulnerability_type; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/vulnerabilities", + "{}/api/v2/posture_management/findings", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - if let Some(ref local_query_param) = page_token { - local_req_builder = - local_req_builder.query(&[("page[token]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_number { - local_req_builder = - local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_type { + if let Some(ref local_query_param) = page_limit { local_req_builder = - local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_cvss_base_score_op { - local_req_builder = local_req_builder.query(&[( - "filter[cvss.base.score][`$op`]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_cvss_base_severity { - local_req_builder = local_req_builder - .query(&[("filter[cvss.base.severity]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_cvss_base_vector { - local_req_builder = local_req_builder - .query(&[("filter[cvss.base.vector]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_cvss_datadog_score_op { - local_req_builder = local_req_builder.query(&[( - "filter[cvss.datadog.score][`$op`]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_cvss_datadog_severity { - local_req_builder = local_req_builder.query(&[( - "filter[cvss.datadog.severity]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_cvss_datadog_vector { - local_req_builder = local_req_builder.query(&[( - "filter[cvss.datadog.vector]", - &local_query_param.to_string(), - )]); + local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_status { + if let Some(ref local_query_param) = snapshot_timestamp { local_req_builder = - local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]); + local_req_builder.query(&[("snapshot_timestamp", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_tool { + if let Some(ref local_query_param) = page_cursor { local_req_builder = - local_req_builder.query(&[("filter[tool]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_library_name { - local_req_builder = local_req_builder - .query(&[("filter[library.name]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_library_version { - local_req_builder = local_req_builder - .query(&[("filter[library.version]", &local_query_param.to_string())]); + local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_advisory_id { + if let Some(ref local_query_param) = filter_tags { local_req_builder = - local_req_builder.query(&[("filter[advisory_id]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_risks_exploitation_probability { - local_req_builder = local_req_builder.query(&[( - "filter[risks.exploitation_probability]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_risks_poc_exploit_available { - local_req_builder = local_req_builder.query(&[( - "filter[risks.poc_exploit_available]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_risks_exploit_available { - local_req_builder = local_req_builder.query(&[( - "filter[risks.exploit_available]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_risks_epss_score_op { - local_req_builder = local_req_builder.query(&[( - "filter[risks.epss.score][`$op`]", - &local_query_param.to_string(), - )]); + local_req_builder.query(&[("filter[tags]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_risks_epss_severity { + if let Some(ref local_query_param) = filter_evaluation_changed_at { local_req_builder = local_req_builder.query(&[( - "filter[risks.epss.severity]", + "filter[evaluation_changed_at]", &local_query_param.to_string(), )]); }; - if let Some(ref local_query_param) = filter_language { + if let Some(ref local_query_param) = filter_muted { local_req_builder = - local_req_builder.query(&[("filter[language]", &local_query_param.to_string())]); + local_req_builder.query(&[("filter[muted]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_ecosystem { + if let Some(ref local_query_param) = filter_rule_id { local_req_builder = - local_req_builder.query(&[("filter[ecosystem]", &local_query_param.to_string())]); + local_req_builder.query(&[("filter[rule_id]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_code_location_location { - local_req_builder = local_req_builder.query(&[( - "filter[code_location.location]", - &local_query_param.to_string(), - )]); + if let Some(ref local_query_param) = filter_rule_name { + local_req_builder = + local_req_builder.query(&[("filter[rule_name]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_code_location_file_path { - local_req_builder = local_req_builder.query(&[( - "filter[code_location.file_path]", - &local_query_param.to_string(), - )]); + if let Some(ref local_query_param) = filter_resource_type { + local_req_builder = local_req_builder + .query(&[("filter[resource_type]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_code_location_method { + if let Some(ref local_query_param) = filter_discovery_timestamp { local_req_builder = local_req_builder.query(&[( - "filter[code_location.method]", + "filter[discovery_timestamp]", &local_query_param.to_string(), )]); }; - if let Some(ref local_query_param) = filter_fix_available { - local_req_builder = local_req_builder - .query(&[("filter[fix_available]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_repo_digests { - local_req_builder = local_req_builder - .query(&[("filter[repo_digests]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_asset_name { + if let Some(ref local_query_param) = filter_evaluation { local_req_builder = - local_req_builder.query(&[("filter[asset.name]", &local_query_param.to_string())]); + local_req_builder.query(&[("filter[evaluation]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_asset_type { + if let Some(ref local_query_param) = filter_status { local_req_builder = - local_req_builder.query(&[("filter[asset.type]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_asset_version_first { - local_req_builder = local_req_builder.query(&[( - "filter[asset.version.first]", - &local_query_param.to_string(), - )]); + local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_asset_version_last { - local_req_builder = local_req_builder - .query(&[("filter[asset.version.last]", &local_query_param.to_string())]); + if let Some(ref local) = filter_vulnerability_type { + for param in local { + local_req_builder = + local_req_builder.query(&[("filter[vulnerability_type]", ¶m.to_string())]); + } }; - if let Some(ref local_query_param) = filter_asset_repository_url { - local_req_builder = local_req_builder.query(&[( - "filter[asset.repository_url]", - &local_query_param.to_string(), - )]); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } }; - if let Some(ref local_query_param) = filter_asset_risks_in_production { - local_req_builder = local_req_builder.query(&[( - "filter[asset.risks.in_production]", - &local_query_param.to_string(), - )]); + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); }; - if let Some(ref local_query_param) = filter_asset_risks_under_attack { - local_req_builder = local_req_builder.query(&[( - "filter[asset.risks.under_attack]", - &local_query_param.to_string(), - )]); + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); }; - if let Some(ref local_query_param) = filter_asset_risks_is_publicly_accessible { - local_req_builder = local_req_builder.query(&[( - "filter[asset.risks.is_publicly_accessible]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_asset_risks_has_privileged_access { - local_req_builder = local_req_builder.query(&[( - "filter[asset.risks.has_privileged_access]", - &local_query_param.to_string(), - )]); + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// List historical jobs. + pub async fn list_historical_jobs( + &self, + params: ListHistoricalJobsOptionalParams, + ) -> Result< + crate::datadogV2::model::ListHistoricalJobsResponse, + datadog::Error, + > { + match self.list_historical_jobs_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// List historical jobs. + pub async fn list_historical_jobs_with_http_info( + &self, + params: ListHistoricalJobsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_historical_jobs"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_historical_jobs' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_size = params.page_size; + let page_number = params.page_number; + let sort = params.sort; + let filter_query = params.filter_query; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/siem-historical-detections/jobs", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_size { + local_req_builder = + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_asset_risks_has_access_to_sensitive_data { - local_req_builder = local_req_builder.query(&[( - "filter[asset.risks.has_access_to_sensitive_data]", - &local_query_param.to_string(), - )]); + if let Some(ref local_query_param) = page_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_asset_environments { - local_req_builder = local_req_builder - .query(&[("filter[asset.environments]", &local_query_param.to_string())]); + if let Some(ref local_query_param) = sort { + local_req_builder = + local_req_builder.query(&[("sort", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_asset_arch { + if let Some(ref local_query_param) = filter_query { local_req_builder = - local_req_builder.query(&[("filter[asset.arch]", &local_query_param.to_string())]); + local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_asset_operating_system_name { - local_req_builder = local_req_builder.query(&[( - "filter[asset.operating_system.name]", - &local_query_param.to_string(), - )]); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } }; - if let Some(ref local_query_param) = filter_asset_operating_system_version { - local_req_builder = local_req_builder.query(&[( - "filter[asset.operating_system.version]", - &local_query_param.to_string(), - )]); + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); }; + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get the list of configured security filters with their definitions. + pub async fn list_security_filters( + &self, + ) -> Result< + crate::datadogV2::model::SecurityFiltersResponse, + datadog::Error, + > { + match self.list_security_filters_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get the list of configured security filters with their definitions. + pub async fn list_security_filters_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_security_filters"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security_monitoring/configuration/security_filters", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + // build headers let mut headers = HeaderMap::new(); headers.insert("Accept", HeaderValue::from_static("application/json")); @@ -6186,23 +6250,1842 @@ impl SecurityMonitoringAPI { HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), ) } - }; - - // build auth - if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { - headers.insert( - "DD-API-KEY", - HeaderValue::from_str(local_key.key.as_str()) - .expect("failed to parse DD-API-KEY header"), - ); - }; - if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { - headers.insert( - "DD-APPLICATION-KEY", - HeaderValue::from_str(local_key.key.as_str()) - .expect("failed to parse DD-APPLICATION-KEY header"), - ); - }; + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// List rules. + pub async fn list_security_monitoring_rules( + &self, + params: ListSecurityMonitoringRulesOptionalParams, + ) -> Result< + crate::datadogV2::model::SecurityMonitoringListRulesResponse, + datadog::Error, + > { + match self + .list_security_monitoring_rules_with_http_info(params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// List rules. + pub async fn list_security_monitoring_rules_with_http_info( + &self, + params: ListSecurityMonitoringRulesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_security_monitoring_rules"; + + // unbox and build optional parameters + let page_size = params.page_size; + let page_number = params.page_number; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security_monitoring/rules", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_size { + local_req_builder = + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// The list endpoint returns security signals that match a search query. + /// Both this endpoint and the POST endpoint can be used interchangeably when listing + /// security signals. + pub async fn list_security_monitoring_signals( + &self, + params: ListSecurityMonitoringSignalsOptionalParams, + ) -> Result< + crate::datadogV2::model::SecurityMonitoringSignalsListResponse, + datadog::Error, + > { + match self + .list_security_monitoring_signals_with_http_info(params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub fn list_security_monitoring_signals_with_pagination( + &self, + mut params: ListSecurityMonitoringSignalsOptionalParams, + ) -> impl Stream< + Item = Result< + crate::datadogV2::model::SecurityMonitoringSignal, + datadog::Error, + >, + > + '_ { + try_stream! { + let mut page_size: i32 = 10; + if params.page_limit.is_none() { + params.page_limit = Some(page_size); + } else { + page_size = params.page_limit.unwrap().clone(); + } + loop { + let resp = self.list_security_monitoring_signals(params.clone()).await?; + let Some(data) = resp.data else { break }; + + let r = data; + let count = r.len(); + for team in r { + yield team; + } + + if count < page_size as usize { + break; + } + let Some(meta) = resp.meta else { break }; + let Some(page) = meta.page else { break }; + let Some(after) = page.after else { break }; + + params.page_cursor = Some(after); + } + } + } + + /// The list endpoint returns security signals that match a search query. + /// Both this endpoint and the POST endpoint can be used interchangeably when listing + /// security signals. + pub async fn list_security_monitoring_signals_with_http_info( + &self, + params: ListSecurityMonitoringSignalsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_security_monitoring_signals"; + + // unbox and build optional parameters + let filter_query = params.filter_query; + let filter_from = params.filter_from; + let filter_to = params.filter_to; + let sort = params.sort; + let page_cursor = params.page_cursor; + let page_limit = params.page_limit; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security_monitoring/signals", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = filter_query { + local_req_builder = + local_req_builder.query(&[("filter[query]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_from { + local_req_builder = local_req_builder.query(&[( + "filter[from]", + &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true), + )]); + }; + if let Some(ref local_query_param) = filter_to { + local_req_builder = local_req_builder.query(&[( + "filter[to]", + &local_query_param.to_rfc3339_opts(chrono::SecondsFormat::Millis, true), + )]); + }; + if let Some(ref local_query_param) = sort { + local_req_builder = + local_req_builder.query(&[("sort", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_cursor { + local_req_builder = + local_req_builder.query(&[("page[cursor]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_limit { + local_req_builder = + local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::< + crate::datadogV2::model::SecurityMonitoringSignalsListResponse, + >(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get the list of all suppression rules. + pub async fn list_security_monitoring_suppressions( + &self, + ) -> Result< + crate::datadogV2::model::SecurityMonitoringSuppressionsResponse, + datadog::Error, + > { + match self + .list_security_monitoring_suppressions_with_http_info() + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get the list of all suppression rules. + pub async fn list_security_monitoring_suppressions_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_security_monitoring_suppressions"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security_monitoring/configuration/suppressions", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::< + crate::datadogV2::model::SecurityMonitoringSuppressionsResponse, + >(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get a list of vulnerabilities. + /// + /// ### Pagination + /// + /// Pagination is enabled by default in both `vulnerabilities` and `assets`. The size of the page varies depending on the endpoint and cannot be modified. To automate the request of the next page, you can use the links section in the response. + /// + /// This endpoint will return paginated responses. The pages are stored in the links section of the response: + /// + /// ```JSON + /// { + /// "data": [...], + /// "meta": {...}, + /// "links": { + /// "self": " + /// "first": " + /// "last": " + /// "next": " + /// } + /// } + /// ``` + /// + /// + /// - `links.previous` is empty if the first page is requested. + /// - `links.next` is empty if the last page is requested. + /// + /// #### Token + /// + /// Vulnerabilities can be created, updated or deleted at any point in time. + /// + /// Upon the first request, a token is created to ensure consistency across subsequent paginated requests. + /// + /// A token is valid only for 24 hours. + /// + /// #### First request + /// + /// We consider a request to be the first request when there is no `page[token]` parameter. + /// + /// The response of this first request contains the newly created token in the `links` section. + /// + /// This token can then be used in the subsequent paginated requests. + /// + /// #### Subsequent requests + /// + /// Any request containing valid `page[token]` and `page[number]` parameters will be considered a subsequent request. + /// + /// If the `token` is invalid, a `404` response will be returned. + /// + /// If the page `number` is invalid, a `400` response will be returned. + /// + /// ### Filtering + /// + /// The request can include some filter parameters to filter the data to be retrieved. The format of the filter parameters follows the [JSON:API format](): `filter[$prop_name]`, where `prop_name` is the property name in the entity being filtered by. + /// + /// All filters can include multiple values, where data will be filtered with an OR clause: `filter[title]=Title1,Title2` will filter all vulnerabilities where title is equal to `Title1` OR `Title2`. + /// + /// String filters are case sensitive. + /// + /// Boolean filters accept `true` or `false` as values. + /// + /// Number filters must include an operator as a second filter input: `filter[$prop_name][$operator]`. For example, for the vulnerabilities endpoint: `filter[cvss.base.score][lte]=8`. + /// + /// Available operators are: `eq` (==), `lt` (<), `lte` (<=), `gt` (>) and `gte` (>=). + /// + /// ### Metadata + /// + /// Following [JSON:API format](), object including non-standard meta-information. + /// + /// This endpoint includes the meta member in the response. For more details on each of the properties included in this section, check the endpoints response tables. + /// + /// ```JSON + /// { + /// "data": [...], + /// "meta": { + /// "total": 1500, + /// "count": 18732, + /// "token": "some_token" + /// }, + /// "links": {...} + /// } + /// ``` + /// + pub async fn list_vulnerabilities( + &self, + params: ListVulnerabilitiesOptionalParams, + ) -> Result< + crate::datadogV2::model::ListVulnerabilitiesResponse, + datadog::Error, + > { + match self.list_vulnerabilities_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get a list of vulnerabilities. + /// + /// ### Pagination + /// + /// Pagination is enabled by default in both `vulnerabilities` and `assets`. The size of the page varies depending on the endpoint and cannot be modified. To automate the request of the next page, you can use the links section in the response. + /// + /// This endpoint will return paginated responses. The pages are stored in the links section of the response: + /// + /// ```JSON + /// { + /// "data": [...], + /// "meta": {...}, + /// "links": { + /// "self": " + /// "first": " + /// "last": " + /// "next": " + /// } + /// } + /// ``` + /// + /// + /// - `links.previous` is empty if the first page is requested. + /// - `links.next` is empty if the last page is requested. + /// + /// #### Token + /// + /// Vulnerabilities can be created, updated or deleted at any point in time. + /// + /// Upon the first request, a token is created to ensure consistency across subsequent paginated requests. + /// + /// A token is valid only for 24 hours. + /// + /// #### First request + /// + /// We consider a request to be the first request when there is no `page[token]` parameter. + /// + /// The response of this first request contains the newly created token in the `links` section. + /// + /// This token can then be used in the subsequent paginated requests. + /// + /// #### Subsequent requests + /// + /// Any request containing valid `page[token]` and `page[number]` parameters will be considered a subsequent request. + /// + /// If the `token` is invalid, a `404` response will be returned. + /// + /// If the page `number` is invalid, a `400` response will be returned. + /// + /// ### Filtering + /// + /// The request can include some filter parameters to filter the data to be retrieved. The format of the filter parameters follows the [JSON:API format](): `filter[$prop_name]`, where `prop_name` is the property name in the entity being filtered by. + /// + /// All filters can include multiple values, where data will be filtered with an OR clause: `filter[title]=Title1,Title2` will filter all vulnerabilities where title is equal to `Title1` OR `Title2`. + /// + /// String filters are case sensitive. + /// + /// Boolean filters accept `true` or `false` as values. + /// + /// Number filters must include an operator as a second filter input: `filter[$prop_name][$operator]`. For example, for the vulnerabilities endpoint: `filter[cvss.base.score][lte]=8`. + /// + /// Available operators are: `eq` (==), `lt` (<), `lte` (<=), `gt` (>) and `gte` (>=). + /// + /// ### Metadata + /// + /// Following [JSON:API format](), object including non-standard meta-information. + /// + /// This endpoint includes the meta member in the response. For more details on each of the properties included in this section, check the endpoints response tables. + /// + /// ```JSON + /// { + /// "data": [...], + /// "meta": { + /// "total": 1500, + /// "count": 18732, + /// "token": "some_token" + /// }, + /// "links": {...} + /// } + /// ``` + /// + pub async fn list_vulnerabilities_with_http_info( + &self, + params: ListVulnerabilitiesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_vulnerabilities"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_vulnerabilities' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_token = params.page_token; + let page_number = params.page_number; + let filter_type = params.filter_type; + let filter_cvss_base_score_op = params.filter_cvss_base_score_op; + let filter_cvss_base_severity = params.filter_cvss_base_severity; + let filter_cvss_base_vector = params.filter_cvss_base_vector; + let filter_cvss_datadog_score_op = params.filter_cvss_datadog_score_op; + let filter_cvss_datadog_severity = params.filter_cvss_datadog_severity; + let filter_cvss_datadog_vector = params.filter_cvss_datadog_vector; + let filter_status = params.filter_status; + let filter_tool = params.filter_tool; + let filter_library_name = params.filter_library_name; + let filter_library_version = params.filter_library_version; + let filter_advisory_id = params.filter_advisory_id; + let filter_risks_exploitation_probability = params.filter_risks_exploitation_probability; + let filter_risks_poc_exploit_available = params.filter_risks_poc_exploit_available; + let filter_risks_exploit_available = params.filter_risks_exploit_available; + let filter_risks_epss_score_op = params.filter_risks_epss_score_op; + let filter_risks_epss_severity = params.filter_risks_epss_severity; + let filter_language = params.filter_language; + let filter_ecosystem = params.filter_ecosystem; + let filter_code_location_location = params.filter_code_location_location; + let filter_code_location_file_path = params.filter_code_location_file_path; + let filter_code_location_method = params.filter_code_location_method; + let filter_fix_available = params.filter_fix_available; + let filter_repo_digests = params.filter_repo_digests; + let filter_asset_name = params.filter_asset_name; + let filter_asset_type = params.filter_asset_type; + let filter_asset_version_first = params.filter_asset_version_first; + let filter_asset_version_last = params.filter_asset_version_last; + let filter_asset_repository_url = params.filter_asset_repository_url; + let filter_asset_risks_in_production = params.filter_asset_risks_in_production; + let filter_asset_risks_under_attack = params.filter_asset_risks_under_attack; + let filter_asset_risks_is_publicly_accessible = + params.filter_asset_risks_is_publicly_accessible; + let filter_asset_risks_has_privileged_access = + params.filter_asset_risks_has_privileged_access; + let filter_asset_risks_has_access_to_sensitive_data = + params.filter_asset_risks_has_access_to_sensitive_data; + let filter_asset_environments = params.filter_asset_environments; + let filter_asset_arch = params.filter_asset_arch; + let filter_asset_operating_system_name = params.filter_asset_operating_system_name; + let filter_asset_operating_system_version = params.filter_asset_operating_system_version; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security/vulnerabilities", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_token { + local_req_builder = + local_req_builder.query(&[("page[token]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_type { + local_req_builder = + local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_cvss_base_score_op { + local_req_builder = local_req_builder.query(&[( + "filter[cvss.base.score][`$op`]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_cvss_base_severity { + local_req_builder = local_req_builder + .query(&[("filter[cvss.base.severity]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_cvss_base_vector { + local_req_builder = local_req_builder + .query(&[("filter[cvss.base.vector]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_cvss_datadog_score_op { + local_req_builder = local_req_builder.query(&[( + "filter[cvss.datadog.score][`$op`]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_cvss_datadog_severity { + local_req_builder = local_req_builder.query(&[( + "filter[cvss.datadog.severity]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_cvss_datadog_vector { + local_req_builder = local_req_builder.query(&[( + "filter[cvss.datadog.vector]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_status { + local_req_builder = + local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_tool { + local_req_builder = + local_req_builder.query(&[("filter[tool]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_library_name { + local_req_builder = local_req_builder + .query(&[("filter[library.name]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_library_version { + local_req_builder = local_req_builder + .query(&[("filter[library.version]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_advisory_id { + local_req_builder = + local_req_builder.query(&[("filter[advisory_id]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_risks_exploitation_probability { + local_req_builder = local_req_builder.query(&[( + "filter[risks.exploitation_probability]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_risks_poc_exploit_available { + local_req_builder = local_req_builder.query(&[( + "filter[risks.poc_exploit_available]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_risks_exploit_available { + local_req_builder = local_req_builder.query(&[( + "filter[risks.exploit_available]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_risks_epss_score_op { + local_req_builder = local_req_builder.query(&[( + "filter[risks.epss.score][`$op`]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_risks_epss_severity { + local_req_builder = local_req_builder.query(&[( + "filter[risks.epss.severity]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_language { + local_req_builder = + local_req_builder.query(&[("filter[language]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_ecosystem { + local_req_builder = + local_req_builder.query(&[("filter[ecosystem]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_code_location_location { + local_req_builder = local_req_builder.query(&[( + "filter[code_location.location]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_code_location_file_path { + local_req_builder = local_req_builder.query(&[( + "filter[code_location.file_path]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_code_location_method { + local_req_builder = local_req_builder.query(&[( + "filter[code_location.method]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_fix_available { + local_req_builder = local_req_builder + .query(&[("filter[fix_available]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_repo_digests { + local_req_builder = local_req_builder + .query(&[("filter[repo_digests]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_asset_name { + local_req_builder = + local_req_builder.query(&[("filter[asset.name]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_asset_type { + local_req_builder = + local_req_builder.query(&[("filter[asset.type]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_asset_version_first { + local_req_builder = local_req_builder.query(&[( + "filter[asset.version.first]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_asset_version_last { + local_req_builder = local_req_builder + .query(&[("filter[asset.version.last]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_asset_repository_url { + local_req_builder = local_req_builder.query(&[( + "filter[asset.repository_url]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_asset_risks_in_production { + local_req_builder = local_req_builder.query(&[( + "filter[asset.risks.in_production]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_asset_risks_under_attack { + local_req_builder = local_req_builder.query(&[( + "filter[asset.risks.under_attack]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_asset_risks_is_publicly_accessible { + local_req_builder = local_req_builder.query(&[( + "filter[asset.risks.is_publicly_accessible]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_asset_risks_has_privileged_access { + local_req_builder = local_req_builder.query(&[( + "filter[asset.risks.has_privileged_access]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_asset_risks_has_access_to_sensitive_data { + local_req_builder = local_req_builder.query(&[( + "filter[asset.risks.has_access_to_sensitive_data]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_asset_environments { + local_req_builder = local_req_builder + .query(&[("filter[asset.environments]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_asset_arch { + local_req_builder = + local_req_builder.query(&[("filter[asset.arch]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_asset_operating_system_name { + local_req_builder = local_req_builder.query(&[( + "filter[asset.operating_system.name]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_asset_operating_system_version { + local_req_builder = local_req_builder.query(&[( + "filter[asset.operating_system.version]", + &local_query_param.to_string(), + )]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get a list of vulnerable assets. + /// + /// ### Pagination + /// + /// Please review the [Pagination section for the "List Vulnerabilities"](#pagination) endpoint. + /// + /// ### Filtering + /// + /// Please review the [Filtering section for the "List Vulnerabilities"](#filtering) endpoint. + /// + /// ### Metadata + /// + /// Please review the [Metadata section for the "List Vulnerabilities"](#metadata) endpoint. + /// + pub async fn list_vulnerable_assets( + &self, + params: ListVulnerableAssetsOptionalParams, + ) -> Result< + crate::datadogV2::model::ListVulnerableAssetsResponse, + datadog::Error, + > { + match self.list_vulnerable_assets_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get a list of vulnerable assets. + /// + /// ### Pagination + /// + /// Please review the [Pagination section for the "List Vulnerabilities"](#pagination) endpoint. + /// + /// ### Filtering + /// + /// Please review the [Filtering section for the "List Vulnerabilities"](#filtering) endpoint. + /// + /// ### Metadata + /// + /// Please review the [Metadata section for the "List Vulnerabilities"](#metadata) endpoint. + /// + pub async fn list_vulnerable_assets_with_http_info( + &self, + params: ListVulnerableAssetsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_vulnerable_assets"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_vulnerable_assets' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_token = params.page_token; + let page_number = params.page_number; + let filter_name = params.filter_name; + let filter_type = params.filter_type; + let filter_version_first = params.filter_version_first; + let filter_version_last = params.filter_version_last; + let filter_repository_url = params.filter_repository_url; + let filter_risks_in_production = params.filter_risks_in_production; + let filter_risks_under_attack = params.filter_risks_under_attack; + let filter_risks_is_publicly_accessible = params.filter_risks_is_publicly_accessible; + let filter_risks_has_privileged_access = params.filter_risks_has_privileged_access; + let filter_risks_has_access_to_sensitive_data = + params.filter_risks_has_access_to_sensitive_data; + let filter_environments = params.filter_environments; + let filter_arch = params.filter_arch; + let filter_operating_system_name = params.filter_operating_system_name; + let filter_operating_system_version = params.filter_operating_system_version; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security/assets", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_token { + local_req_builder = + local_req_builder.query(&[("page[token]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_name { + local_req_builder = + local_req_builder.query(&[("filter[name]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_type { + local_req_builder = + local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_version_first { + local_req_builder = local_req_builder + .query(&[("filter[version.first]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_version_last { + local_req_builder = local_req_builder + .query(&[("filter[version.last]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_repository_url { + local_req_builder = local_req_builder + .query(&[("filter[repository_url]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_risks_in_production { + local_req_builder = local_req_builder.query(&[( + "filter[risks.in_production]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_risks_under_attack { + local_req_builder = local_req_builder + .query(&[("filter[risks.under_attack]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_risks_is_publicly_accessible { + local_req_builder = local_req_builder.query(&[( + "filter[risks.is_publicly_accessible]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_risks_has_privileged_access { + local_req_builder = local_req_builder.query(&[( + "filter[risks.has_privileged_access]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_risks_has_access_to_sensitive_data { + local_req_builder = local_req_builder.query(&[( + "filter[risks.has_access_to_sensitive_data]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_environments { + local_req_builder = local_req_builder + .query(&[("filter[environments]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_arch { + local_req_builder = + local_req_builder.query(&[("filter[arch]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_operating_system_name { + local_req_builder = local_req_builder.query(&[( + "filter[operating_system.name]", + &local_query_param.to_string(), + )]); + }; + if let Some(ref local_query_param) = filter_operating_system_version { + local_req_builder = local_req_builder.query(&[( + "filter[operating_system.version]", + &local_query_param.to_string(), + )]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Mute or unmute findings. + pub async fn mute_findings( + &self, + body: crate::datadogV2::model::BulkMuteFindingsRequest, + ) -> Result> + { + match self.mute_findings_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Mute or unmute findings. + pub async fn mute_findings_with_http_info( + &self, + body: crate::datadogV2::model::BulkMuteFindingsRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.mute_findings"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.mute_findings' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/posture_management/findings", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Partially update the inbox rule. All fields are optional; if a field is not provided, it is not updated. + pub async fn patch_inbox_rule( + &self, + inbox_rule_id: uuid::Uuid, + body: crate::datadogV2::model::PatchInboxRulesParameters, + ) -> Result> + { + match self + .patch_inbox_rule_with_http_info(inbox_rule_id, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Partially update the inbox rule. All fields are optional; if a field is not provided, it is not updated. + pub async fn patch_inbox_rule_with_http_info( + &self, + inbox_rule_id: uuid::Uuid, + body: crate::datadogV2::model::PatchInboxRulesParameters, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.patch_inbox_rule"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security/vulnerabilities/pipelines/inbox_rules/{inbox_rule_id}", + local_configuration.get_operation_host(operation_id), + inbox_rule_id = datadog::urlencode(inbox_rule_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Partially update the mute rule. All fields are optional; if a field is not provided, it is not updated. + pub async fn patch_mute_rule( + &self, + mute_rule_id: uuid::Uuid, + body: crate::datadogV2::model::PatchMuteRuleParameters, + ) -> Result> { + match self + .patch_mute_rule_with_http_info(mute_rule_id, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Partially update the mute rule. All fields are optional; if a field is not provided, it is not updated. + pub async fn patch_mute_rule_with_http_info( + &self, + mute_rule_id: uuid::Uuid, + body: crate::datadogV2::model::PatchMuteRuleParameters, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.patch_mute_rule"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security/vulnerabilities/pipelines/mute_rules/{mute_rule_id}", + local_configuration.get_operation_host(operation_id), + mute_rule_id = datadog::urlencode(mute_rule_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. + pub async fn patch_signal_notification_rule( + &self, + id: String, + body: crate::datadogV2::model::PatchNotificationRuleParameters, + ) -> Result< + crate::datadogV2::model::NotificationRuleResponse, + datadog::Error, + > { + match self + .patch_signal_notification_rule_with_http_info(id, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. + pub async fn patch_signal_notification_rule_with_http_info( + &self, + id: String, + body: crate::datadogV2::model::PatchNotificationRuleParameters, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.patch_signal_notification_rule"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security/signals/notification_rules/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; @@ -6214,7 +8097,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -6227,7 +8110,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -6238,28 +8121,19 @@ impl SecurityMonitoringAPI { } } - /// Get a list of vulnerable assets. - /// - /// ### Pagination - /// - /// Please review the [Pagination section for the "List Vulnerabilities"](#pagination) endpoint. - /// - /// ### Filtering - /// - /// Please review the [Filtering section for the "List Vulnerabilities"](#filtering) endpoint. - /// - /// ### Metadata - /// - /// Please review the [Metadata section for the "List Vulnerabilities"](#metadata) endpoint. - /// - pub async fn list_vulnerable_assets( + /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. + pub async fn patch_vulnerability_notification_rule( &self, - params: ListVulnerableAssetsOptionalParams, + id: String, + body: crate::datadogV2::model::PatchNotificationRuleParameters, ) -> Result< - crate::datadogV2::model::ListVulnerableAssetsResponse, - datadog::Error, + crate::datadogV2::model::NotificationRuleResponse, + datadog::Error, > { - match self.list_vulnerable_assets_with_http_info(params).await { + match self + .patch_vulnerability_notification_rule_with_http_info(id, body) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -6273,145 +8147,187 @@ impl SecurityMonitoringAPI { } } - /// Get a list of vulnerable assets. - /// - /// ### Pagination - /// - /// Please review the [Pagination section for the "List Vulnerabilities"](#pagination) endpoint. - /// - /// ### Filtering - /// - /// Please review the [Filtering section for the "List Vulnerabilities"](#filtering) endpoint. - /// - /// ### Metadata - /// - /// Please review the [Metadata section for the "List Vulnerabilities"](#metadata) endpoint. - /// - pub async fn list_vulnerable_assets_with_http_info( + /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. + pub async fn patch_vulnerability_notification_rule_with_http_info( &self, - params: ListVulnerableAssetsOptionalParams, + id: String, + body: crate::datadogV2::model::PatchNotificationRuleParameters, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_vulnerable_assets"; - if local_configuration.is_unstable_operation_enabled(operation_id) { - warn!("Using unstable operation {operation_id}"); - } else { - let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.list_vulnerable_assets' is not enabled".to_string(), - }; - return Err(datadog::Error::UnstableOperationDisabledError(local_error)); - } - - // unbox and build optional parameters - let page_token = params.page_token; - let page_number = params.page_number; - let filter_name = params.filter_name; - let filter_type = params.filter_type; - let filter_version_first = params.filter_version_first; - let filter_version_last = params.filter_version_last; - let filter_repository_url = params.filter_repository_url; - let filter_risks_in_production = params.filter_risks_in_production; - let filter_risks_under_attack = params.filter_risks_under_attack; - let filter_risks_is_publicly_accessible = params.filter_risks_is_publicly_accessible; - let filter_risks_has_privileged_access = params.filter_risks_has_privileged_access; - let filter_risks_has_access_to_sensitive_data = - params.filter_risks_has_access_to_sensitive_data; - let filter_environments = params.filter_environments; - let filter_arch = params.filter_arch; - let filter_operating_system_name = params.filter_operating_system_name; - let filter_operating_system_version = params.filter_operating_system_version; + let operation_id = "v2.patch_vulnerability_notification_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/assets", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/security/vulnerabilities/notification_rules/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) ); let mut local_req_builder = - local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); - if let Some(ref local_query_param) = page_token { - local_req_builder = - local_req_builder.query(&[("page[token]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_number { - local_req_builder = - local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_name { - local_req_builder = - local_req_builder.query(&[("filter[name]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_type { - local_req_builder = - local_req_builder.query(&[("filter[type]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_version_first { - local_req_builder = local_req_builder - .query(&[("filter[version.first]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_version_last { - local_req_builder = local_req_builder - .query(&[("filter[version.last]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_repository_url { - local_req_builder = local_req_builder - .query(&[("filter[repository_url]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_risks_in_production { - local_req_builder = local_req_builder.query(&[( - "filter[risks.in_production]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_risks_under_attack { - local_req_builder = local_req_builder - .query(&[("filter[risks.under_attack]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_risks_is_publicly_accessible { - local_req_builder = local_req_builder.query(&[( - "filter[risks.is_publicly_accessible]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_risks_has_privileged_access { - local_req_builder = local_req_builder.query(&[( - "filter[risks.has_privileged_access]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_risks_has_access_to_sensitive_data { - local_req_builder = local_req_builder.query(&[( - "filter[risks.has_access_to_sensitive_data]", - &local_query_param.to_string(), - )]); - }; - if let Some(ref local_query_param) = filter_environments { - local_req_builder = local_req_builder - .query(&[("filter[environments]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_arch { - local_req_builder = - local_req_builder.query(&[("filter[arch]", &local_query_param.to_string())]); + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } }; - if let Some(ref local_query_param) = filter_operating_system_name { - local_req_builder = local_req_builder.query(&[( - "filter[operating_system.name]", - &local_query_param.to_string(), - )]); + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); }; - if let Some(ref local_query_param) = filter_operating_system_version { - local_req_builder = local_req_builder.query(&[( - "filter[operating_system.version]", - &local_query_param.to_string(), - )]); + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); }; + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Reorder the list of inbox rules in the pipeline and return the reordered list of rules. + /// To reorder fields, you must provide the full list of pipeline rules in the new order. + pub async fn reorder_inbox_rules( + &self, + body: crate::datadogV2::model::ReorderInboxRulesParameters, + ) -> Result< + std::collections::BTreeMap, + datadog::Error, + > { + match self.reorder_inbox_rules_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Reorder the list of inbox rules in the pipeline and return the reordered list of rules. + /// To reorder fields, you must provide the full list of pipeline rules in the new order. + pub async fn reorder_inbox_rules_with_http_info( + &self, + body: crate::datadogV2::model::ReorderInboxRulesParameters, + ) -> Result< + datadog::ResponseContent>, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.reorder_inbox_rules"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/security/vulnerabilities/pipelines/inbox_rules/reorder", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + // build headers let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent @@ -6442,6 +8358,51 @@ impl SecurityMonitoringAPI { ); }; + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; log::debug!("request content: {:?}", local_req.body()); @@ -6452,7 +8413,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::>( &local_content, ) { Ok(e) => { @@ -6465,7 +8426,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -6476,13 +8437,16 @@ impl SecurityMonitoringAPI { } } - /// Mute or unmute findings. - pub async fn mute_findings( + /// Reorder the list of mute rules in the pipeline and return the reordered list of rules. + /// To reorder fields, you must provide the full list of pipeline rules in the new order. + pub async fn reorder_mute_rules( &self, - body: crate::datadogV2::model::BulkMuteFindingsRequest, - ) -> Result> - { - match self.mute_findings_with_http_info(body).await { + body: crate::datadogV2::model::ReorderMuteRulesParameters, + ) -> Result< + std::collections::BTreeMap, + datadog::Error, + > { + match self.reorder_mute_rules_with_http_info(body).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -6496,33 +8460,26 @@ impl SecurityMonitoringAPI { } } - /// Mute or unmute findings. - pub async fn mute_findings_with_http_info( + /// Reorder the list of mute rules in the pipeline and return the reordered list of rules. + /// To reorder fields, you must provide the full list of pipeline rules in the new order. + pub async fn reorder_mute_rules_with_http_info( &self, - body: crate::datadogV2::model::BulkMuteFindingsRequest, + body: crate::datadogV2::model::ReorderMuteRulesParameters, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent>, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.mute_findings"; - if local_configuration.is_unstable_operation_enabled(operation_id) { - warn!("Using unstable operation {operation_id}"); - } else { - let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.mute_findings' is not enabled".to_string(), - }; - return Err(datadog::Error::UnstableOperationDisabledError(local_error)); - } + let operation_id = "v2.reorder_mute_rules"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/posture_management/findings", + "{}/api/v2/security/vulnerabilities/pipelines/mute_rules/reorder", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); @@ -6612,7 +8569,7 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::>( &local_content, ) { Ok(e) => { @@ -6625,7 +8582,8 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_entity: Option = + serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -6635,19 +8593,13 @@ impl SecurityMonitoringAPI { } } - /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. - pub async fn patch_signal_notification_rule( + /// Run a historical job. + pub async fn run_historical_job( &self, - id: String, - body: crate::datadogV2::model::PatchNotificationRuleParameters, - ) -> Result< - crate::datadogV2::model::NotificationRuleResponse, - datadog::Error, - > { - match self - .patch_signal_notification_rule_with_http_info(id, body) - .await - { + body: crate::datadogV2::model::RunHistoricalJobRequest, + ) -> Result> + { + match self.run_historical_job_with_http_info(body).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -6661,27 +8613,33 @@ impl SecurityMonitoringAPI { } } - /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. - pub async fn patch_signal_notification_rule_with_http_info( + /// Run a historical job. + pub async fn run_historical_job_with_http_info( &self, - id: String, - body: crate::datadogV2::model::PatchNotificationRuleParameters, + body: crate::datadogV2::model::RunHistoricalJobRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.patch_signal_notification_rule"; + let operation_id = "v2.run_historical_job"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.run_historical_job' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/signals/notification_rules/{id}", - local_configuration.get_operation_host(operation_id), - id = datadog::urlencode(id) + "{}/api/v2/siem-historical-detections/jobs", + local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); @@ -6771,9 +8729,8 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -6784,7 +8741,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -6795,53 +8752,101 @@ impl SecurityMonitoringAPI { } } - /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. - pub async fn patch_vulnerability_notification_rule( - &self, - id: String, - body: crate::datadogV2::model::PatchNotificationRuleParameters, - ) -> Result< - crate::datadogV2::model::NotificationRuleResponse, - datadog::Error, - > { - match self - .patch_vulnerability_notification_rule_with_http_info(id, body) - .await - { - Ok(response_content) => { - if let Some(e) = response_content.entity { - Ok(e) - } else { - Err(datadog::Error::Serde(serde::de::Error::custom( - "response content was None", - ))) + /// Returns security signals that match a search query. + /// Both this endpoint and the GET endpoint can be used interchangeably for listing + /// security signals. + pub async fn search_security_monitoring_signals( + &self, + params: SearchSecurityMonitoringSignalsOptionalParams, + ) -> Result< + crate::datadogV2::model::SecurityMonitoringSignalsListResponse, + datadog::Error, + > { + match self + .search_security_monitoring_signals_with_http_info(params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub fn search_security_monitoring_signals_with_pagination( + &self, + mut params: SearchSecurityMonitoringSignalsOptionalParams, + ) -> impl Stream< + Item = Result< + crate::datadogV2::model::SecurityMonitoringSignal, + datadog::Error, + >, + > + '_ { + try_stream! { + let mut page_size: i32 = 10; + if params.body.is_none() { + params.body = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequest::new()); + } + if params.body.as_ref().unwrap().page.is_none() { + params.body.as_mut().unwrap().page = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequestPage::new()); + } + if params.body.as_ref().unwrap().page.as_ref().unwrap().limit.is_none() { + params.body.as_mut().unwrap().page.as_mut().unwrap().limit = Some(page_size); + } else { + page_size = params.body.as_ref().unwrap().page.as_ref().unwrap().limit.unwrap().clone(); + } + loop { + let resp = self.search_security_monitoring_signals(params.clone()).await?; + let Some(data) = resp.data else { break }; + + let r = data; + let count = r.len(); + for team in r { + yield team; } + + if count < page_size as usize { + break; + } + let Some(meta) = resp.meta else { break }; + let Some(page) = meta.page else { break }; + let Some(after) = page.after else { break }; + + params.body.as_mut().unwrap().page.as_mut().unwrap().cursor = Some(after); } - Err(err) => Err(err), } } - /// Partially update the notification rule. All fields are optional; if a field is not provided, it is not updated. - pub async fn patch_vulnerability_notification_rule_with_http_info( + /// Returns security signals that match a search query. + /// Both this endpoint and the GET endpoint can be used interchangeably for listing + /// security signals. + pub async fn search_security_monitoring_signals_with_http_info( &self, - id: String, - body: crate::datadogV2::model::PatchNotificationRuleParameters, + params: SearchSecurityMonitoringSignalsOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.patch_vulnerability_notification_rule"; + let operation_id = "v2.search_security_monitoring_signals"; + + // unbox and build optional parameters + let body = params.body; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security/vulnerabilities/notification_rules/{id}", - local_configuration.get_operation_host(operation_id), - id = datadog::urlencode(id) + "{}/api/v2/security_monitoring/signals/search", + local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = - local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); @@ -6931,9 +8936,10 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::< + crate::datadogV2::model::SecurityMonitoringSignalsListResponse, + >(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -6944,7 +8950,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -6955,13 +8961,19 @@ impl SecurityMonitoringAPI { } } - /// Run a historical job. - pub async fn run_historical_job( + /// Test an existing rule. + pub async fn test_existing_security_monitoring_rule( &self, - body: crate::datadogV2::model::RunHistoricalJobRequest, - ) -> Result> - { - match self.run_historical_job_with_http_info(body).await { + rule_id: String, + body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest, + ) -> Result< + crate::datadogV2::model::SecurityMonitoringRuleTestResponse, + datadog::Error, + > { + match self + .test_existing_security_monitoring_rule_with_http_info(rule_id, body) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -6975,30 +8987,24 @@ impl SecurityMonitoringAPI { } } - /// Run a historical job. - pub async fn run_historical_job_with_http_info( + /// Test an existing rule. + pub async fn test_existing_security_monitoring_rule_with_http_info( &self, - body: crate::datadogV2::model::RunHistoricalJobRequest, + rule_id: String, + body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.run_historical_job"; - if local_configuration.is_unstable_operation_enabled(operation_id) { - warn!("Using unstable operation {operation_id}"); - } else { - let local_error = datadog::UnstableOperationDisabledError { - msg: "Operation 'v2.run_historical_job' is not enabled".to_string(), - }; - return Err(datadog::Error::UnstableOperationDisabledError(local_error)); - } + let operation_id = "v2.test_existing_security_monitoring_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/siem-historical-detections/jobs", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/security_monitoring/rules/{rule_id}/test", + local_configuration.get_operation_host(operation_id), + rule_id = datadog::urlencode(rule_id) ); let mut local_req_builder = local_client.request(reqwest::Method::POST, local_uri_str.as_str()); @@ -7091,8 +9097,9 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) - { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -7103,7 +9110,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -7114,18 +9121,16 @@ impl SecurityMonitoringAPI { } } - /// Returns security signals that match a search query. - /// Both this endpoint and the GET endpoint can be used interchangeably for listing - /// security signals. - pub async fn search_security_monitoring_signals( + /// Test a rule. + pub async fn test_security_monitoring_rule( &self, - params: SearchSecurityMonitoringSignalsOptionalParams, + body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest, ) -> Result< - crate::datadogV2::model::SecurityMonitoringSignalsListResponse, - datadog::Error, + crate::datadogV2::model::SecurityMonitoringRuleTestResponse, + datadog::Error, > { match self - .search_security_monitoring_signals_with_http_info(params) + .test_security_monitoring_rule_with_http_info(body) .await { Ok(response_content) => { @@ -7141,70 +9146,21 @@ impl SecurityMonitoringAPI { } } - pub fn search_security_monitoring_signals_with_pagination( - &self, - mut params: SearchSecurityMonitoringSignalsOptionalParams, - ) -> impl Stream< - Item = Result< - crate::datadogV2::model::SecurityMonitoringSignal, - datadog::Error, - >, - > + '_ { - try_stream! { - let mut page_size: i32 = 10; - if params.body.is_none() { - params.body = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequest::new()); - } - if params.body.as_ref().unwrap().page.is_none() { - params.body.as_mut().unwrap().page = Some(crate::datadogV2::model::SecurityMonitoringSignalListRequestPage::new()); - } - if params.body.as_ref().unwrap().page.as_ref().unwrap().limit.is_none() { - params.body.as_mut().unwrap().page.as_mut().unwrap().limit = Some(page_size); - } else { - page_size = params.body.as_ref().unwrap().page.as_ref().unwrap().limit.unwrap().clone(); - } - loop { - let resp = self.search_security_monitoring_signals(params.clone()).await?; - let Some(data) = resp.data else { break }; - - let r = data; - let count = r.len(); - for team in r { - yield team; - } - - if count < page_size as usize { - break; - } - let Some(meta) = resp.meta else { break }; - let Some(page) = meta.page else { break }; - let Some(after) = page.after else { break }; - - params.body.as_mut().unwrap().page.as_mut().unwrap().cursor = Some(after); - } - } - } - - /// Returns security signals that match a search query. - /// Both this endpoint and the GET endpoint can be used interchangeably for listing - /// security signals. - pub async fn search_security_monitoring_signals_with_http_info( + /// Test a rule. + pub async fn test_security_monitoring_rule_with_http_info( &self, - params: SearchSecurityMonitoringSignalsOptionalParams, + body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.search_security_monitoring_signals"; - - // unbox and build optional parameters - let body = params.body; + let operation_id = "v2.test_security_monitoring_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/signals/search", + "{}/api/v2/security_monitoring/rules/test", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -7298,10 +9254,9 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::< - crate::datadogV2::model::SecurityMonitoringSignalsListResponse, - >(&local_content) - { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -7312,7 +9267,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -7323,17 +9278,15 @@ impl SecurityMonitoringAPI { } } - /// Test an existing rule. - pub async fn test_existing_security_monitoring_rule( + /// Update the whole inbox rule. If an optional field is not provided, it is set to its default value. + pub async fn update_inbox_rule( &self, - rule_id: String, - body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest, - ) -> Result< - crate::datadogV2::model::SecurityMonitoringRuleTestResponse, - datadog::Error, - > { + inbox_rule_id: uuid::Uuid, + body: crate::datadogV2::model::UpdateInboxRuleParameters, + ) -> Result> + { match self - .test_existing_security_monitoring_rule_with_http_info(rule_id, body) + .update_inbox_rule_with_http_info(inbox_rule_id, body) .await { Ok(response_content) => { @@ -7349,27 +9302,27 @@ impl SecurityMonitoringAPI { } } - /// Test an existing rule. - pub async fn test_existing_security_monitoring_rule_with_http_info( + /// Update the whole inbox rule. If an optional field is not provided, it is set to its default value. + pub async fn update_inbox_rule_with_http_info( &self, - rule_id: String, - body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest, + inbox_rule_id: uuid::Uuid, + body: crate::datadogV2::model::UpdateInboxRuleParameters, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.test_existing_security_monitoring_rule"; + let operation_id = "v2.update_inbox_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/rules/{rule_id}/test", + "{}/api/v2/security/vulnerabilities/pipelines/inbox_rules/{inbox_rule_id}", local_configuration.get_operation_host(operation_id), - rule_id = datadog::urlencode(rule_id) + inbox_rule_id = datadog::urlencode(inbox_rule_id.to_string()) ); let mut local_req_builder = - local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + local_client.request(reqwest::Method::PUT, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); @@ -7459,9 +9412,8 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -7472,7 +9424,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -7483,16 +9435,15 @@ impl SecurityMonitoringAPI { } } - /// Test a rule. - pub async fn test_security_monitoring_rule( + /// Update the whole mute rule. If an optional field is not provided, it is set to its default value. + pub async fn update_mute_rule( &self, - body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest, - ) -> Result< - crate::datadogV2::model::SecurityMonitoringRuleTestResponse, - datadog::Error, - > { + mute_rule_id: uuid::Uuid, + body: crate::datadogV2::model::UpdateMuteRuleParameters, + ) -> Result> + { match self - .test_security_monitoring_rule_with_http_info(body) + .update_mute_rule_with_http_info(mute_rule_id, body) .await { Ok(response_content) => { @@ -7508,25 +9459,27 @@ impl SecurityMonitoringAPI { } } - /// Test a rule. - pub async fn test_security_monitoring_rule_with_http_info( + /// Update the whole mute rule. If an optional field is not provided, it is set to its default value. + pub async fn update_mute_rule_with_http_info( &self, - body: crate::datadogV2::model::SecurityMonitoringRuleTestRequest, + mute_rule_id: uuid::Uuid, + body: crate::datadogV2::model::UpdateMuteRuleParameters, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.test_security_monitoring_rule"; + let operation_id = "v2.update_mute_rule"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/security_monitoring/rules/test", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/security/vulnerabilities/pipelines/mute_rules/{mute_rule_id}", + local_configuration.get_operation_host(operation_id), + mute_rule_id = datadog::urlencode(mute_rule_id.to_string()) ); let mut local_req_builder = - local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + local_client.request(reqwest::Method::PUT, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); @@ -7616,9 +9569,8 @@ impl SecurityMonitoringAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -7629,7 +9581,7 @@ impl SecurityMonitoringAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index ab6f244be..fa8a94449 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2940,6 +2940,78 @@ pub mod model_vulnerability_relationships_affects_data; pub use self::model_vulnerability_relationships_affects_data::VulnerabilityRelationshipsAffectsData; pub mod model_vulnerabilities_type; pub use self::model_vulnerabilities_type::VulnerabilitiesType; +pub mod model_create_inbox_rule_parameters; +pub use self::model_create_inbox_rule_parameters::CreateInboxRuleParameters; +pub mod model_create_inbox_rule_parameters_data; +pub use self::model_create_inbox_rule_parameters_data::CreateInboxRuleParametersData; +pub mod model_create_inbox_rule_parameters_data_attributes; +pub use self::model_create_inbox_rule_parameters_data_attributes::CreateInboxRuleParametersDataAttributes; +pub mod model_action_inbox; +pub use self::model_action_inbox::ActionInbox; +pub mod model_automation_rule; +pub use self::model_automation_rule::AutomationRule; +pub mod model_issue_type; +pub use self::model_issue_type::IssueType; +pub mod model_security_rule_types_items; +pub use self::model_security_rule_types_items::SecurityRuleTypesItems; +pub mod model_security_rule_severity; +pub use self::model_security_rule_severity::SecurityRuleSeverity; +pub mod model_inbox_rules_type; +pub use self::model_inbox_rules_type::InboxRulesType; +pub mod model_inbox_rule_response; +pub use self::model_inbox_rule_response::InboxRuleResponse; +pub mod model_inbox_rule; +pub use self::model_inbox_rule::InboxRule; +pub mod model_inbox_rule_attributes; +pub use self::model_inbox_rule_attributes::InboxRuleAttributes; +pub mod model_automation_rule_user; +pub use self::model_automation_rule_user::AutomationRuleUser; +pub mod model_reorder_inbox_rules_parameters; +pub use self::model_reorder_inbox_rules_parameters::ReorderInboxRulesParameters; +pub mod model_reorder_inbox_rules_parameters_data; +pub use self::model_reorder_inbox_rules_parameters_data::ReorderInboxRulesParametersData; +pub mod model_patch_inbox_rules_parameters; +pub use self::model_patch_inbox_rules_parameters::PatchInboxRulesParameters; +pub mod model_patch_inbox_rules_parameters_data; +pub use self::model_patch_inbox_rules_parameters_data::PatchInboxRulesParametersData; +pub mod model_patch_inbox_rules_parameters_data_attributes; +pub use self::model_patch_inbox_rules_parameters_data_attributes::PatchInboxRulesParametersDataAttributes; +pub mod model_update_inbox_rule_parameters; +pub use self::model_update_inbox_rule_parameters::UpdateInboxRuleParameters; +pub mod model_update_inbox_rule_parameters_data; +pub use self::model_update_inbox_rule_parameters_data::UpdateInboxRuleParametersData; +pub mod model_create_mute_rule_parameters; +pub use self::model_create_mute_rule_parameters::CreateMuteRuleParameters; +pub mod model_create_mute_rule_parameters_data; +pub use self::model_create_mute_rule_parameters_data::CreateMuteRuleParametersData; +pub mod model_create_mute_rule_parameters_data_attributes; +pub use self::model_create_mute_rule_parameters_data_attributes::CreateMuteRuleParametersDataAttributes; +pub mod model_action_mute; +pub use self::model_action_mute::ActionMute; +pub mod model_mute_reason; +pub use self::model_mute_reason::MuteReason; +pub mod model_mute_rules_type; +pub use self::model_mute_rules_type::MuteRulesType; +pub mod model_mute_rule_response; +pub use self::model_mute_rule_response::MuteRuleResponse; +pub mod model_mute_rule; +pub use self::model_mute_rule::MuteRule; +pub mod model_mute_rule_attributes; +pub use self::model_mute_rule_attributes::MuteRuleAttributes; +pub mod model_reorder_mute_rules_parameters; +pub use self::model_reorder_mute_rules_parameters::ReorderMuteRulesParameters; +pub mod model_reorder_mute_rules_parameters_data; +pub use self::model_reorder_mute_rules_parameters_data::ReorderMuteRulesParametersData; +pub mod model_patch_mute_rule_parameters; +pub use self::model_patch_mute_rule_parameters::PatchMuteRuleParameters; +pub mod model_patch_mute_rule_parameters_data; +pub use self::model_patch_mute_rule_parameters_data::PatchMuteRuleParametersData; +pub mod model_patch_mute_rule_parameters_data_attributes; +pub use self::model_patch_mute_rule_parameters_data_attributes::PatchMuteRuleParametersDataAttributes; +pub mod model_update_mute_rule_parameters; +pub use self::model_update_mute_rule_parameters::UpdateMuteRuleParameters; +pub mod model_update_mute_rule_parameters_data; +pub use self::model_update_mute_rule_parameters_data::UpdateMuteRuleParametersData; pub mod model_security_filters_response; pub use self::model_security_filters_response::SecurityFiltersResponse; pub mod model_security_filter; diff --git a/src/datadogV2/model/model_action_inbox.rs b/src/datadogV2/model/model_action_inbox.rs new file mode 100644 index 000000000..e9da8fab3 --- /dev/null +++ b/src/datadogV2/model/model_action_inbox.rs @@ -0,0 +1,106 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Action of the inbox rule +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ActionInbox { + /// Free text to add a reason description. + #[serde(rename = "reason_description")] + pub reason_description: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ActionInbox { + pub fn new() -> ActionInbox { + ActionInbox { + reason_description: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn reason_description(mut self, value: String) -> Self { + self.reason_description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ActionInbox { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ActionInbox { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ActionInboxVisitor; + impl<'a> Visitor<'a> for ActionInboxVisitor { + type Value = ActionInbox; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut reason_description: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "reason_description" => { + if v.is_null() { + continue; + } + reason_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ActionInbox { + reason_description, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ActionInboxVisitor) + } +} diff --git a/src/datadogV2/model/model_action_mute.rs b/src/datadogV2/model/model_action_mute.rs new file mode 100644 index 000000000..fa1b39b68 --- /dev/null +++ b/src/datadogV2/model/model_action_mute.rs @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Action of the mute rule +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ActionMute { + /// End date of the mute rule (null means mute forever) + #[serde(rename = "expire_at")] + pub expire_at: Option, + /// Reason for muting a vulnerability + #[serde(rename = "reason")] + pub reason: crate::datadogV2::model::MuteReason, + /// Free text to add a reason description. + #[serde(rename = "reason_description")] + pub reason_description: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ActionMute { + pub fn new(reason: crate::datadogV2::model::MuteReason) -> ActionMute { + ActionMute { + expire_at: None, + reason, + reason_description: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn expire_at(mut self, value: i64) -> Self { + self.expire_at = Some(value); + self + } + + pub fn reason_description(mut self, value: String) -> Self { + self.reason_description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ActionMute { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ActionMuteVisitor; + impl<'a> Visitor<'a> for ActionMuteVisitor { + type Value = ActionMute; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut expire_at: Option = None; + let mut reason: Option = None; + let mut reason_description: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "expire_at" => { + if v.is_null() { + continue; + } + expire_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "reason" => { + reason = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _reason) = reason { + match _reason { + crate::datadogV2::model::MuteReason::UnparsedObject( + _reason, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "reason_description" => { + if v.is_null() { + continue; + } + reason_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let reason = reason.ok_or_else(|| M::Error::missing_field("reason"))?; + + let content = ActionMute { + expire_at, + reason, + reason_description, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ActionMuteVisitor) + } +} diff --git a/src/datadogV2/model/model_automation_rule.rs b/src/datadogV2/model/model_automation_rule.rs new file mode 100644 index 000000000..d45ad6bf1 --- /dev/null +++ b/src/datadogV2/model/model_automation_rule.rs @@ -0,0 +1,171 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of an automation pipeline rule scope. +/// A rule can act on specific issue types, security rule types, security rule IDs, rule severities, or a query. +/// The query can be used to filter resources on tags and attributes. +/// The issue type and rule types fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AutomationRule { + /// The type of issues on which the rule applies + #[serde(rename = "issue_type")] + pub issue_type: crate::datadogV2::model::IssueType, + /// The query is composed of one or several key:value pairs, which can be used to filter resources on tags and attributes. + #[serde(rename = "query")] + pub query: Option, + /// Security rule ids + #[serde(rename = "rule_ids")] + pub rule_ids: Option>, + /// Security rule types + #[serde(rename = "rule_types")] + pub rule_types: Vec, + /// The security rules severities to consider + #[serde(rename = "severities")] + pub severities: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AutomationRule { + pub fn new( + issue_type: crate::datadogV2::model::IssueType, + rule_types: Vec, + ) -> AutomationRule { + AutomationRule { + issue_type, + query: None, + rule_ids: None, + rule_types, + severities: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn query(mut self, value: String) -> Self { + self.query = Some(value); + self + } + + pub fn rule_ids(mut self, value: Vec) -> Self { + self.rule_ids = Some(value); + self + } + + pub fn severities(mut self, value: Vec) -> Self { + self.severities = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AutomationRule { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AutomationRuleVisitor; + impl<'a> Visitor<'a> for AutomationRuleVisitor { + type Value = AutomationRule; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut issue_type: Option = None; + let mut query: Option = None; + let mut rule_ids: Option> = None; + let mut rule_types: Option> = + None; + let mut severities: Option> = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "issue_type" => { + issue_type = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _issue_type) = issue_type { + match _issue_type { + crate::datadogV2::model::IssueType::UnparsedObject( + _issue_type, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "query" => { + if v.is_null() { + continue; + } + query = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule_ids" => { + if v.is_null() { + continue; + } + rule_ids = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule_types" => { + rule_types = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "severities" => { + if v.is_null() { + continue; + } + severities = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let issue_type = issue_type.ok_or_else(|| M::Error::missing_field("issue_type"))?; + let rule_types = rule_types.ok_or_else(|| M::Error::missing_field("rule_types"))?; + + let content = AutomationRule { + issue_type, + query, + rule_ids, + rule_types, + severities, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AutomationRuleVisitor) + } +} diff --git a/src/datadogV2/model/model_automation_rule_user.rs b/src/datadogV2/model/model_automation_rule_user.rs new file mode 100644 index 000000000..4b9821346 --- /dev/null +++ b/src/datadogV2/model/model_automation_rule_user.rs @@ -0,0 +1,122 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// User creating or modifying a rule +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AutomationRuleUser { + /// The user handle. + #[serde(rename = "handle")] + pub handle: Option, + /// The user name. + #[serde(rename = "name")] + pub name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AutomationRuleUser { + pub fn new() -> AutomationRuleUser { + AutomationRuleUser { + handle: None, + name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn handle(mut self, value: String) -> Self { + self.handle = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for AutomationRuleUser { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for AutomationRuleUser { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AutomationRuleUserVisitor; + impl<'a> Visitor<'a> for AutomationRuleUserVisitor { + type Value = AutomationRuleUser; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut handle: Option = None; + let mut name: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "handle" => { + if v.is_null() { + continue; + } + handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = AutomationRuleUser { + handle, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AutomationRuleUserVisitor) + } +} diff --git a/src/datadogV2/model/model_create_inbox_rule_parameters.rs b/src/datadogV2/model/model_create_inbox_rule_parameters.rs new file mode 100644 index 000000000..5d77fc0aa --- /dev/null +++ b/src/datadogV2/model/model_create_inbox_rule_parameters.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Body of the inbox rule create request +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateInboxRuleParameters { + /// Data of the inbox rule create request: the rule type and the rule attributes. All fields are required. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateInboxRuleParameters { + pub fn new() -> CreateInboxRuleParameters { + CreateInboxRuleParameters { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::CreateInboxRuleParametersData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateInboxRuleParameters { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateInboxRuleParameters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateInboxRuleParametersVisitor; + impl<'a> Visitor<'a> for CreateInboxRuleParametersVisitor { + type Value = CreateInboxRuleParameters; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateInboxRuleParameters { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateInboxRuleParametersVisitor) + } +} diff --git a/src/datadogV2/model/model_create_inbox_rule_parameters_data.rs b/src/datadogV2/model/model_create_inbox_rule_parameters_data.rs new file mode 100644 index 000000000..3bff2f37f --- /dev/null +++ b/src/datadogV2/model/model_create_inbox_rule_parameters_data.rs @@ -0,0 +1,117 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data of the inbox rule create request: the rule type and the rule attributes. All fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateInboxRuleParametersData { + /// Attributes of the inbox rule create request: the rule name, the rule details, the associated action, and the optional enabled field. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::CreateInboxRuleParametersDataAttributes, + /// The pipeline rule type associated to inbox rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::InboxRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateInboxRuleParametersData { + pub fn new( + attributes: crate::datadogV2::model::CreateInboxRuleParametersDataAttributes, + type_: crate::datadogV2::model::InboxRulesType, + ) -> CreateInboxRuleParametersData { + CreateInboxRuleParametersData { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateInboxRuleParametersData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateInboxRuleParametersDataVisitor; + impl<'a> Visitor<'a> for CreateInboxRuleParametersDataVisitor { + type Value = CreateInboxRuleParametersData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::CreateInboxRuleParametersDataAttributes, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::InboxRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateInboxRuleParametersData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateInboxRuleParametersDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_inbox_rule_parameters_data_attributes.rs b/src/datadogV2/model/model_create_inbox_rule_parameters_data_attributes.rs new file mode 100644 index 000000000..b1030046e --- /dev/null +++ b/src/datadogV2/model/model_create_inbox_rule_parameters_data_attributes.rs @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the inbox rule create request: the rule name, the rule details, the associated action, and the optional enabled field. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateInboxRuleParametersDataAttributes { + /// Action of the inbox rule + #[serde(rename = "action")] + pub action: crate::datadogV2::model::ActionInbox, + /// Field used to enable or disable the rule. + #[serde(rename = "enabled")] + pub enabled: Option, + /// Name of the pipeline rule + #[serde(rename = "name")] + pub name: String, + /// The definition of an automation pipeline rule scope. + /// A rule can act on specific issue types, security rule types, security rule IDs, rule severities, or a query. + /// The query can be used to filter resources on tags and attributes. + /// The issue type and rule types fields are required. + #[serde(rename = "rule")] + pub rule: crate::datadogV2::model::AutomationRule, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateInboxRuleParametersDataAttributes { + pub fn new( + action: crate::datadogV2::model::ActionInbox, + name: String, + rule: crate::datadogV2::model::AutomationRule, + ) -> CreateInboxRuleParametersDataAttributes { + CreateInboxRuleParametersDataAttributes { + action, + enabled: None, + name, + rule, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn enabled(mut self, value: bool) -> Self { + self.enabled = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateInboxRuleParametersDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateInboxRuleParametersDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateInboxRuleParametersDataAttributesVisitor { + type Value = CreateInboxRuleParametersDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut action: Option = None; + let mut enabled: Option = None; + let mut name: Option = None; + let mut rule: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "action" => { + action = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + if v.is_null() { + continue; + } + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule" => { + rule = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let action = action.ok_or_else(|| M::Error::missing_field("action"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let rule = rule.ok_or_else(|| M::Error::missing_field("rule"))?; + + let content = CreateInboxRuleParametersDataAttributes { + action, + enabled, + name, + rule, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateInboxRuleParametersDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_create_mute_rule_parameters.rs b/src/datadogV2/model/model_create_mute_rule_parameters.rs new file mode 100644 index 000000000..bf3d22bbe --- /dev/null +++ b/src/datadogV2/model/model_create_mute_rule_parameters.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Body of the mute rule create request +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateMuteRuleParameters { + /// Data of the mute rule create request: the rule type and the rule attributes. All fields are required. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateMuteRuleParameters { + pub fn new() -> CreateMuteRuleParameters { + CreateMuteRuleParameters { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::CreateMuteRuleParametersData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateMuteRuleParameters { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateMuteRuleParameters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateMuteRuleParametersVisitor; + impl<'a> Visitor<'a> for CreateMuteRuleParametersVisitor { + type Value = CreateMuteRuleParameters; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateMuteRuleParameters { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateMuteRuleParametersVisitor) + } +} diff --git a/src/datadogV2/model/model_create_mute_rule_parameters_data.rs b/src/datadogV2/model/model_create_mute_rule_parameters_data.rs new file mode 100644 index 000000000..d8f3f9ce4 --- /dev/null +++ b/src/datadogV2/model/model_create_mute_rule_parameters_data.rs @@ -0,0 +1,117 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data of the mute rule create request: the rule type and the rule attributes. All fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateMuteRuleParametersData { + /// Attributes of the mute rule create request: the rule name, the rule details, the associated action, and the optional enabled field. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::CreateMuteRuleParametersDataAttributes, + /// The pipeline rule type associated to mute rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::MuteRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateMuteRuleParametersData { + pub fn new( + attributes: crate::datadogV2::model::CreateMuteRuleParametersDataAttributes, + type_: crate::datadogV2::model::MuteRulesType, + ) -> CreateMuteRuleParametersData { + CreateMuteRuleParametersData { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateMuteRuleParametersData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateMuteRuleParametersDataVisitor; + impl<'a> Visitor<'a> for CreateMuteRuleParametersDataVisitor { + type Value = CreateMuteRuleParametersData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::CreateMuteRuleParametersDataAttributes, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::MuteRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateMuteRuleParametersData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateMuteRuleParametersDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_mute_rule_parameters_data_attributes.rs b/src/datadogV2/model/model_create_mute_rule_parameters_data_attributes.rs new file mode 100644 index 000000000..e6db6de1c --- /dev/null +++ b/src/datadogV2/model/model_create_mute_rule_parameters_data_attributes.rs @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the mute rule create request: the rule name, the rule details, the associated action, and the optional enabled field. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateMuteRuleParametersDataAttributes { + /// Action of the mute rule + #[serde(rename = "action")] + pub action: crate::datadogV2::model::ActionMute, + /// Field used to enable or disable the rule. + #[serde(rename = "enabled")] + pub enabled: Option, + /// Name of the pipeline rule + #[serde(rename = "name")] + pub name: String, + /// The definition of an automation pipeline rule scope. + /// A rule can act on specific issue types, security rule types, security rule IDs, rule severities, or a query. + /// The query can be used to filter resources on tags and attributes. + /// The issue type and rule types fields are required. + #[serde(rename = "rule")] + pub rule: crate::datadogV2::model::AutomationRule, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateMuteRuleParametersDataAttributes { + pub fn new( + action: crate::datadogV2::model::ActionMute, + name: String, + rule: crate::datadogV2::model::AutomationRule, + ) -> CreateMuteRuleParametersDataAttributes { + CreateMuteRuleParametersDataAttributes { + action, + enabled: None, + name, + rule, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn enabled(mut self, value: bool) -> Self { + self.enabled = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateMuteRuleParametersDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateMuteRuleParametersDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateMuteRuleParametersDataAttributesVisitor { + type Value = CreateMuteRuleParametersDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut action: Option = None; + let mut enabled: Option = None; + let mut name: Option = None; + let mut rule: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "action" => { + action = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + if v.is_null() { + continue; + } + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule" => { + rule = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let action = action.ok_or_else(|| M::Error::missing_field("action"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let rule = rule.ok_or_else(|| M::Error::missing_field("rule"))?; + + let content = CreateMuteRuleParametersDataAttributes { + action, + enabled, + name, + rule, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateMuteRuleParametersDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_inbox_rule.rs b/src/datadogV2/model/model_inbox_rule.rs new file mode 100644 index 000000000..8972497fe --- /dev/null +++ b/src/datadogV2/model/model_inbox_rule.rs @@ -0,0 +1,127 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Inbox rules are used to prioritize and add relevant vulnerabilities to your Security Inbox. +/// An inbox rule is composed of a rule UUID, a rule type, and the rule attributes. All fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct InboxRule { + /// Attributes of the inbox rule + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::InboxRuleAttributes, + /// The ID of a pipeline rule + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The pipeline rule type associated to inbox rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::InboxRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl InboxRule { + pub fn new( + attributes: crate::datadogV2::model::InboxRuleAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::InboxRulesType, + ) -> InboxRule { + InboxRule { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for InboxRule { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct InboxRuleVisitor; + impl<'a> Visitor<'a> for InboxRuleVisitor { + type Value = InboxRule; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::InboxRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = InboxRule { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(InboxRuleVisitor) + } +} diff --git a/src/datadogV2/model/model_inbox_rule_attributes.rs b/src/datadogV2/model/model_inbox_rule_attributes.rs new file mode 100644 index 000000000..1b31576d0 --- /dev/null +++ b/src/datadogV2/model/model_inbox_rule_attributes.rs @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the inbox rule +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct InboxRuleAttributes { + /// Action of the inbox rule + #[serde(rename = "action")] + pub action: crate::datadogV2::model::ActionInbox, + /// Date as Unix timestamp in milliseconds + #[serde(rename = "created_at")] + pub created_at: i64, + /// User creating or modifying a rule + #[serde(rename = "created_by")] + pub created_by: crate::datadogV2::model::AutomationRuleUser, + /// Field used to enable or disable the rule. + #[serde(rename = "enabled")] + pub enabled: bool, + /// Date as Unix timestamp in milliseconds + #[serde(rename = "modified_at")] + pub modified_at: i64, + /// User creating or modifying a rule + #[serde(rename = "modified_by")] + pub modified_by: crate::datadogV2::model::AutomationRuleUser, + /// Name of the pipeline rule + #[serde(rename = "name")] + pub name: String, + /// The definition of an automation pipeline rule scope. + /// A rule can act on specific issue types, security rule types, security rule IDs, rule severities, or a query. + /// The query can be used to filter resources on tags and attributes. + /// The issue type and rule types fields are required. + #[serde(rename = "rule")] + pub rule: crate::datadogV2::model::AutomationRule, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl InboxRuleAttributes { + pub fn new( + action: crate::datadogV2::model::ActionInbox, + created_at: i64, + created_by: crate::datadogV2::model::AutomationRuleUser, + enabled: bool, + modified_at: i64, + modified_by: crate::datadogV2::model::AutomationRuleUser, + name: String, + rule: crate::datadogV2::model::AutomationRule, + ) -> InboxRuleAttributes { + InboxRuleAttributes { + action, + created_at, + created_by, + enabled, + modified_at, + modified_by, + name, + rule, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for InboxRuleAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct InboxRuleAttributesVisitor; + impl<'a> Visitor<'a> for InboxRuleAttributesVisitor { + type Value = InboxRuleAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut action: Option = None; + let mut created_at: Option = None; + let mut created_by: Option = None; + let mut enabled: Option = None; + let mut modified_at: Option = None; + let mut modified_by: Option = None; + let mut name: Option = None; + let mut rule: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "action" => { + action = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_by" => { + created_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_by" => { + modified_by = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule" => { + rule = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let action = action.ok_or_else(|| M::Error::missing_field("action"))?; + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let created_by = created_by.ok_or_else(|| M::Error::missing_field("created_by"))?; + let enabled = enabled.ok_or_else(|| M::Error::missing_field("enabled"))?; + let modified_at = + modified_at.ok_or_else(|| M::Error::missing_field("modified_at"))?; + let modified_by = + modified_by.ok_or_else(|| M::Error::missing_field("modified_by"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let rule = rule.ok_or_else(|| M::Error::missing_field("rule"))?; + + let content = InboxRuleAttributes { + action, + created_at, + created_by, + enabled, + modified_at, + modified_by, + name, + rule, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(InboxRuleAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_inbox_rule_response.rs b/src/datadogV2/model/model_inbox_rule_response.rs new file mode 100644 index 000000000..1207d4937 --- /dev/null +++ b/src/datadogV2/model/model_inbox_rule_response.rs @@ -0,0 +1,106 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response object which includes an inbox rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct InboxRuleResponse { + /// Inbox rules are used to prioritize and add relevant vulnerabilities to your Security Inbox. + /// An inbox rule is composed of a rule UUID, a rule type, and the rule attributes. All fields are required. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl InboxRuleResponse { + pub fn new() -> InboxRuleResponse { + InboxRuleResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::InboxRule) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for InboxRuleResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for InboxRuleResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct InboxRuleResponseVisitor; + impl<'a> Visitor<'a> for InboxRuleResponseVisitor { + type Value = InboxRuleResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = InboxRuleResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(InboxRuleResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_inbox_rules_type.rs b/src/datadogV2/model/model_inbox_rules_type.rs new file mode 100644 index 000000000..8a2eeb3a7 --- /dev/null +++ b/src/datadogV2/model/model_inbox_rules_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum InboxRulesType { + INBOX_RULES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for InboxRulesType { + fn to_string(&self) -> String { + match self { + Self::INBOX_RULES => String::from("inbox_rules"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for InboxRulesType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for InboxRulesType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "inbox_rules" => Self::INBOX_RULES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_issue_type.rs b/src/datadogV2/model/model_issue_type.rs new file mode 100644 index 000000000..f15233f9f --- /dev/null +++ b/src/datadogV2/model/model_issue_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum IssueType { + VULNERABILITY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for IssueType { + fn to_string(&self) -> String { + match self { + Self::VULNERABILITY => String::from("vulnerability"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for IssueType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for IssueType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "vulnerability" => Self::VULNERABILITY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_mute_reason.rs b/src/datadogV2/model/model_mute_reason.rs new file mode 100644 index 000000000..87a757ec8 --- /dev/null +++ b/src/datadogV2/model/model_mute_reason.rs @@ -0,0 +1,69 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum MuteReason { + DUPLICATE, + EXTERNAL_SOLUTION, + FALSE_POSITIVE, + INTERNAL_SOLUTION, + NO_FIX_AVAILABLE, + OTHER, + PENDING_FIX, + RISK_ACCEPTED, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for MuteReason { + fn to_string(&self) -> String { + match self { + Self::DUPLICATE => String::from("duplicate"), + Self::EXTERNAL_SOLUTION => String::from("external_solution"), + Self::FALSE_POSITIVE => String::from("false_positive"), + Self::INTERNAL_SOLUTION => String::from("internal_solution"), + Self::NO_FIX_AVAILABLE => String::from("no_fix_available"), + Self::OTHER => String::from("other"), + Self::PENDING_FIX => String::from("pending_fix"), + Self::RISK_ACCEPTED => String::from("risk_accepted"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for MuteReason { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for MuteReason { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "duplicate" => Self::DUPLICATE, + "external_solution" => Self::EXTERNAL_SOLUTION, + "false_positive" => Self::FALSE_POSITIVE, + "internal_solution" => Self::INTERNAL_SOLUTION, + "no_fix_available" => Self::NO_FIX_AVAILABLE, + "other" => Self::OTHER, + "pending_fix" => Self::PENDING_FIX, + "risk_accepted" => Self::RISK_ACCEPTED, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_mute_rule.rs b/src/datadogV2/model/model_mute_rule.rs new file mode 100644 index 000000000..db65d666a --- /dev/null +++ b/src/datadogV2/model/model_mute_rule.rs @@ -0,0 +1,128 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Mute rules are used to proactively filter out known false positives or accepted risks. +/// A mute rule is composed of a rule UUID, a rule type, and the rule attributes. All fields are required. +/// +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MuteRule { + /// Attributes of the mute rule + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::MuteRuleAttributes, + /// The ID of a pipeline rule + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The pipeline rule type associated to mute rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::MuteRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MuteRule { + pub fn new( + attributes: crate::datadogV2::model::MuteRuleAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::MuteRulesType, + ) -> MuteRule { + MuteRule { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MuteRule { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MuteRuleVisitor; + impl<'a> Visitor<'a> for MuteRuleVisitor { + type Value = MuteRule; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::MuteRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = MuteRule { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MuteRuleVisitor) + } +} diff --git a/src/datadogV2/model/model_mute_rule_attributes.rs b/src/datadogV2/model/model_mute_rule_attributes.rs new file mode 100644 index 000000000..eaa491a6f --- /dev/null +++ b/src/datadogV2/model/model_mute_rule_attributes.rs @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the mute rule +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MuteRuleAttributes { + /// Action of the mute rule + #[serde(rename = "action")] + pub action: crate::datadogV2::model::ActionMute, + /// Date as Unix timestamp in milliseconds + #[serde(rename = "created_at")] + pub created_at: i64, + /// User creating or modifying a rule + #[serde(rename = "created_by")] + pub created_by: crate::datadogV2::model::AutomationRuleUser, + /// Field used to enable or disable the rule. + #[serde(rename = "enabled")] + pub enabled: bool, + /// Date as Unix timestamp in milliseconds + #[serde(rename = "modified_at")] + pub modified_at: i64, + /// User creating or modifying a rule + #[serde(rename = "modified_by")] + pub modified_by: crate::datadogV2::model::AutomationRuleUser, + /// Name of the pipeline rule + #[serde(rename = "name")] + pub name: String, + /// The definition of an automation pipeline rule scope. + /// A rule can act on specific issue types, security rule types, security rule IDs, rule severities, or a query. + /// The query can be used to filter resources on tags and attributes. + /// The issue type and rule types fields are required. + #[serde(rename = "rule")] + pub rule: crate::datadogV2::model::AutomationRule, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MuteRuleAttributes { + pub fn new( + action: crate::datadogV2::model::ActionMute, + created_at: i64, + created_by: crate::datadogV2::model::AutomationRuleUser, + enabled: bool, + modified_at: i64, + modified_by: crate::datadogV2::model::AutomationRuleUser, + name: String, + rule: crate::datadogV2::model::AutomationRule, + ) -> MuteRuleAttributes { + MuteRuleAttributes { + action, + created_at, + created_by, + enabled, + modified_at, + modified_by, + name, + rule, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MuteRuleAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MuteRuleAttributesVisitor; + impl<'a> Visitor<'a> for MuteRuleAttributesVisitor { + type Value = MuteRuleAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut action: Option = None; + let mut created_at: Option = None; + let mut created_by: Option = None; + let mut enabled: Option = None; + let mut modified_at: Option = None; + let mut modified_by: Option = None; + let mut name: Option = None; + let mut rule: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "action" => { + action = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_by" => { + created_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_by" => { + modified_by = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule" => { + rule = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let action = action.ok_or_else(|| M::Error::missing_field("action"))?; + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let created_by = created_by.ok_or_else(|| M::Error::missing_field("created_by"))?; + let enabled = enabled.ok_or_else(|| M::Error::missing_field("enabled"))?; + let modified_at = + modified_at.ok_or_else(|| M::Error::missing_field("modified_at"))?; + let modified_by = + modified_by.ok_or_else(|| M::Error::missing_field("modified_by"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let rule = rule.ok_or_else(|| M::Error::missing_field("rule"))?; + + let content = MuteRuleAttributes { + action, + created_at, + created_by, + enabled, + modified_at, + modified_by, + name, + rule, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MuteRuleAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_mute_rule_response.rs b/src/datadogV2/model/model_mute_rule_response.rs new file mode 100644 index 000000000..c035b117a --- /dev/null +++ b/src/datadogV2/model/model_mute_rule_response.rs @@ -0,0 +1,107 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response object which includes a mute rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MuteRuleResponse { + /// Mute rules are used to proactively filter out known false positives or accepted risks. + /// A mute rule is composed of a rule UUID, a rule type, and the rule attributes. All fields are required. + /// + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MuteRuleResponse { + pub fn new() -> MuteRuleResponse { + MuteRuleResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::MuteRule) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for MuteRuleResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for MuteRuleResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MuteRuleResponseVisitor; + impl<'a> Visitor<'a> for MuteRuleResponseVisitor { + type Value = MuteRuleResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = MuteRuleResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MuteRuleResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_mute_rules_type.rs b/src/datadogV2/model/model_mute_rules_type.rs new file mode 100644 index 000000000..b490d27a1 --- /dev/null +++ b/src/datadogV2/model/model_mute_rules_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum MuteRulesType { + MUTE_RULES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for MuteRulesType { + fn to_string(&self) -> String { + match self { + Self::MUTE_RULES => String::from("mute_rules"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for MuteRulesType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for MuteRulesType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "mute_rules" => Self::MUTE_RULES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_patch_inbox_rules_parameters.rs b/src/datadogV2/model/model_patch_inbox_rules_parameters.rs new file mode 100644 index 000000000..a9434584d --- /dev/null +++ b/src/datadogV2/model/model_patch_inbox_rules_parameters.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Body of the inbox rule patch request +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchInboxRulesParameters { + /// Data of the inbox rule patch request: the rule UUID, the rule type, and the rule attributes. All fields are required. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchInboxRulesParameters { + pub fn new() -> PatchInboxRulesParameters { + PatchInboxRulesParameters { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::PatchInboxRulesParametersData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchInboxRulesParameters { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchInboxRulesParameters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchInboxRulesParametersVisitor; + impl<'a> Visitor<'a> for PatchInboxRulesParametersVisitor { + type Value = PatchInboxRulesParameters; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchInboxRulesParameters { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchInboxRulesParametersVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_inbox_rules_parameters_data.rs b/src/datadogV2/model/model_patch_inbox_rules_parameters_data.rs new file mode 100644 index 000000000..81b2157ed --- /dev/null +++ b/src/datadogV2/model/model_patch_inbox_rules_parameters_data.rs @@ -0,0 +1,128 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data of the inbox rule patch request: the rule UUID, the rule type, and the rule attributes. All fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchInboxRulesParametersData { + /// Attributes of the inbox rule patch request: the rule name, the rule details, the associated action, and the enabled field. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::PatchInboxRulesParametersDataAttributes, + /// The ID of a pipeline rule + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The pipeline rule type associated to inbox rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::InboxRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchInboxRulesParametersData { + pub fn new( + attributes: crate::datadogV2::model::PatchInboxRulesParametersDataAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::InboxRulesType, + ) -> PatchInboxRulesParametersData { + PatchInboxRulesParametersData { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchInboxRulesParametersData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchInboxRulesParametersDataVisitor; + impl<'a> Visitor<'a> for PatchInboxRulesParametersDataVisitor { + type Value = PatchInboxRulesParametersData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::PatchInboxRulesParametersDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::InboxRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PatchInboxRulesParametersData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchInboxRulesParametersDataVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_inbox_rules_parameters_data_attributes.rs b/src/datadogV2/model/model_patch_inbox_rules_parameters_data_attributes.rs new file mode 100644 index 000000000..d0d9c52a5 --- /dev/null +++ b/src/datadogV2/model/model_patch_inbox_rules_parameters_data_attributes.rs @@ -0,0 +1,159 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the inbox rule patch request: the rule name, the rule details, the associated action, and the enabled field. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchInboxRulesParametersDataAttributes { + /// Action of the inbox rule + #[serde(rename = "action")] + pub action: Option, + /// Field used to enable or disable the rule. + #[serde(rename = "enabled")] + pub enabled: Option, + /// Name of the pipeline rule + #[serde(rename = "name")] + pub name: Option, + /// The definition of an automation pipeline rule scope. + /// A rule can act on specific issue types, security rule types, security rule IDs, rule severities, or a query. + /// The query can be used to filter resources on tags and attributes. + /// The issue type and rule types fields are required. + #[serde(rename = "rule")] + pub rule: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchInboxRulesParametersDataAttributes { + pub fn new() -> PatchInboxRulesParametersDataAttributes { + PatchInboxRulesParametersDataAttributes { + action: None, + enabled: None, + name: None, + rule: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn action(mut self, value: crate::datadogV2::model::ActionInbox) -> Self { + self.action = Some(value); + self + } + + pub fn enabled(mut self, value: bool) -> Self { + self.enabled = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn rule(mut self, value: crate::datadogV2::model::AutomationRule) -> Self { + self.rule = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchInboxRulesParametersDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchInboxRulesParametersDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchInboxRulesParametersDataAttributesVisitor; + impl<'a> Visitor<'a> for PatchInboxRulesParametersDataAttributesVisitor { + type Value = PatchInboxRulesParametersDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut action: Option = None; + let mut enabled: Option = None; + let mut name: Option = None; + let mut rule: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "action" => { + if v.is_null() { + continue; + } + action = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + if v.is_null() { + continue; + } + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule" => { + if v.is_null() { + continue; + } + rule = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchInboxRulesParametersDataAttributes { + action, + enabled, + name, + rule, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchInboxRulesParametersDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_mute_rule_parameters.rs b/src/datadogV2/model/model_patch_mute_rule_parameters.rs new file mode 100644 index 000000000..c06fb2d16 --- /dev/null +++ b/src/datadogV2/model/model_patch_mute_rule_parameters.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Body of the mute rule patch request +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchMuteRuleParameters { + /// Data of the mute rule patch request: the rule UUID, the rule type, and the rule attributes. All fields are required. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchMuteRuleParameters { + pub fn new() -> PatchMuteRuleParameters { + PatchMuteRuleParameters { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::PatchMuteRuleParametersData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchMuteRuleParameters { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchMuteRuleParameters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchMuteRuleParametersVisitor; + impl<'a> Visitor<'a> for PatchMuteRuleParametersVisitor { + type Value = PatchMuteRuleParameters; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchMuteRuleParameters { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchMuteRuleParametersVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_mute_rule_parameters_data.rs b/src/datadogV2/model/model_patch_mute_rule_parameters_data.rs new file mode 100644 index 000000000..0bb8a63e5 --- /dev/null +++ b/src/datadogV2/model/model_patch_mute_rule_parameters_data.rs @@ -0,0 +1,128 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data of the mute rule patch request: the rule UUID, the rule type, and the rule attributes. All fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchMuteRuleParametersData { + /// Attributes of the mute rule patch request: the rule name, the rule details, the associated action, and the enabled field. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::PatchMuteRuleParametersDataAttributes, + /// The ID of a pipeline rule + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The pipeline rule type associated to mute rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::MuteRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchMuteRuleParametersData { + pub fn new( + attributes: crate::datadogV2::model::PatchMuteRuleParametersDataAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::MuteRulesType, + ) -> PatchMuteRuleParametersData { + PatchMuteRuleParametersData { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchMuteRuleParametersData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchMuteRuleParametersDataVisitor; + impl<'a> Visitor<'a> for PatchMuteRuleParametersDataVisitor { + type Value = PatchMuteRuleParametersData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::PatchMuteRuleParametersDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::MuteRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PatchMuteRuleParametersData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchMuteRuleParametersDataVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_mute_rule_parameters_data_attributes.rs b/src/datadogV2/model/model_patch_mute_rule_parameters_data_attributes.rs new file mode 100644 index 000000000..9423b0e62 --- /dev/null +++ b/src/datadogV2/model/model_patch_mute_rule_parameters_data_attributes.rs @@ -0,0 +1,159 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the mute rule patch request: the rule name, the rule details, the associated action, and the enabled field. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchMuteRuleParametersDataAttributes { + /// Action of the mute rule + #[serde(rename = "action")] + pub action: Option, + /// Field used to enable or disable the rule. + #[serde(rename = "enabled")] + pub enabled: Option, + /// Name of the pipeline rule + #[serde(rename = "name")] + pub name: Option, + /// The definition of an automation pipeline rule scope. + /// A rule can act on specific issue types, security rule types, security rule IDs, rule severities, or a query. + /// The query can be used to filter resources on tags and attributes. + /// The issue type and rule types fields are required. + #[serde(rename = "rule")] + pub rule: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchMuteRuleParametersDataAttributes { + pub fn new() -> PatchMuteRuleParametersDataAttributes { + PatchMuteRuleParametersDataAttributes { + action: None, + enabled: None, + name: None, + rule: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn action(mut self, value: crate::datadogV2::model::ActionMute) -> Self { + self.action = Some(value); + self + } + + pub fn enabled(mut self, value: bool) -> Self { + self.enabled = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn rule(mut self, value: crate::datadogV2::model::AutomationRule) -> Self { + self.rule = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchMuteRuleParametersDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchMuteRuleParametersDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchMuteRuleParametersDataAttributesVisitor; + impl<'a> Visitor<'a> for PatchMuteRuleParametersDataAttributesVisitor { + type Value = PatchMuteRuleParametersDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut action: Option = None; + let mut enabled: Option = None; + let mut name: Option = None; + let mut rule: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "action" => { + if v.is_null() { + continue; + } + action = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + if v.is_null() { + continue; + } + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rule" => { + if v.is_null() { + continue; + } + rule = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchMuteRuleParametersDataAttributes { + action, + enabled, + name, + rule, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchMuteRuleParametersDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_reorder_inbox_rules_parameters.rs b/src/datadogV2/model/model_reorder_inbox_rules_parameters.rs new file mode 100644 index 000000000..e868f5eaa --- /dev/null +++ b/src/datadogV2/model/model_reorder_inbox_rules_parameters.rs @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Body of the inbox rule reorder request: the full list of inbox rules, which must be provided in the new order. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ReorderInboxRulesParameters { + /// The `ReorderInboxRulesParameters` `data`. + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ReorderInboxRulesParameters { + pub fn new() -> ReorderInboxRulesParameters { + ReorderInboxRulesParameters { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: Vec, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ReorderInboxRulesParameters { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ReorderInboxRulesParameters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ReorderInboxRulesParametersVisitor; + impl<'a> Visitor<'a> for ReorderInboxRulesParametersVisitor { + type Value = ReorderInboxRulesParameters; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ReorderInboxRulesParameters { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ReorderInboxRulesParametersVisitor) + } +} diff --git a/src/datadogV2/model/model_reorder_inbox_rules_parameters_data.rs b/src/datadogV2/model/model_reorder_inbox_rules_parameters_data.rs new file mode 100644 index 000000000..46433c408 --- /dev/null +++ b/src/datadogV2/model/model_reorder_inbox_rules_parameters_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data of the inbox rule reorder request: the rule UUID, the rule type, and the rule attributes. All fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ReorderInboxRulesParametersData { + /// The ID of a pipeline rule + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The pipeline rule type associated to inbox rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::InboxRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ReorderInboxRulesParametersData { + pub fn new( + id: uuid::Uuid, + type_: crate::datadogV2::model::InboxRulesType, + ) -> ReorderInboxRulesParametersData { + ReorderInboxRulesParametersData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ReorderInboxRulesParametersData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ReorderInboxRulesParametersDataVisitor; + impl<'a> Visitor<'a> for ReorderInboxRulesParametersDataVisitor { + type Value = ReorderInboxRulesParametersData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::InboxRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ReorderInboxRulesParametersData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ReorderInboxRulesParametersDataVisitor) + } +} diff --git a/src/datadogV2/model/model_reorder_mute_rules_parameters.rs b/src/datadogV2/model/model_reorder_mute_rules_parameters.rs new file mode 100644 index 000000000..7a815bb00 --- /dev/null +++ b/src/datadogV2/model/model_reorder_mute_rules_parameters.rs @@ -0,0 +1,109 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Body of the mute rule reorder request: the full list of mute rules, which must be provided in the new order. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ReorderMuteRulesParameters { + /// The `ReorderMuteRulesParameters` `data`. + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ReorderMuteRulesParameters { + pub fn new() -> ReorderMuteRulesParameters { + ReorderMuteRulesParameters { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: Vec, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ReorderMuteRulesParameters { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ReorderMuteRulesParameters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ReorderMuteRulesParametersVisitor; + impl<'a> Visitor<'a> for ReorderMuteRulesParametersVisitor { + type Value = ReorderMuteRulesParameters; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ReorderMuteRulesParameters { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ReorderMuteRulesParametersVisitor) + } +} diff --git a/src/datadogV2/model/model_reorder_mute_rules_parameters_data.rs b/src/datadogV2/model/model_reorder_mute_rules_parameters_data.rs new file mode 100644 index 000000000..ace385aa6 --- /dev/null +++ b/src/datadogV2/model/model_reorder_mute_rules_parameters_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data of the mute rule reorder request: a rule UUID and its type. All fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ReorderMuteRulesParametersData { + /// The ID of a pipeline rule + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The pipeline rule type associated to mute rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::MuteRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ReorderMuteRulesParametersData { + pub fn new( + id: uuid::Uuid, + type_: crate::datadogV2::model::MuteRulesType, + ) -> ReorderMuteRulesParametersData { + ReorderMuteRulesParametersData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ReorderMuteRulesParametersData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ReorderMuteRulesParametersDataVisitor; + impl<'a> Visitor<'a> for ReorderMuteRulesParametersDataVisitor { + type Value = ReorderMuteRulesParametersData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::MuteRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ReorderMuteRulesParametersData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ReorderMuteRulesParametersDataVisitor) + } +} diff --git a/src/datadogV2/model/model_security_rule_severity.rs b/src/datadogV2/model/model_security_rule_severity.rs new file mode 100644 index 000000000..71d9024f2 --- /dev/null +++ b/src/datadogV2/model/model_security_rule_severity.rs @@ -0,0 +1,63 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum SecurityRuleSeverity { + CRITICAL, + HIGH, + MEDIUM, + LOW, + UNKNOWN, + INFO, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SecurityRuleSeverity { + fn to_string(&self) -> String { + match self { + Self::CRITICAL => String::from("critical"), + Self::HIGH => String::from("high"), + Self::MEDIUM => String::from("medium"), + Self::LOW => String::from("low"), + Self::UNKNOWN => String::from("unknown"), + Self::INFO => String::from("info"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SecurityRuleSeverity { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for SecurityRuleSeverity { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "critical" => Self::CRITICAL, + "high" => Self::HIGH, + "medium" => Self::MEDIUM, + "low" => Self::LOW, + "unknown" => Self::UNKNOWN, + "info" => Self::INFO, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_security_rule_types_items.rs b/src/datadogV2/model/model_security_rule_types_items.rs new file mode 100644 index 000000000..0a215380f --- /dev/null +++ b/src/datadogV2/model/model_security_rule_types_items.rs @@ -0,0 +1,71 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum SecurityRuleTypesItems { + APPLICATION_CODE_VULNERABILITY, + APPLICATION_LIBRARY_VULNERABILITY, + ATTACK_PATH, + CONTAINER_IMAGE_VULNERABILITY, + HOST_VULNERABILITY, + IDENTITY_RISK, + MISCONFIGURATION, + API_SECURITY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for SecurityRuleTypesItems { + fn to_string(&self) -> String { + match self { + Self::APPLICATION_CODE_VULNERABILITY => String::from("application_code_vulnerability"), + Self::APPLICATION_LIBRARY_VULNERABILITY => { + String::from("application_library_vulnerability") + } + Self::ATTACK_PATH => String::from("attack_path"), + Self::CONTAINER_IMAGE_VULNERABILITY => String::from("container_image_vulnerability"), + Self::HOST_VULNERABILITY => String::from("host_vulnerability"), + Self::IDENTITY_RISK => String::from("identity_risk"), + Self::MISCONFIGURATION => String::from("misconfiguration"), + Self::API_SECURITY => String::from("api_security"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for SecurityRuleTypesItems { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for SecurityRuleTypesItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "application_code_vulnerability" => Self::APPLICATION_CODE_VULNERABILITY, + "application_library_vulnerability" => Self::APPLICATION_LIBRARY_VULNERABILITY, + "attack_path" => Self::ATTACK_PATH, + "container_image_vulnerability" => Self::CONTAINER_IMAGE_VULNERABILITY, + "host_vulnerability" => Self::HOST_VULNERABILITY, + "identity_risk" => Self::IDENTITY_RISK, + "misconfiguration" => Self::MISCONFIGURATION, + "api_security" => Self::API_SECURITY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_update_inbox_rule_parameters.rs b/src/datadogV2/model/model_update_inbox_rule_parameters.rs new file mode 100644 index 000000000..816091ef9 --- /dev/null +++ b/src/datadogV2/model/model_update_inbox_rule_parameters.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Body of the inbox rule update request +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateInboxRuleParameters { + /// Data of the inbox rule update request: the rule id, the rule type, and the rule attributes. All fields are required. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateInboxRuleParameters { + pub fn new() -> UpdateInboxRuleParameters { + UpdateInboxRuleParameters { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::UpdateInboxRuleParametersData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for UpdateInboxRuleParameters { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for UpdateInboxRuleParameters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateInboxRuleParametersVisitor; + impl<'a> Visitor<'a> for UpdateInboxRuleParametersVisitor { + type Value = UpdateInboxRuleParameters; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = UpdateInboxRuleParameters { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateInboxRuleParametersVisitor) + } +} diff --git a/src/datadogV2/model/model_update_inbox_rule_parameters_data.rs b/src/datadogV2/model/model_update_inbox_rule_parameters_data.rs new file mode 100644 index 000000000..a83591781 --- /dev/null +++ b/src/datadogV2/model/model_update_inbox_rule_parameters_data.rs @@ -0,0 +1,128 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data of the inbox rule update request: the rule id, the rule type, and the rule attributes. All fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateInboxRuleParametersData { + /// Attributes of the inbox rule create request: the rule name, the rule details, the associated action, and the optional enabled field. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::CreateInboxRuleParametersDataAttributes, + /// The ID of a pipeline rule + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The pipeline rule type associated to inbox rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::InboxRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateInboxRuleParametersData { + pub fn new( + attributes: crate::datadogV2::model::CreateInboxRuleParametersDataAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::InboxRulesType, + ) -> UpdateInboxRuleParametersData { + UpdateInboxRuleParametersData { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for UpdateInboxRuleParametersData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateInboxRuleParametersDataVisitor; + impl<'a> Visitor<'a> for UpdateInboxRuleParametersDataVisitor { + type Value = UpdateInboxRuleParametersData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::CreateInboxRuleParametersDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::InboxRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = UpdateInboxRuleParametersData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateInboxRuleParametersDataVisitor) + } +} diff --git a/src/datadogV2/model/model_update_mute_rule_parameters.rs b/src/datadogV2/model/model_update_mute_rule_parameters.rs new file mode 100644 index 000000000..00f2793fd --- /dev/null +++ b/src/datadogV2/model/model_update_mute_rule_parameters.rs @@ -0,0 +1,105 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Body of the mute rule update request +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateMuteRuleParameters { + /// Data of the mute rule update request: the rule id, the rule type, and the rule attributes. All fields are required. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateMuteRuleParameters { + pub fn new() -> UpdateMuteRuleParameters { + UpdateMuteRuleParameters { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::UpdateMuteRuleParametersData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for UpdateMuteRuleParameters { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for UpdateMuteRuleParameters { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateMuteRuleParametersVisitor; + impl<'a> Visitor<'a> for UpdateMuteRuleParametersVisitor { + type Value = UpdateMuteRuleParameters; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = UpdateMuteRuleParameters { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateMuteRuleParametersVisitor) + } +} diff --git a/src/datadogV2/model/model_update_mute_rule_parameters_data.rs b/src/datadogV2/model/model_update_mute_rule_parameters_data.rs new file mode 100644 index 000000000..23457e6da --- /dev/null +++ b/src/datadogV2/model/model_update_mute_rule_parameters_data.rs @@ -0,0 +1,128 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data of the mute rule update request: the rule id, the rule type, and the rule attributes. All fields are required. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateMuteRuleParametersData { + /// Attributes of the mute rule create request: the rule name, the rule details, the associated action, and the optional enabled field. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::CreateMuteRuleParametersDataAttributes, + /// The ID of a pipeline rule + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The pipeline rule type associated to mute rules + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::MuteRulesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateMuteRuleParametersData { + pub fn new( + attributes: crate::datadogV2::model::CreateMuteRuleParametersDataAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::MuteRulesType, + ) -> UpdateMuteRuleParametersData { + UpdateMuteRuleParametersData { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for UpdateMuteRuleParametersData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateMuteRuleParametersDataVisitor; + impl<'a> Visitor<'a> for UpdateMuteRuleParametersDataVisitor { + type Value = UpdateMuteRuleParametersData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::CreateMuteRuleParametersDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::MuteRulesType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = UpdateMuteRuleParametersData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateMuteRuleParametersDataVisitor) + } +} diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-inbox-rule-returns-Successfully-created-the-inbox-rule-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-inbox-rule-returns-Successfully-created-the-inbox-rule-response.frozen new file mode 100644 index 000000000..fa7eeec30 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-inbox-rule-returns-Successfully-created-the-inbox-rule-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:16.327Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-inbox-rule-returns-Successfully-created-the-inbox-rule-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-inbox-rule-returns-Successfully-created-the-inbox-rule-response.json new file mode 100644 index 000000000..229f5aab7 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-inbox-rule-returns-Successfully-created-the-inbox-rule-response.json @@ -0,0 +1,63 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"e0e466a5-6a37-4311-85e3-41edcd5bf075\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"created_at\":1738076176650,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076176650,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:16 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/e0e466a5-6a37-4311-85e3-41edcd5bf075" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:16 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-mute-rule-returns-Successfully-created-the-mute-rule-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-mute-rule-returns-Successfully-created-the-mute-rule-response.frozen new file mode 100644 index 000000000..cbf80eeb3 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-mute-rule-returns-Successfully-created-the-mute-rule-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:17.189Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-mute-rule-returns-Successfully-created-the-mute-rule-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-mute-rule-returns-Successfully-created-the-mute-rule-response.json new file mode 100644 index 000000000..8ac74a314 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Create-a-new-mute-rule-returns-Successfully-created-the-mute-rule-response.json @@ -0,0 +1,63 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"expire_at\":1893452400000,\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"84f9054f-4fb3-46a9-a032-2d8d3d6d61dd\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\",\"expire_at\":1893452400000},\"created_at\":1738076177608,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076177608,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:17 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/84f9054f-4fb3-46a9-a032-2d8d3d6d61dd" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:17 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Not-Found-response.frozen new file mode 100644 index 000000000..8b357295e --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:22.778Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Not-Found-response.json new file mode 100644 index 000000000..44d044e31 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Not-Found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/00000000-0000-0000-0000-426655000000" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:22 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Rule-successfully-deleted-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Rule-successfully-deleted-response.frozen new file mode 100644 index 000000000..ace09a134 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Rule-successfully-deleted-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:23.246Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Rule-successfully-deleted-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Rule-successfully-deleted-response.json new file mode 100644 index 000000000..6c125b6c1 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Delete-a-mute-rule-returns-Rule-successfully-deleted-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"enabled\":true,\"name\":\"Test-Delete_a_mute_rule_returns_Rule_successfully_deleted_response-1738076183\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"8b2eba88-d569-457c-a257-81dca506a008\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1738076183701,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076183701,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Delete_a_mute_rule_returns_Rule_successfully_deleted_response-1738076183\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:23 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/8b2eba88-d569-457c-a257-81dca506a008" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:23 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/8b2eba88-d569-457c-a257-81dca506a008" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:23 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Not-Found-response.frozen new file mode 100644 index 000000000..d07adb545 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:33.003Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Not-Found-response.json new file mode 100644 index 000000000..9aaa156fa --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Not-Found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/00000000-0000-0000-0000-426655000000" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:33 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Rule-successfully-deleted-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Rule-successfully-deleted-response.frozen new file mode 100644 index 000000000..861cc179c --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Rule-successfully-deleted-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:33.378Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Rule-successfully-deleted-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Rule-successfully-deleted-response.json new file mode 100644 index 000000000..d45eae5dc --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Delete-an-inbox-rule-returns-Rule-successfully-deleted-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"enabled\":true,\"name\":\"Test-Delete_an_inbox_rule_returns_Rule_successfully_deleted_response-1738076193\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"c5278cb5-0b73-4259-a131-f4e39e3ce507\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076193807,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076193807,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Delete_an_inbox_rule_returns_Rule_successfully_deleted_response-1738076193\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:33 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/c5278cb5-0b73-4259-a131-f4e39e3ce507" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:33 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/c5278cb5-0b73-4259-a131-f4e39e3ce507" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:33 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Mute-rule-details-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Mute-rule-details-response.frozen new file mode 100644 index 000000000..e3487da31 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Mute-rule-details-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:44.817Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Mute-rule-details-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Mute-rule-details-response.json new file mode 100644 index 000000000..43af1dd60 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Mute-rule-details-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"enabled\":true,\"name\":\"Test-Get_details_of_a_mute_rule_returns_Mute_rule_details_response-1738076204\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"4c45a22e-76c1-4dd8-b0a4-b759c69f12b5\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1738076205227,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076205227,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_details_of_a_mute_rule_returns_Mute_rule_details_response-1738076204\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:44 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/4c45a22e-76c1-4dd8-b0a4-b759c69f12b5" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"4c45a22e-76c1-4dd8-b0a4-b759c69f12b5\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1738076205227,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076205227,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_details_of_a_mute_rule_returns_Mute_rule_details_response-1738076204\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:44 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/4c45a22e-76c1-4dd8-b0a4-b759c69f12b5" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:44 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Not-Found-response.frozen new file mode 100644 index 000000000..8960e1e18 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:46.132Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Not-Found-response.json new file mode 100644 index 000000000..ecf9db911 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-a-mute-rule-returns-Not-Found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/00000000-0000-0000-0000-426655000000" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:46 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Inbox-rule-details-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Inbox-rule-details-response.frozen new file mode 100644 index 000000000..40f13f871 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Inbox-rule-details-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:50.068Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Inbox-rule-details-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Inbox-rule-details-response.json new file mode 100644 index 000000000..4e253e3b5 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Inbox-rule-details-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"enabled\":true,\"name\":\"Test-Get_details_of_an_inbox_rule_returns_Inbox_rule_details_response-1738076210\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"0d3e2f13-ffda-4802-aec8-1c0a4936dc23\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076210476,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076210476,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_details_of_an_inbox_rule_returns_Inbox_rule_details_response-1738076210\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:50 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/0d3e2f13-ffda-4802-aec8-1c0a4936dc23" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"0d3e2f13-ffda-4802-aec8-1c0a4936dc23\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076210476,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076210476,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_details_of_an_inbox_rule_returns_Inbox_rule_details_response-1738076210\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:50 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/0d3e2f13-ffda-4802-aec8-1c0a4936dc23" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:50 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Not-Found-response.frozen new file mode 100644 index 000000000..46e326e8e --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:51.376Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Not-Found-response.json new file mode 100644 index 000000000..d874f2c08 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-details-of-an-inbox-rule-returns-Not-Found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/00000000-0000-0000-0000-426655000000" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:51 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-inbox-rules-returns-The-list-of-inbox-rules-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-inbox-rules-returns-The-list-of-inbox-rules-response.frozen new file mode 100644 index 000000000..3bd78eb9f --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-inbox-rules-returns-The-list-of-inbox-rules-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:54.480Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-inbox-rules-returns-The-list-of-inbox-rules-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-inbox-rules-returns-The-list-of-inbox-rules-response.json new file mode 100644 index 000000000..7256f99fd --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-inbox-rules-returns-The-list-of-inbox-rules-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"enabled\":true,\"name\":\"Test-Get_the_ordered_list_of_inbox_rules_returns_The_list_of_inbox_rules_response-1738076214\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"1b5ede63-c593-4408-a54c-dc8418d36a50\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076214890,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076214890,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_the_ordered_list_of_inbox_rules_returns_The_list_of_inbox_rules_response-1738076214\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:54 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":[{\"id\":\"720e23e6-3aa2-4792-9dff-df02f86676ad\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736869747695,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736869747695,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Delete_an_inbox_rule_returns_Rule_successfully_deleted_response-1736869747\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"307d8a2f-a82d-4272-9d38-6a859251d0a6\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736936332401,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736936332401,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_an_inbox_rule_returns_Bad_Request_response-1736936332\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"9e4361c5-e21b-4e59-90ae-57214151b2b2\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736936704349,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736936704349,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_an_inbox_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_r-1736936704\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"1ad42562-e1be-4ec2-a510-6923e6d708a4\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736937094878,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736937094878,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Get_details_of_an_inbox_rule_returns_Inbox_rule_details_response-1736937094\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"2ce28a6e-0975-48cc-9bff-de1a9edd94e2\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736937364153,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736937364153,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_an_inbox_rule_returns_Inbox_rule_successfully_updated_response-1736937363\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"bd638ded-e784-48c9-87bf-a3de72138f44\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"created_at\":1736938273788,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736938274279,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}},{\"id\":\"6717872d-9ac1-4570-8480-720b0f6f3193\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"created_at\":1736938776235,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736938776235,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}},{\"id\":\"1b50cdb7-5218-4989-9afc-e0d144d642e2\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736938883731,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736938883731,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Get_the_ordered_list_of_inbox_rules_returns_The_list_of_inbox_rules_response-1736938883\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"b6ea190b-0317-40ba-a7ad-844e1e89a767\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736939052699,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736939052699,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_an_inbox_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_-1736939052\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"4f18dc53-d185-44d4-846c-561ec59bbf72\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"created_at\":1736952258489,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736952258489,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}},{\"id\":\"0294b7cd-ecf4-4e30-bf00-542e53e9918b\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736952539376,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736952539376,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_an_inbox_rule_returns_Inbox_rule_successfully_patched_response-1736952538\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"5e57a84a-a64e-4551-8c70-71e164df56ea\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"created_at\":1736952677206,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736952677695,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}},{\"id\":\"8db7bc0b-0ff9-4936-8eba-32ff56c42f0d\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736953111545,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736953111545,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Delete_an_inbox_rule_returns_Rule_successfully_deleted_response-1736953111\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"754ec766-45e1-4617-92f2-2c685640cfa5\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736953380911,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736953380911,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_an_inbox_rule_returns_Inbox_rule_successfully_patched_response-1736953380\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"5e7dd814-ba12-4536-be51-b29aa3dff555\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"created_at\":1736953540702,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736953541190,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}},{\"id\":\"9a53ae69-e980-4088-b57c-260f07da4706\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736953562530,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736953562530,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_an_inbox_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_-1736953562\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"b6525132-929b-4c7a-ad7e-c51b66521219\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736955793842,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736955793842,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Get_the_ordered_list_of_inbox_rules_returns_The_list_of_inbox_rules_response-1736955793\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"f4e5ffe8-b035-4f0e-9fdb-34fc3cbe1d68\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736956113141,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736956113141,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_an_inbox_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_r-1736956112\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"fdc17395-9f98-4b1f-9643-21642074109c\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736956188814,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736956188814,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_an_inbox_rule_returns_Bad_Request_response-1736956188\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"0d0010f5-0255-46ff-94ac-ae52239d6369\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736957603847,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736957603847,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_an_inbox_rule_returns_Bad_Request_response-1736957603\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"4079ea57-aa2a-4da6-b7b9-1f186492dc6c\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1736972574272,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736972574272,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Get_the_ordered_list_of_inbox_rules_returns_The_list_of_inbox_rules_response-1736972573\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"1b5ede63-c593-4408-a54c-dc8418d36a50\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076214890,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076214890,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_the_ordered_list_of_inbox_rules_returns_The_list_of_inbox_rules_response-1738076214\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:54 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/1b5ede63-c593-4408-a54c-dc8418d36a50" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:54 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-mute-rules-returns-The-list-of-mute-rules-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-mute-rules-returns-The-list-of-mute-rules-response.frozen new file mode 100644 index 000000000..4b6e550c3 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-mute-rules-returns-The-list-of-mute-rules-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:56:56.037Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-mute-rules-returns-The-list-of-mute-rules-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-mute-rules-returns-The-list-of-mute-rules-response.json new file mode 100644 index 000000000..cd6fd3a02 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Get-the-ordered-list-of-mute-rules-returns-The-list-of-mute-rules-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"enabled\":true,\"name\":\"Test-Get_the_ordered_list_of_mute_rules_returns_The_list_of_mute_rules_response-1738076216\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"781a0ca4-a262-4390-80ae-50a5ea91c59b\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1738076216450,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076216450,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_the_ordered_list_of_mute_rules_returns_The_list_of_mute_rules_response-1738076216\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:56 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules" + }, + "response": { + "body": { + "string": "{\"data\":[{\"id\":\"4601dcaf-d7ee-40ef-9ce5-7eed3a83f69a\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736870838826,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736870838826,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Delete_a_mute_rule_returns_Rule_successfully_deleted_response-1736870838\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"a479725a-8692-42d0-bf9c-0d63ca642345\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"created_at\":1736873422906,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736873422906,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}},{\"id\":\"48589a8d-1a79-443a-8b05-11209ac9be54\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736931543287,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736931543287,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_a_mute_rule_returns_Mute_rule_successfully_patched_response-1736931542\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"cb8e7dec-f5fa-4d20-b731-21d7685e3084\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736931564718,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736931564718,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_a_mute_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_res-1736931564\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"714e8c5d-1d83-4646-968d-35586ad7ddc4\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736931593302,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736931593302,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_Mute_rule_successfully_updated_response-1736931592\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"aec50bc5-e9c0-4101-953e-0f87d5138c10\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736931614635,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736931614635,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_re-1736931614\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"9e2d8004-e866-47d3-8e47-069051522e60\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"created_at\":1736934594769,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736934594769,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}},{\"id\":\"1f0eda8c-86a3-4670-889b-4f95d47445e1\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736934778778,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736934778778,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_Mute_rule_successfully_updated_response-1736934778\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"128ceab0-9c15-4421-be66-f5131b171755\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736934800187,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736934800187,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_re-1736934799\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"cca4499a-19c3-4642-af33-2051458b9e80\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736935335347,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736935335347,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Get_details_of_a_mute_rule_returns_Mute_rule_details_response-1736935334\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"b77f1a5f-0aeb-4ed7-8451-d9d3f0eef4a0\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736935380165,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736935380165,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Get_the_ordered_list_of_mute_rules_returns_The_list_of_mute_rules_response-1736935379\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"009b952a-5ae5-45ea-bf4c-5b42cd414739\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736935847643,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736935847643,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_a_mute_rule_returns_Bad_Request_response-1736935847\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"82563439-591a-4a2f-9061-eddf0f30cc40\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736936710612,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736936710612,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_re-1736936710\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"2d2b5a1d-8bb4-440c-a95c-8e4fef7ac478\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736938961065,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736938961065,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_Mute_rule_successfully_updated_response-1736938960\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"fb6be9d0-fe60-449a-91b2-5a2647ea9b45\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736952343752,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736952343752,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Get_details_of_a_mute_rule_returns_Mute_rule_details_response-1736952343\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"8eaf899d-519f-430e-a03f-bf0001259a78\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736952429326,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736952429326,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Get_the_ordered_list_of_mute_rules_returns_The_list_of_mute_rules_response-1736952428\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"5e08217f-eca0-4502-ac23-3d6490d8cd66\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\",\"expire_at\":1893452400000},\"created_at\":1736952606711,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736952607199,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}},{\"id\":\"11ec6d30-e044-487e-b560-83e17e571001\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736952628631,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736952628631,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_re-1736952628\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"746e3593-b6ba-4fcd-b100-7d298b4c6454\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"created_at\":1736953059610,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736953059610,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}},{\"id\":\"2ef91fd4-4e8f-4f47-8745-58cff2874da7\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736953256564,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736953256564,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_a_mute_rule_returns_Bad_Request_response-1736953256\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"dfc987db-7584-4f48-9e80-f5ba91145132\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736953277997,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736953277997,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_a_mute_rule_returns_Mute_rule_successfully_patched_response-1736953277\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"1d1e9077-8c7d-44b4-9a5e-6f3f9e516ff0\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736953429788,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736953429788,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_Mute_rule_successfully_updated_response-1736953429\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"ab5208f6-88d2-4bd4-9392-a0020b9fec60\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736953491759,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736953491759,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_re-1736953491\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"3ffd9263-0460-4cd8-95ca-0f1e43624490\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736954925280,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736954925280,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Delete_a_mute_rule_returns_Rule_successfully_deleted_response-1736954924\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"690679b5-99e9-46ed-a11e-ce03915fe063\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736955128456,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736955128456,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Get_the_ordered_list_of_mute_rules_returns_The_list_of_mute_rules_response-1736955128\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"c151d2d4-5917-4d83-bb60-e82eecaf36a1\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736956108775,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736956108775,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Patch_a_mute_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_res-1736956108\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"c5c3dcfa-b30b-4db6-8fd8-60c96cb94bac\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736963169276,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736963169276,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_Bad_Request_response-1736963168\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"45d5d101-eb05-4dc2-926b-079900bb7ad6\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1736970911790,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1736970911790,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Typescript-Update_a_mute_rule_returns_Bad_Request_response-1736970911\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}},{\"id\":\"781a0ca4-a262-4390-80ae-50a5ea91c59b\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1738076216450,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076216450,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Get_the_ordered_list_of_mute_rules_returns_The_list_of_mute_rules_response-1738076216\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:56 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/781a0ca4-a262-4390-80ae-50a5ea91c59b" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:56:56 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Mute-rule-successfully-patched-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Mute-rule-successfully-patched-response.frozen new file mode 100644 index 000000000..022691fea --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Mute-rule-successfully-patched-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:02.493Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Mute-rule-successfully-patched-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Mute-rule-successfully-patched-response.json new file mode 100644 index 000000000..3ba0dc46f --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Mute-rule-successfully-patched-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"enabled\":true,\"name\":\"Test-Patch_a_mute_rule_returns_Mute_rule_successfully_patched_response-1738076222\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"d7a109ad-032f-4f25-b80c-de7fef3f7b94\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1738076222803,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076222803,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Patch_a_mute_rule_returns_Mute_rule_successfully_patched_response-1738076222\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:02 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"expire_at\":1893452400000,\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"d7a109ad-032f-4f25-b80c-de7fef3f7b94\",\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/d7a109ad-032f-4f25-b80c-de7fef3f7b94" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"d7a109ad-032f-4f25-b80c-de7fef3f7b94\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\",\"expire_at\":1893452400000},\"created_at\":1738076222803,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076223290,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:02 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/d7a109ad-032f-4f25-b80c-de7fef3f7b94" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:02 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Not-Found-response.frozen new file mode 100644 index 000000000..f3a776488 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:03.825Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Not-Found-response.json new file mode 100644 index 000000000..13fae6089 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-a-mute-rule-returns-Not-Found-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"expire_at\":1893452400000,\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"00000000-0000-0000-0000-426655000000\",\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/00000000-0000-0000-0000-426655000000" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:03 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..9ddcd4054 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:10.433Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Bad-Request-response.json new file mode 100644 index 000000000..c89b990aa --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Bad-Request-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"enabled\":true,\"name\":\"Test-Patch_an_inbox_rule_returns_Bad_Request_response-1738076230\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"7fffd998-9474-451a-b750-a306120b5fe7\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076230847,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076230847,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Patch_an_inbox_rule_returns_Bad_Request_response-1738076230\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:10 GMT" + }, + { + "request": { + "body": { + "string": "{\"invalid\":{\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"7fffd998-9474-451a-b750-a306120b5fe7\",\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/7fffd998-9474-451a-b750-a306120b5fe7" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"Error while unmarshalling JSON API request\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:10 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/7fffd998-9474-451a-b750-a306120b5fe7" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:10 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Inbox-rule-successfully-patched-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Inbox-rule-successfully-patched-response.frozen new file mode 100644 index 000000000..0b9ed6f52 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Inbox-rule-successfully-patched-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:11.757Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Inbox-rule-successfully-patched-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Inbox-rule-successfully-patched-response.json new file mode 100644 index 000000000..d5788e434 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Inbox-rule-successfully-patched-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"enabled\":true,\"name\":\"Test-Patch_an_inbox_rule_returns_Inbox_rule_successfully_patched_response-1738076231\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"b1cae592-90ba-424c-8398-1d0e2f4a4689\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076232178,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076232178,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Patch_an_inbox_rule_returns_Inbox_rule_successfully_patched_response-1738076231\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:11 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"b1cae592-90ba-424c-8398-1d0e2f4a4689\",\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/b1cae592-90ba-424c-8398-1d0e2f4a4689" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"b1cae592-90ba-424c-8398-1d0e2f4a4689\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"created_at\":1738076232178,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076232662,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:11 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/b1cae592-90ba-424c-8398-1d0e2f4a4689" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:11 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Not-Found-response.frozen new file mode 100644 index 000000000..f2582e8b2 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:13.093Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Not-Found-response.json new file mode 100644 index 000000000..f6d260e5c --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Patch-an-inbox-rule-returns-Not-Found-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"00000000-0000-0000-0000-426655000000\",\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/00000000-0000-0000-0000-426655000000" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:13 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..61e377441 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:17.105Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Bad-Request-response.json new file mode 100644 index 000000000..4d048adcd --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Bad-Request-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"enabled\":true,\"name\":\"Test-Update_a_mute_rule_returns_Bad_Request_response-1738076237\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"c3ea4deb-588b-4340-874c-6ed929273635\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1738076237517,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076237517,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_mute_rule_returns_Bad_Request_response-1738076237\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:17 GMT" + }, + { + "request": { + "body": { + "string": "{\"invalid\":{\"attributes\":{\"action\":{\"expire_at\":1893452400000,\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"c3ea4deb-588b-4340-874c-6ed929273635\",\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/c3ea4deb-588b-4340-874c-6ed929273635" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"Error while unmarshalling JSON API request\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:17 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/c3ea4deb-588b-4340-874c-6ed929273635" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:17 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Mute-rule-successfully-updated-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Mute-rule-successfully-updated-response.frozen new file mode 100644 index 000000000..6d09d070e --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Mute-rule-successfully-updated-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:18.388Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Mute-rule-successfully-updated-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Mute-rule-successfully-updated-response.json new file mode 100644 index 000000000..7627d2dc4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Mute-rule-successfully-updated-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"enabled\":true,\"name\":\"Test-Update_a_mute_rule_returns_Mute_rule_successfully_updated_response-1738076238\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"edf96f66-5f69-4d05-a027-4157260b2bb7\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1738076238794,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076238794,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_mute_rule_returns_Mute_rule_successfully_updated_response-1738076238\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:18 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"expire_at\":1893452400000,\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"edf96f66-5f69-4d05-a027-4157260b2bb7\",\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/edf96f66-5f69-4d05-a027-4157260b2bb7" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"edf96f66-5f69-4d05-a027-4157260b2bb7\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\",\"expire_at\":1893452400000},\"created_at\":1738076238794,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076239278,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:18 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/edf96f66-5f69-4d05-a027-4157260b2bb7" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:18 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Not-Found-response.frozen new file mode 100644 index 000000000..277ceb52d --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:19.708Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Not-Found-response.json new file mode 100644 index 000000000..f7a4b9077 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-Not-Found-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"expire_at\":1893452400000,\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"00000000-0000-0000-0000-426655000000\",\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/00000000-0000-0000-0000-426655000000" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:19 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.frozen new file mode 100644 index 000000000..9ee63a2d9 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:20.205Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.json new file mode 100644 index 000000000..be4da76a4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-a-mute-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"enabled\":true,\"name\":\"Test-Update_a_mute_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_re-1738076240\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"dd1f2131-9b79-4510-a18b-523bc53158bb\",\"type\":\"mute_rules\",\"attributes\":{\"action\":{\"reason\":\"duplicate\"},\"created_at\":1738076240624,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076240624,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_a_mute_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_re-1738076240\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:20 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"expire_at\":1893452400000,\"reason\":\"duplicate\",\"reason_description\":\"Muting for a while\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"00000000-0000-0000-0000-426655000000\",\"type\":\"mute_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/dd1f2131-9b79-4510-a18b-523bc53158bb" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"422\",\"title\":\"Unprocessable Entity\",\"detail\":\"Rule Ids in path and in request body differ\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 422, + "message": "Unprocessable Entity" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:20 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/mute_rules/dd1f2131-9b79-4510-a18b-523bc53158bb" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:20 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..17d150b94 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:27.999Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Bad-Request-response.json new file mode 100644 index 000000000..e26c8dce9 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Bad-Request-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"enabled\":true,\"name\":\"Test-Update_an_inbox_rule_returns_Bad_Request_response-1738076247\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"2304d942-bdea-4c7e-9899-2f5882eba53a\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076248310,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076248310,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_an_inbox_rule_returns_Bad_Request_response-1738076247\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:27 GMT" + }, + { + "request": { + "body": { + "string": "{\"invalid\":{\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"2304d942-bdea-4c7e-9899-2f5882eba53a\",\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/2304d942-bdea-4c7e-9899-2f5882eba53a" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"Error while unmarshalling JSON API request\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:27 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/2304d942-bdea-4c7e-9899-2f5882eba53a" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:27 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Inbox-rule-successfully-updated-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Inbox-rule-successfully-updated-response.frozen new file mode 100644 index 000000000..3d40712bb --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Inbox-rule-successfully-updated-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:29.306Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Inbox-rule-successfully-updated-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Inbox-rule-successfully-updated-response.json new file mode 100644 index 000000000..bae3a97e6 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Inbox-rule-successfully-updated-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"enabled\":true,\"name\":\"Test-Update_an_inbox_rule_returns_Inbox_rule_successfully_updated_response-1738076249\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"a4b6b6fd-641c-4633-b6b0-cc53fde68159\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076249602,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076249602,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_an_inbox_rule_returns_Inbox_rule_successfully_updated_response-1738076249\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:29 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"a4b6b6fd-641c-4633-b6b0-cc53fde68159\",\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/a4b6b6fd-641c-4633-b6b0-cc53fde68159" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"a4b6b6fd-641c-4633-b6b0-cc53fde68159\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"created_at\":1738076249602,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076250066,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"application_code_vulnerability\"],\"rule_ids\":[\"rule-id-1\"],\"query\":\"key:val\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:29 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/a4b6b6fd-641c-4633-b6b0-cc53fde68159" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:29 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Not-Found-response.frozen new file mode 100644 index 000000000..525ddb90f --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:30.606Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Not-Found-response.json new file mode 100644 index 000000000..680e45714 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-Not-Found-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"00000000-0000-0000-0000-426655000000\",\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/00000000-0000-0000-0000-426655000000" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:30 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.frozen b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.frozen new file mode 100644 index 000000000..74aa9ac75 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.frozen @@ -0,0 +1 @@ +2025-01-28T14:57:30.963Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.json b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.json new file mode 100644 index 000000000..551f440a0 --- /dev/null +++ b/tests/scenarios/cassettes/v2/security_monitoring/Update-an-inbox-rule-returns-The-server-cannot-process-the-request-because-it-contains-invalid-data-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"enabled\":true,\"name\":\"Test-Update_an_inbox_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_-1738076250\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"\",\"rule_ids\":[],\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"severities\":[\"critical\"]}},\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"faae7573-c106-4d14-8dbc-585e003f51c1\",\"type\":\"inbox_rules\",\"attributes\":{\"action\":{\"reason_description\":\"items to focus on\"},\"created_at\":1738076251372,\"created_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"enabled\":true,\"modified_at\":1738076251372,\"modified_by\":{\"name\":\"frog\",\"handle\":\"frog@datadoghq.com\"},\"name\":\"Test-Update_an_inbox_rule_returns_The_server_cannot_process_the_request_because_it_contains_invalid_data_-1738076250\",\"rule\":{\"issue_type\":\"vulnerability\",\"rule_types\":[\"misconfiguration\",\"attack_path\"],\"rule_ids\":[],\"query\":\"\",\"severities\":[\"critical\"]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:30 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"action\":{\"reason_description\":\"We want to focus on these items.\"},\"enabled\":true,\"name\":\"Rule 1\",\"rule\":{\"issue_type\":\"vulnerability\",\"query\":\"key:val\",\"rule_ids\":[\"rule-id-1\"],\"rule_types\":[\"application_code_vulnerability\"],\"severities\":[\"critical\"]}},\"id\":\"00000000-0000-0000-0000-426655000000\",\"type\":\"inbox_rules\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/faae7573-c106-4d14-8dbc-585e003f51c1" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"422\",\"title\":\"Unprocessable Entity\",\"detail\":\"Rule Ids in path and in request body differ\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 422, + "message": "Unprocessable Entity" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:30 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/security/vulnerabilities/pipelines/inbox_rules/faae7573-c106-4d14-8dbc-585e003f51c1" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Jan 2025 14:57:30 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 9f928a1af..3c7c1e57e 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -571,6 +571,30 @@ "tag": "Security Monitoring", "operationId": "CreateVulnerabilityNotificationRule" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"inbox_rules\",\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"rule\": {\n \"issue_type\": \"vulnerability\",\n \"rule_types\": [\"misconfiguration\", \"attack_path\"],\n \"rule_ids\": [],\n \"severities\": [\"critical\"],\n \"query\": \"\"\n },\n \"action\": {\n \"reason_description\": \"items to focus on\"\n },\n \"enabled\": true\n }\n }\n}" + } + ], + "step": "there is a valid \"valid_inbox_rule\" in the system", + "key": "valid_inbox_rule", + "tag": "Security Monitoring", + "operationId": "CreateInboxRule" + }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"mute_rules\",\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"rule\": {\n \"issue_type\": \"vulnerability\",\n \"rule_types\": [\"misconfiguration\", \"attack_path\"],\n \"rule_ids\": [],\n \"severities\": [\"critical\"],\n \"query\": \"\"\n },\n \"action\": {\n \"reason\": \"duplicate\"\n },\n \"enabled\": true\n }\n }\n}" + } + ], + "step": "there is a valid \"valid_mute_rule\" in the system", + "key": "valid_mute_rule", + "tag": "Security Monitoring", + "operationId": "CreateMuteRule" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/security_monitoring.feature b/tests/scenarios/features/v2/security_monitoring.feature index a82f2a3dc..e42eb9ca8 100644 --- a/tests/scenarios/features/v2/security_monitoring.feature +++ b/tests/scenarios/features/v2/security_monitoring.feature @@ -235,6 +235,34 @@ Feature: Security Monitoring And the response "message" is equal to "Test rule" And the response "isEnabled" is equal to true + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Create a new inbox rule returns "Bad Request" response + Given new "CreateInboxRule" request + And body with value {"data": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "type": "inbox_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Create a new inbox rule returns "Successfully created the inbox rule" response + Given new "CreateInboxRule" request + And body with value {"data": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "type": "inbox_rules"}} + When the request is sent + Then the response status is 201 Successfully created the inbox rule + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Create a new mute rule returns "Bad Request" response + Given new "CreateMuteRule" request + And body with value {"data": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "type": "mute_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Create a new mute rule returns "Successfully created the mute rule" response + Given new "CreateMuteRule" request + And body with value {"data": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "type": "mute_rules"}} + When the request is sent + Then the response status is 201 Successfully created the mute rule + @generated @skip @team:DataDog/cloud-security-posture-management Scenario: Create a new signal-based rule returns "Bad Request" response Given new "CreateSignalNotificationRule" request @@ -324,6 +352,21 @@ Feature: Security Monitoring And the response "data.attributes.rule_query" is equal to "type:log_detection source:cloudtrail" And the response "data.attributes.data_exclusion_query" is equal to "account_id:12345" + @team:DataDog/cloud-security-posture-management + Scenario: Delete a mute rule returns "Not Found" response + Given new "DeleteMuteRule" request + And request contains "mute_rule_id" parameter with value "00000000-0000-0000-0000-426655000000" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Delete a mute rule returns "Rule successfully deleted" response + Given there is a valid "valid_mute_rule" in the system + And new "DeleteMuteRule" request + And request contains "mute_rule_id" parameter from "valid_mute_rule.data.id" + When the request is sent + Then the response status is 204 Rule successfully deleted + @skip @team:DataDog/k9-cloud-security-platform Scenario: Delete a non existing rule returns "Not Found" response Given new "DeleteSecurityMonitoringRule" request @@ -445,6 +488,21 @@ Feature: Security Monitoring When the request is sent Then the response status is 204 OK + @team:DataDog/cloud-security-posture-management + Scenario: Delete an inbox rule returns "Not Found" response + Given new "DeleteInboxRule" request + And request contains "inbox_rule_id" parameter with value "00000000-0000-0000-0000-426655000000" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Delete an inbox rule returns "Rule successfully deleted" response + Given there is a valid "valid_inbox_rule" in the system + And new "DeleteInboxRule" request + And request contains "inbox_rule_id" parameter from "valid_inbox_rule.data.id" + When the request is sent + Then the response status is 204 Rule successfully deleted + @generated @skip @team:DataDog/asm-vm Scenario: Get SBOM returns "Bad request: The server cannot process the request due to invalid syntax in the request." response Given operation "GetSBOM" enabled @@ -657,6 +715,29 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @skip @team:DataDog/cloud-security-posture-management + Scenario: Get details of a mute rule returns "Bad Request" response + Given new "GetMuteRule" request + And there is a valid "valid_mute_rule" in the system + And request contains "mute_rule_id" parameter from "valid_mute_rule.data.id" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Get details of a mute rule returns "Mute rule details" response + Given new "GetMuteRule" request + And there is a valid "valid_mute_rule" in the system + And request contains "mute_rule_id" parameter from "valid_mute_rule.data.id" + When the request is sent + Then the response status is 200 Mute rule details + + @team:DataDog/cloud-security-posture-management + Scenario: Get details of a mute rule returns "Not Found" response + Given new "GetMuteRule" request + And request contains "mute_rule_id" parameter with value "00000000-0000-0000-0000-426655000000" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/cloud-security-posture-management Scenario: Get details of a signal-based rule returns "Bad Request" response Given new "GetSignalNotificationRule" request @@ -701,6 +782,29 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 Notification rule details. + @skip @team:DataDog/cloud-security-posture-management + Scenario: Get details of an inbox rule returns "Bad Request" response + Given new "GetInboxRule" request + And there is a valid "valid_inbox_rule" in the system + And request contains "inbox_rule_id" parameter from "valid_inbox_rule.data.id" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Get details of an inbox rule returns "Inbox rule details" response + Given new "GetInboxRule" request + And there is a valid "valid_inbox_rule" in the system + And request contains "inbox_rule_id" parameter from "valid_inbox_rule.data.id" + When the request is sent + Then the response status is 200 Inbox rule details + + @team:DataDog/cloud-security-posture-management + Scenario: Get details of an inbox rule returns "Not Found" response + Given new "GetInboxRule" request + And request contains "inbox_rule_id" parameter with value "00000000-0000-0000-0000-426655000000" + When the request is sent + Then the response status is 404 Not Found + @team:DataDog/cloud-security-posture-management Scenario: Get the list of signal-based rules returns "The list of notification rules." response Given there is a valid "valid_signal_notification_rule" in the system @@ -715,6 +819,20 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 The list of notification rules. + @team:DataDog/cloud-security-posture-management + Scenario: Get the ordered list of inbox rules returns "The list of inbox rules" response + Given new "GetInboxRules" request + And there is a valid "valid_inbox_rule" in the system + When the request is sent + Then the response status is 200 The list of inbox rules + + @team:DataDog/cloud-security-posture-management + Scenario: Get the ordered list of mute rules returns "The list of mute rules" response + Given new "GetMuteRules" request + And there is a valid "valid_mute_rule" in the system + When the request is sent + Then the response status is 200 The list of mute rules + @generated @skip @team:DataDog/cloud-security-posture-management Scenario: List findings returns "Bad Request: The server cannot process the request due to invalid syntax in the request." response Given operation "ListFindings" enabled @@ -889,6 +1007,41 @@ Feature: Security Monitoring When the request is sent Then the response status is 200 OK + @skip @team:DataDog/cloud-security-posture-management + Scenario: Patch a mute rule returns "Bad Request" response + Given new "PatchMuteRule" request + And there is a valid "valid_mute_rule" in the system + And request contains "mute_rule_id" parameter from "valid_mute_rule.data.id" + And body with value {"invalid": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "{{ valid_mute_rule.data.id }}", "type": "mute_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Patch a mute rule returns "Mute rule successfully patched" response + Given new "PatchMuteRule" request + And there is a valid "valid_mute_rule" in the system + And request contains "mute_rule_id" parameter from "valid_mute_rule.data.id" + And body with value {"data": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "{{ valid_mute_rule.data.id }}", "type": "mute_rules"}} + When the request is sent + Then the response status is 200 Mute rule successfully patched + + @team:DataDog/cloud-security-posture-management + Scenario: Patch a mute rule returns "Not Found" response + Given new "PatchMuteRule" request + And request contains "mute_rule_id" parameter with value "00000000-0000-0000-0000-426655000000" + And body with value {"data": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "00000000-0000-0000-0000-426655000000", "type": "mute_rules"}} + When the request is sent + Then the response status is 404 Not Found + + @skip @team:DataDog/cloud-security-posture-management + Scenario: Patch a mute rule returns "The server cannot process the request because it contains invalid data." response + Given new "PatchMuteRule" request + And there is a valid "valid_mute_rule" in the system + And request contains "mute_rule_id" parameter from "valid_mute_rule.data.id" + And body with value {"data": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "00000000-0000-0000-0000-426655000000", "type": "mute_rules"}} + When the request is sent + Then the response status is 422 The server cannot process the request because it contains invalid data. + @team:DataDog/cloud-security-posture-management Scenario: Patch a signal-based rule returns "Bad Request" response Given new "PatchSignalNotificationRule" request @@ -957,6 +1110,69 @@ Feature: Security Monitoring When the request is sent Then the response status is 422 The server cannot process the request because it contains invalid data. + @team:DataDog/cloud-security-posture-management + Scenario: Patch an inbox rule returns "Bad Request" response + Given new "PatchInboxRule" request + And there is a valid "valid_inbox_rule" in the system + And request contains "inbox_rule_id" parameter from "valid_inbox_rule.data.id" + And body with value {"invalid": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "{{ valid_inbox_rule.data.id }}", "type": "inbox_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Patch an inbox rule returns "Inbox rule successfully patched" response + Given new "PatchInboxRule" request + And there is a valid "valid_inbox_rule" in the system + And request contains "inbox_rule_id" parameter from "valid_inbox_rule.data.id" + And body with value {"data": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "{{ valid_inbox_rule.data.id }}", "type": "inbox_rules"}} + When the request is sent + Then the response status is 200 Inbox rule successfully patched + + @team:DataDog/cloud-security-posture-management + Scenario: Patch an inbox rule returns "Not Found" response + Given new "PatchInboxRule" request + And request contains "inbox_rule_id" parameter with value "00000000-0000-0000-0000-426655000000" + And body with value {"data": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "00000000-0000-0000-0000-426655000000", "type": "inbox_rules"}} + When the request is sent + Then the response status is 404 Not Found + + @skip @team:DataDog/cloud-security-posture-management + Scenario: Patch an inbox rule returns "The server cannot process the request because it contains invalid data." response + Given new "PatchInboxRule" request + And there is a valid "valid_inbox_rule" in the system + And request contains "inbox_rule_id" parameter from "valid_inbox_rule.data.id" + And body with value {"data": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "00000000-0000-0000-0000-426655000000", "type": "inbox_rules"}} + When the request is sent + Then the response status is 422 The server cannot process the request because it contains invalid data. + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Reorder the list of inbox rules in the pipeline returns "Bad Request" response + Given new "ReorderInboxRules" request + And body with value {"data": [{"id": "123e4567-e89b-12d3-a456-426655440000", "type": "inbox_rules"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Reorder the list of inbox rules in the pipeline returns "The list of inbox rules" response + Given new "ReorderInboxRules" request + And body with value {"data": [{"id": "123e4567-e89b-12d3-a456-426655440000", "type": "inbox_rules"}]} + When the request is sent + Then the response status is 200 The list of inbox rules + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Reorder the list of mute rules in the pipeline returns "Bad Request" response + Given new "ReorderMuteRules" request + And body with value {"data": [{"id": "123e4567-e89b-12d3-a456-426655440000", "type": "mute_rules"}]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-security-posture-management + Scenario: Reorder the list of mute rules in the pipeline returns "The list of mute rules" response + Given new "ReorderMuteRules" request + And body with value {"data": [{"id": "123e4567-e89b-12d3-a456-426655440000", "type": "mute_rules"}]} + When the request is sent + Then the response status is 200 The list of mute rules + @team:DataDog/k9-cloud-security-platform Scenario: Run a historical job returns "Bad Request" response Given operation "RunHistoricalJob" enabled @@ -1038,6 +1254,41 @@ Feature: Security Monitoring And the response "name" is equal to "{{ unique }}_cloud_updated" And the response "id" has the same value as "cloud_configuration_rule.id" + @team:DataDog/cloud-security-posture-management + Scenario: Update a mute rule returns "Bad Request" response + Given new "UpdateMuteRule" request + And there is a valid "valid_mute_rule" in the system + And request contains "mute_rule_id" parameter from "valid_mute_rule.data.id" + And body with value {"invalid": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "{{ valid_mute_rule.data.id }}", "type": "mute_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Update a mute rule returns "Mute rule successfully updated" response + Given new "UpdateMuteRule" request + And there is a valid "valid_mute_rule" in the system + And request contains "mute_rule_id" parameter from "valid_mute_rule.data.id" + And body with value {"data": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "{{ valid_mute_rule.data.id }}", "type": "mute_rules"}} + When the request is sent + Then the response status is 200 Mute rule successfully updated + + @team:DataDog/cloud-security-posture-management + Scenario: Update a mute rule returns "Not Found" response + Given new "UpdateMuteRule" request + And request contains "mute_rule_id" parameter with value "00000000-0000-0000-0000-426655000000" + And body with value {"data": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "00000000-0000-0000-0000-426655000000", "type": "mute_rules"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Update a mute rule returns "The server cannot process the request because it contains invalid data." response + Given new "UpdateMuteRule" request + And there is a valid "valid_mute_rule" in the system + And request contains "mute_rule_id" parameter from "valid_mute_rule.data.id" + And body with value {"data": {"attributes": {"action": {"expire_at": 1893452400000, "reason": "duplicate", "reason_description": "Muting for a while"}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "00000000-0000-0000-0000-426655000000", "type": "mute_rules"}} + When the request is sent + Then the response status is 422 The server cannot process the request because it contains invalid data. + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: Update a security filter returns "Bad Request" response Given new "UpdateSecurityFilter" request @@ -1138,6 +1389,41 @@ Feature: Security Monitoring And the response "name" is equal to "{{ unique }}-Updated" And the response "id" has the same value as "security_rule.id" + @team:DataDog/cloud-security-posture-management + Scenario: Update an inbox rule returns "Bad Request" response + Given new "UpdateInboxRule" request + And there is a valid "valid_inbox_rule" in the system + And request contains "inbox_rule_id" parameter from "valid_inbox_rule.data.id" + And body with value {"invalid": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "{{ valid_inbox_rule.data.id }}", "type": "inbox_rules"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/cloud-security-posture-management + Scenario: Update an inbox rule returns "Inbox rule successfully updated" response + Given new "UpdateInboxRule" request + And there is a valid "valid_inbox_rule" in the system + And request contains "inbox_rule_id" parameter from "valid_inbox_rule.data.id" + And body with value {"data": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "{{ valid_inbox_rule.data.id }}", "type": "inbox_rules"}} + When the request is sent + Then the response status is 200 Inbox rule successfully updated + + @team:DataDog/cloud-security-posture-management + Scenario: Update an inbox rule returns "Not Found" response + Given new "UpdateInboxRule" request + And request contains "inbox_rule_id" parameter with value "00000000-0000-0000-0000-426655000000" + And body with value {"data": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "00000000-0000-0000-0000-426655000000", "type": "inbox_rules"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/cloud-security-posture-management + Scenario: Update an inbox rule returns "The server cannot process the request because it contains invalid data." response + Given new "UpdateInboxRule" request + And there is a valid "valid_inbox_rule" in the system + And request contains "inbox_rule_id" parameter from "valid_inbox_rule.data.id" + And body with value {"data": {"attributes": {"action": {"reason_description": "We want to focus on these items."}, "enabled": true, "name": "Rule 1", "rule": {"issue_type": "vulnerability", "query": "key:val", "rule_ids": ["rule-id-1"], "rule_types": ["application_code_vulnerability"], "severities": ["critical"]}}, "id": "00000000-0000-0000-0000-426655000000", "type": "inbox_rules"}} + When the request is sent + Then the response status is 422 The server cannot process the request because it contains invalid data. + @skip-go @skip-java @skip-python @skip-ruby @skip-rust @skip-typescript @skip-validation @team:DataDog/k9-cloud-security-platform Scenario: Validate a detection rule returns "Bad Request" response Given new "ValidateSecurityMonitoringRule" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index bb8735975..778d24501 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2147,6 +2147,104 @@ "type": "idempotent" } }, + "GetInboxRules": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "CreateInboxRule": { + "tag": "Security Monitoring", + "undo": { + "operationId": "DeleteInboxRule", + "parameters": [ + { + "name": "inbox_rule_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "ReorderInboxRules": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "DeleteInboxRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "GetInboxRule": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "PatchInboxRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "UpdateInboxRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "GetMuteRules": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "CreateMuteRule": { + "tag": "Security Monitoring", + "undo": { + "operationId": "DeleteMuteRule", + "parameters": [ + { + "name": "mute_rule_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "ReorderMuteRules": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "DeleteMuteRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "GetMuteRule": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "PatchMuteRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, + "UpdateMuteRule": { + "tag": "Security Monitoring", + "undo": { + "type": "idempotent" + } + }, "ListCloudWorkloadSecurityAgentRules": { "tag": "CSM Threats", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 665257762..d8f1b65eb 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -2738,6 +2738,48 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.PatchVulnerabilityNotificationRule".into(), test_v2_patch_vulnerability_notification_rule, ); + world + .function_mappings + .insert("v2.GetInboxRules".into(), test_v2_get_inbox_rules); + world + .function_mappings + .insert("v2.CreateInboxRule".into(), test_v2_create_inbox_rule); + world + .function_mappings + .insert("v2.ReorderInboxRules".into(), test_v2_reorder_inbox_rules); + world + .function_mappings + .insert("v2.DeleteInboxRule".into(), test_v2_delete_inbox_rule); + world + .function_mappings + .insert("v2.GetInboxRule".into(), test_v2_get_inbox_rule); + world + .function_mappings + .insert("v2.PatchInboxRule".into(), test_v2_patch_inbox_rule); + world + .function_mappings + .insert("v2.UpdateInboxRule".into(), test_v2_update_inbox_rule); + world + .function_mappings + .insert("v2.GetMuteRules".into(), test_v2_get_mute_rules); + world + .function_mappings + .insert("v2.CreateMuteRule".into(), test_v2_create_mute_rule); + world + .function_mappings + .insert("v2.ReorderMuteRules".into(), test_v2_reorder_mute_rules); + world + .function_mappings + .insert("v2.DeleteMuteRule".into(), test_v2_delete_mute_rule); + world + .function_mappings + .insert("v2.GetMuteRule".into(), test_v2_get_mute_rule); + world + .function_mappings + .insert("v2.PatchMuteRule".into(), test_v2_patch_mute_rule); + world + .function_mappings + .insert("v2.UpdateMuteRule".into(), test_v2_update_mute_rule); world.function_mappings.insert( "v2.ListSecurityFilters".into(), test_v2_list_security_filters, @@ -20458,6 +20500,366 @@ fn test_v2_patch_vulnerability_notification_rule( world.response.code = response.status.as_u16(); } +fn test_v2_get_inbox_rules(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.get_inbox_rules_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_inbox_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_inbox_rule_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_reorder_inbox_rules(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.reorder_inbox_rules_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_inbox_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let inbox_rule_id = + serde_json::from_value(_parameters.get("inbox_rule_id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_inbox_rule_with_http_info(inbox_rule_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_inbox_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let inbox_rule_id = + serde_json::from_value(_parameters.get("inbox_rule_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_inbox_rule_with_http_info(inbox_rule_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_patch_inbox_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let inbox_rule_id = + serde_json::from_value(_parameters.get("inbox_rule_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.patch_inbox_rule_with_http_info(inbox_rule_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_inbox_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let inbox_rule_id = + serde_json::from_value(_parameters.get("inbox_rule_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_inbox_rule_with_http_info(inbox_rule_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_mute_rules(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.get_mute_rules_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_mute_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_mute_rule_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_reorder_mute_rules(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.reorder_mute_rules_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_mute_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let mute_rule_id = + serde_json::from_value(_parameters.get("mute_rule_id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_mute_rule_with_http_info(mute_rule_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_mute_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let mute_rule_id = + serde_json::from_value(_parameters.get("mute_rule_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_mute_rule_with_http_info(mute_rule_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_patch_mute_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let mute_rule_id = + serde_json::from_value(_parameters.get("mute_rule_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.patch_mute_rule_with_http_info(mute_rule_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_mute_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_security_monitoring + .as_ref() + .expect("api instance not found"); + let mute_rule_id = + serde_json::from_value(_parameters.get("mute_rule_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_mute_rule_with_http_info(mute_rule_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_list_security_filters(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances