diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index cd8210f5a292..97c4425978a0 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -36135,6 +36135,51 @@ components: required: - name type: object + LicensesListRequest: + properties: + data: + $ref: '#/components/schemas/LicensesListRequestData' + type: object + LicensesListRequestData: + properties: + attributes: + $ref: '#/components/schemas/LicensesListRequestDataAttributes' + id: + description: Unique identifier for the request + type: string + type: + $ref: '#/components/schemas/LicensesListRequestDataType' + required: + - type + type: object + LicensesListRequestDataAttributes: + properties: + licenses: + description: List of available licenses + items: + $ref: '#/components/schemas/LicensesListRequestLicense' + type: array + type: object + LicensesListRequestDataType: + default: licenserequest + enum: + - licenserequest + example: licenserequest + type: string + x-enum-varnames: + - LICENSEREQUEST + LicensesListRequestLicense: + properties: + display_name: + description: The display name of the license + type: string + identifier: + description: The SPDX identifier of the license + type: string + short_name: + description: The short name of the license + type: string + type: object Links: description: The JSON:API links related to pagination. properties: @@ -104994,6 +105039,31 @@ paths: tags: - Static Analysis x-unstable: '**Note**: This endpoint may be subject to changes.' + /api/v2/static-analysis-sca/licenses/list: + get: + description: Returns a list of all available license identifiers and display + names that can be used for filtering and categorization in SCA. + operationId: GetLicenses + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/LicensesListRequest' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - code_analysis_read + summary: Get list of available licenses + tags: + - Static Analysis + x-unstable: '**Note**: This endpoint may be subject to changes.' /api/v2/static-analysis-sca/vulnerabilities/resolve-vulnerable-symbols: post: operationId: CreateSCAResolveVulnerableSymbols diff --git a/examples/v2/static-analysis/GetLicenses.rb b/examples/v2/static-analysis/GetLicenses.rb new file mode 100644 index 000000000000..4d5cbed9f6e2 --- /dev/null +++ b/examples/v2/static-analysis/GetLicenses.rb @@ -0,0 +1,8 @@ +# Get list of available licenses returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_licenses".to_sym] = true +end +api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new +p api_instance.get_licenses() diff --git a/features/v2/static_analysis.feature b/features/v2/static_analysis.feature index 879e8dca94ff..355043bcb63f 100644 --- a/features/v2/static_analysis.feature +++ b/features/v2/static_analysis.feature @@ -124,6 +124,13 @@ Feature: Static Analysis When the request is sent Then the response status is 200 Successfully deleted + @generated @skip @team:DataDog/k9-vm-sca + Scenario: Get list of available licenses returns "OK" response + Given operation "GetLicenses" enabled + And new "GetLicenses" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-vm-ast Scenario: List Custom Rule Revisions returns "Bad request" response Given operation "ListCustomRuleRevisions" enabled diff --git a/features/v2/undo.json b/features/v2/undo.json index 3dc80275cf05..9e3f82ab6468 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -5410,6 +5410,12 @@ "type": "safe" } }, + "GetLicenses": { + "tag": "Static Analysis", + "undo": { + "type": "safe" + } + }, "CreateSCAResolveVulnerableSymbols": { "tag": "Static Analysis", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index 46d9a0926831..767d2998e90d 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -408,6 +408,7 @@ def initialize "v2.get_custom_rule": false, "v2.get_custom_rule_revision": false, "v2.get_custom_ruleset": false, + "v2.get_licenses": false, "v2.list_custom_rule_revisions": false, "v2.revert_custom_rule_revision": false, "v2.update_custom_ruleset": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 5ec964f5e563..d00a0f2cc538 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -3120,6 +3120,11 @@ def overrides "v2.leaked_key_attributes" => "LeakedKeyAttributes", "v2.leaked_key_type" => "LeakedKeyType", "v2.library" => "Library", + "v2.licenses_list_request" => "LicensesListRequest", + "v2.licenses_list_request_data" => "LicensesListRequestData", + "v2.licenses_list_request_data_attributes" => "LicensesListRequestDataAttributes", + "v2.licenses_list_request_data_type" => "LicensesListRequestDataType", + "v2.licenses_list_request_license" => "LicensesListRequestLicense", "v2.links" => "Links", "v2.list_apis_response" => "ListAPIsResponse", "v2.list_apis_response_data" => "ListAPIsResponseData", diff --git a/lib/datadog_api_client/v2/api/static_analysis_api.rb b/lib/datadog_api_client/v2/api/static_analysis_api.rb index d778dce9101d..91ff03ef0f89 100644 --- a/lib/datadog_api_client/v2/api/static_analysis_api.rb +++ b/lib/datadog_api_client/v2/api/static_analysis_api.rb @@ -699,6 +699,72 @@ def get_custom_ruleset_with_http_info(ruleset_name, opts = {}) return data, status_code, headers end + # Get list of available licenses. + # + # @see #get_licenses_with_http_info + def get_licenses(opts = {}) + data, _status_code, _headers = get_licenses_with_http_info(opts) + data + end + + # Get list of available licenses. + # + # Returns a list of all available license identifiers and display names that can be used for filtering and categorization in SCA. + # + # @param opts [Hash] the optional parameters + # @return [Array<(LicensesListRequest, Integer, Hash)>] LicensesListRequest data, response status code and response headers + def get_licenses_with_http_info(opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_licenses".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_licenses") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_licenses")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StaticAnalysisAPI.get_licenses ...' + end + # resource path + local_var_path = '/api/v2/static-analysis-sca/licenses/list' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LicensesListRequest' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_licenses, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StaticAnalysisAPI#get_licenses\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List Custom Rule Revisions. # # @see #list_custom_rule_revisions_with_http_info diff --git a/lib/datadog_api_client/v2/models/licenses_list_request.rb b/lib/datadog_api_client/v2/models/licenses_list_request.rb new file mode 100644 index 000000000000..41be9f69e7f2 --- /dev/null +++ b/lib/datadog_api_client/v2/models/licenses_list_request.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # + class LicensesListRequest + include BaseGenericModel + + # + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'LicensesListRequestData' + } + 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::LicensesListRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/licenses_list_request_data.rb b/lib/datadog_api_client/v2/models/licenses_list_request_data.rb new file mode 100644 index 000000000000..5f2115376b30 --- /dev/null +++ b/lib/datadog_api_client/v2/models/licenses_list_request_data.rb @@ -0,0 +1,143 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # + class LicensesListRequestData + include BaseGenericModel + + # + attr_accessor :attributes + + # Unique identifier for the request + attr_accessor :id + + # + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'LicensesListRequestDataAttributes', + :'id' => :'String', + :'type' => :'LicensesListRequestDataType' + } + 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::LicensesListRequestData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/licenses_list_request_data_attributes.rb b/lib/datadog_api_client/v2/models/licenses_list_request_data_attributes.rb new file mode 100644 index 000000000000..73d3031c0039 --- /dev/null +++ b/lib/datadog_api_client/v2/models/licenses_list_request_data_attributes.rb @@ -0,0 +1,107 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # + class LicensesListRequestDataAttributes + include BaseGenericModel + + # List of available licenses + attr_accessor :licenses + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'licenses' => :'licenses' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'licenses' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::LicensesListRequestDataAttributes` 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?(:'licenses') + if (value = attributes[:'licenses']).is_a?(Array) + self.licenses = value + end + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + licenses == o.licenses && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [licenses, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/licenses_list_request_data_type.rb b/lib/datadog_api_client/v2/models/licenses_list_request_data_type.rb new file mode 100644 index 000000000000..2b39a4f3db65 --- /dev/null +++ b/lib/datadog_api_client/v2/models/licenses_list_request_data_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # + class LicensesListRequestDataType + include BaseEnumModel + + LICENSEREQUEST = "licenserequest".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/licenses_list_request_license.rb b/lib/datadog_api_client/v2/models/licenses_list_request_license.rb new file mode 100644 index 000000000000..9f24366b8028 --- /dev/null +++ b/lib/datadog_api_client/v2/models/licenses_list_request_license.rb @@ -0,0 +1,125 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # + class LicensesListRequestLicense + include BaseGenericModel + + # The display name of the license + attr_accessor :display_name + + # The SPDX identifier of the license + attr_accessor :identifier + + # The short name of the license + attr_accessor :short_name + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'display_name' => :'display_name', + :'identifier' => :'identifier', + :'short_name' => :'short_name' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'display_name' => :'String', + :'identifier' => :'String', + :'short_name' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::LicensesListRequestLicense` 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?(:'display_name') + self.display_name = attributes[:'display_name'] + end + + if attributes.key?(:'identifier') + self.identifier = attributes[:'identifier'] + end + + if attributes.key?(:'short_name') + self.short_name = attributes[:'short_name'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + display_name == o.display_name && + identifier == o.identifier && + short_name == o.short_name && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [display_name, identifier, short_name, additional_properties].hash + end + end +end