diff --git a/.apigentools-info b/.apigentools-info index acce7261e96a..3121b558fce5 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-13 18:28:06.332663", - "spec_repo_commit": "3517c947" + "regenerated": "2025-01-13 22:02:25.782618", + "spec_repo_commit": "5aa96e08" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-01-13 18:28:06.347841", - "spec_repo_commit": "3517c947" + "regenerated": "2025-01-13 22:02:25.797567", + "spec_repo_commit": "5aa96e08" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 7e519f92653b..61a760d3784c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -213,6 +213,27 @@ components: required: true schema: type: string + CustomFrameworkHandle: + description: The framework handle. + in: path + name: handle + required: true + schema: + type: string + CustomFrameworkOrgID: + description: The ID of the organization. + in: path + name: org_id + required: true + schema: + type: string + CustomFrameworkVersion: + description: The framework version. + in: path + name: version + required: true + schema: + type: string EntityID: description: UUID or Entity Ref. in: path @@ -8375,6 +8396,54 @@ components: $ref: '#/components/schemas/CustomDestinationResponseDefinition' type: array type: object + CustomFrameworkMetadata: + description: Response object for an organization's custom frameworks. + properties: + created_at: + description: Framework Creation Date + format: int64 + type: integer + created_by: + description: Framework Creator + type: string + description: + description: Framework Description + type: string + handle: + description: Framework Handle + example: '' + type: string + icon_url: + description: Framework Icon URL + type: string + id: + description: Custom Framework ID + example: '' + type: string + name: + description: Framework Name + example: '' + type: string + org_id: + description: Org ID + example: 0 + format: int64 + type: integer + updated_at: + description: Framework Update Date + format: int64 + type: integer + version: + description: Framework Version + example: '' + type: string + required: + - id + - org_id + - handle + - version + - name + type: object DORADeploymentRequest: description: Request to create a DORA deployment event. properties: @@ -9015,6 +9084,12 @@ components: type: string x-enum-varnames: - APPDEFINITIONS + DeleteCustomFrameworkResponse: + description: Delete a custom framework. + properties: + data: + $ref: '#/components/schemas/CustomFrameworkMetadata' + type: object DependencyLocation: description: Static library vulnerability location. properties: @@ -40135,6 +40210,39 @@ paths: operator: OR permissions: - org_management + /api/v2/orgs/{org_id}/cloud_security_management/custom_frameworks/{handle}/{version}: + delete: + description: Delete a custom framework. + operationId: DeleteCustomFramework + parameters: + - $ref: '#/components/parameters/CustomFrameworkOrgID' + - $ref: '#/components/parameters/CustomFrameworkHandle' + - $ref: '#/components/parameters/CustomFrameworkVersion' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeleteCustomFrameworkResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + $ref: '#/components/responses/BadRequestResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_rules_read + summary: Delete a custom framework + tags: + - Security Monitoring + x-permission: + operator: OR + permissions: + - security_monitoring_rules_read /api/v2/permissions: get: description: Returns a list of all permissions, including name, description, diff --git a/examples/v2/security-monitoring/DeleteCustomFramework.rb b/examples/v2/security-monitoring/DeleteCustomFramework.rb new file mode 100644 index 000000000000..8086ff645471 --- /dev/null +++ b/examples/v2/security-monitoring/DeleteCustomFramework.rb @@ -0,0 +1,5 @@ +# Delete a custom framework returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::SecurityMonitoringAPI.new +p api_instance.delete_custom_framework("org_id", "handle", "version") diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 6cbd21d4f165..22381106c75a 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -1726,55 +1726,10 @@ "v2.UploadIdPMetadata" => { "idp_file" => "File", }, - "v2.ListRoles" => { - "page_size" => "Integer", - "page_number" => "Integer", - "sort" => "RolesSort", - "filter" => "String", - "filter_id" => "String", - }, - "v2.CreateRole" => { - "body" => "RoleCreateRequest", - }, - "v2.DeleteRole" => { - "role_id" => "String", - }, - "v2.GetRole" => { - "role_id" => "String", - }, - "v2.UpdateRole" => { - "role_id" => "String", - "body" => "RoleUpdateRequest", - }, - "v2.CloneRole" => { - "role_id" => "String", - "body" => "RoleCloneRequest", - }, - "v2.RemovePermissionFromRole" => { - "role_id" => "String", - "body" => "RelationshipToPermission", - }, - "v2.ListRolePermissions" => { - "role_id" => "String", - }, - "v2.AddPermissionToRole" => { - "role_id" => "String", - "body" => "RelationshipToPermission", - }, - "v2.RemoveUserFromRole" => { - "role_id" => "String", - "body" => "RelationshipToUser", - }, - "v2.ListRoleUsers" => { - "role_id" => "String", - "page_size" => "Integer", - "page_number" => "Integer", - "sort" => "String", - "filter" => "String", - }, - "v2.AddUserToRole" => { - "role_id" => "String", - "body" => "RelationshipToUser", + "v2.DeleteCustomFramework" => { + "org_id" => "String", + "handle" => "String", + "version" => "String", }, "v2.ListFindings" => { "page_limit" => "Integer", @@ -1964,6 +1919,56 @@ "v2.CancelHistoricalJob" => { "job_id" => "String", }, + "v2.ListRoles" => { + "page_size" => "Integer", + "page_number" => "Integer", + "sort" => "RolesSort", + "filter" => "String", + "filter_id" => "String", + }, + "v2.CreateRole" => { + "body" => "RoleCreateRequest", + }, + "v2.DeleteRole" => { + "role_id" => "String", + }, + "v2.GetRole" => { + "role_id" => "String", + }, + "v2.UpdateRole" => { + "role_id" => "String", + "body" => "RoleUpdateRequest", + }, + "v2.CloneRole" => { + "role_id" => "String", + "body" => "RoleCloneRequest", + }, + "v2.RemovePermissionFromRole" => { + "role_id" => "String", + "body" => "RelationshipToPermission", + }, + "v2.ListRolePermissions" => { + "role_id" => "String", + }, + "v2.AddPermissionToRole" => { + "role_id" => "String", + "body" => "RelationshipToPermission", + }, + "v2.RemoveUserFromRole" => { + "role_id" => "String", + "body" => "RelationshipToUser", + }, + "v2.ListRoleUsers" => { + "role_id" => "String", + "page_size" => "Integer", + "page_number" => "Integer", + "sort" => "String", + "filter" => "String", + }, + "v2.AddUserToRole" => { + "role_id" => "String", + "body" => "RelationshipToUser", + }, "v2.ListPowerpacks" => { "page_limit" => "Integer", "page_offset" => "Integer", diff --git a/features/v2/security_monitoring.feature b/features/v2/security_monitoring.feature index 362378f63492..5723aa7f6e9f 100644 --- a/features/v2/security_monitoring.feature +++ b/features/v2/security_monitoring.feature @@ -296,6 +296,24 @@ 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" + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Delete a custom framework returns "Bad Request" response + Given new "DeleteCustomFramework" request + And request contains "org_id" parameter from "REPLACE.ME" + And request contains "handle" parameter from "REPLACE.ME" + And request contains "version" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-cloud-security-platform + Scenario: Delete a custom framework returns "OK" response + Given new "DeleteCustomFramework" request + And request contains "org_id" parameter from "REPLACE.ME" + And request contains "handle" parameter from "REPLACE.ME" + And request contains "version" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/k9-cloud-security-platform Scenario: Delete a non existing rule returns "Not Found" response Given new "DeleteSecurityMonitoringRule" request diff --git a/features/v2/undo.json b/features/v2/undo.json index d6c6e9de87c6..8a7c3224efd1 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -1651,6 +1651,12 @@ "type": "idempotent" } }, + "DeleteCustomFramework": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListPermissions": { "tag": "Roles", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 87bf19619568..6ea965ae13a7 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1373,6 +1373,7 @@ def overrides "v2.custom_destination_update_request" => "CustomDestinationUpdateRequest", "v2.custom_destination_update_request_attributes" => "CustomDestinationUpdateRequestAttributes", "v2.custom_destination_update_request_definition" => "CustomDestinationUpdateRequestDefinition", + "v2.custom_framework_metadata" => "CustomFrameworkMetadata", "v2.cvss" => "CVSS", "v2.dashboard_list_add_items_request" => "DashboardListAddItemsRequest", "v2.dashboard_list_add_items_response" => "DashboardListAddItemsResponse", @@ -1398,6 +1399,7 @@ def overrides "v2.delete_apps_response" => "DeleteAppsResponse", "v2.delete_apps_response_data_items" => "DeleteAppsResponseDataItems", "v2.delete_apps_response_data_items_type" => "DeleteAppsResponseDataItemsType", + "v2.delete_custom_framework_response" => "DeleteCustomFrameworkResponse", "v2.dependency_location" => "DependencyLocation", "v2.deploy_app_response" => "DeployAppResponse", "v2.deploy_app_response_data" => "DeployAppResponseData", diff --git a/lib/datadog_api_client/v2/api/security_monitoring_api.rb b/lib/datadog_api_client/v2/api/security_monitoring_api.rb index 4751c01317bf..43383466f35d 100644 --- a/lib/datadog_api_client/v2/api/security_monitoring_api.rb +++ b/lib/datadog_api_client/v2/api/security_monitoring_api.rb @@ -505,6 +505,81 @@ def create_security_monitoring_suppression_with_http_info(body, opts = {}) return data, status_code, headers end + # Delete a custom framework. + # + # @see #delete_custom_framework_with_http_info + def delete_custom_framework(org_id, handle, version, opts = {}) + data, _status_code, _headers = delete_custom_framework_with_http_info(org_id, handle, version, opts) + data + end + + # Delete a custom framework. + # + # Delete a custom framework. + # + # @param org_id [String] The ID of the organization. + # @param handle [String] The framework handle. + # @param version [String] The framework version. + # @param opts [Hash] the optional parameters + # @return [Array<(DeleteCustomFrameworkResponse, Integer, Hash)>] DeleteCustomFrameworkResponse data, response status code and response headers + def delete_custom_framework_with_http_info(org_id, handle, version, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SecurityMonitoringAPI.delete_custom_framework ...' + end + # verify the required parameter 'org_id' is set + if @api_client.config.client_side_validation && org_id.nil? + fail ArgumentError, "Missing the required parameter 'org_id' when calling SecurityMonitoringAPI.delete_custom_framework" + end + # verify the required parameter 'handle' is set + if @api_client.config.client_side_validation && handle.nil? + fail ArgumentError, "Missing the required parameter 'handle' when calling SecurityMonitoringAPI.delete_custom_framework" + end + # verify the required parameter 'version' is set + if @api_client.config.client_side_validation && version.nil? + fail ArgumentError, "Missing the required parameter 'version' when calling SecurityMonitoringAPI.delete_custom_framework" + end + # resource path + local_var_path = '/api/v2/orgs/{org_id}/cloud_security_management/custom_frameworks/{handle}/{version}'.sub('{org_id}', CGI.escape(org_id.to_s).gsub('%2F', '/')).sub('{handle}', CGI.escape(handle.to_s).gsub('%2F', '/')).sub('{version}', CGI.escape(version.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'DeleteCustomFrameworkResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :delete_custom_framework, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: SecurityMonitoringAPI#delete_custom_framework\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete an existing job. # # @see #delete_historical_job_with_http_info diff --git a/lib/datadog_api_client/v2/models/custom_framework_metadata.rb b/lib/datadog_api_client/v2/models/custom_framework_metadata.rb new file mode 100644 index 000000000000..572b9d457bae --- /dev/null +++ b/lib/datadog_api_client/v2/models/custom_framework_metadata.rb @@ -0,0 +1,257 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response object for an organization's custom frameworks. + class CustomFrameworkMetadata + include BaseGenericModel + + # Framework Creation Date + attr_accessor :created_at + + # Framework Creator + attr_accessor :created_by + + # Framework Description + attr_accessor :description + + # Framework Handle + attr_reader :handle + + # Framework Icon URL + attr_accessor :icon_url + + # Custom Framework ID + attr_reader :id + + # Framework Name + attr_reader :name + + # Org ID + attr_reader :org_id + + # Framework Update Date + attr_accessor :updated_at + + # Framework Version + attr_reader :version + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'created_at' => :'created_at', + :'created_by' => :'created_by', + :'description' => :'description', + :'handle' => :'handle', + :'icon_url' => :'icon_url', + :'id' => :'id', + :'name' => :'name', + :'org_id' => :'org_id', + :'updated_at' => :'updated_at', + :'version' => :'version' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'created_at' => :'Integer', + :'created_by' => :'String', + :'description' => :'String', + :'handle' => :'String', + :'icon_url' => :'String', + :'id' => :'String', + :'name' => :'String', + :'org_id' => :'Integer', + :'updated_at' => :'Integer', + :'version' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::CustomFrameworkMetadata` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'created_by') + self.created_by = attributes[:'created_by'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'handle') + self.handle = attributes[:'handle'] + end + + if attributes.key?(:'icon_url') + self.icon_url = attributes[:'icon_url'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'org_id') + self.org_id = attributes[:'org_id'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'version') + self.version = attributes[:'version'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @handle.nil? + return false if @id.nil? + return false if @name.nil? + return false if @org_id.nil? + return false if @version.nil? + true + end + + # Custom attribute writer method with validation + # @param handle [Object] Object to be assigned + # @!visibility private + def handle=(handle) + if handle.nil? + fail ArgumentError, 'invalid value for "handle", handle cannot be nil.' + end + @handle = handle + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param org_id [Object] Object to be assigned + # @!visibility private + def org_id=(org_id) + if org_id.nil? + fail ArgumentError, 'invalid value for "org_id", org_id cannot be nil.' + end + @org_id = org_id + end + + # Custom attribute writer method with validation + # @param version [Object] Object to be assigned + # @!visibility private + def version=(version) + if version.nil? + fail ArgumentError, 'invalid value for "version", version cannot be nil.' + end + @version = version + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + created_at == o.created_at && + created_by == o.created_by && + description == o.description && + handle == o.handle && + icon_url == o.icon_url && + id == o.id && + name == o.name && + org_id == o.org_id && + updated_at == o.updated_at && + version == o.version && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [created_at, created_by, description, handle, icon_url, id, name, org_id, updated_at, version, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/delete_custom_framework_response.rb b/lib/datadog_api_client/v2/models/delete_custom_framework_response.rb new file mode 100644 index 000000000000..7305e8fd0ed2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/delete_custom_framework_response.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Delete a custom framework. + class DeleteCustomFrameworkResponse + include BaseGenericModel + + # Response object for an organization's custom frameworks. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'CustomFrameworkMetadata' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::DeleteCustomFrameworkResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end