diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 73163c4c177d..b4048675b28c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -71914,6 +71914,55 @@ components: $ref: "#/components/schemas/Trigger" type: array type: object + SpecAttributes: + description: Attributes of an API spec. + properties: + name: + description: The name of the spec. + example: pets-api + type: string + status: + $ref: "#/components/schemas/SpecAttributesStatus" + version: + description: The version of the spec. + example: "2.1.0" + type: string + type: object + SpecAttributesStatus: + description: The publication status of the spec. + enum: + - published + - draft + - deprecated + example: published + type: string + x-enum-varnames: + - PUBLISHED + - DRAFT + - DEPRECATED + SpecData: + description: A single API spec resource. + properties: + attributes: + $ref: "#/components/schemas/SpecAttributes" + id: + description: The unique identifier of the spec. + example: d5e5d5a0-1234-5678-9abc-def012345678 + type: string + type: + $ref: "#/components/schemas/SpecType" + required: + - type + type: object + SpecType: + default: spec + description: Type of the spec resource. + enum: + - spec + example: spec + type: string + x-enum-varnames: + - SPEC SpecVersion: description: The version of the CycloneDX specification a BOM conforms to. enum: @@ -71932,6 +71981,15 @@ components: - ONE_THREE - ONE_FOUR - ONE_FIVE + SpecsListResponse: + description: Response containing a list of specs. + properties: + data: + description: List of specs. + items: + $ref: "#/components/schemas/SpecData" + type: array + type: object SplitAPIKey: description: The definition of the `SplitAPIKey` object. properties: @@ -137984,6 +138042,43 @@ paths: cursorPath: meta.page.after limitParam: body.data.attributes.page.limit resultsPath: data + /api/v2/specs: + get: + description: Returns a list of API specs stored in the system. + operationId: ListSpecs + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + name: pets-api + status: published + version: "2.1.0" + id: d5e5d5a0-1234-5678-9abc-def012345678 + type: spec + - attributes: + name: users-api + status: draft + version: "1.0.0" + id: a1b2c3d4-5678-9abc-def0-123456789abc + type: spec + schema: + $ref: "#/components/schemas/SpecsListResponse" + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List API specs + tags: + - Specs /api/v2/static-analysis-sca/dependencies: post: operationId: CreateSCAResult @@ -148377,6 +148472,9 @@ tags: description: Find out more at url: https://docs.datadoghq.com/tracing/metrics/metrics_namespace/ name: Spans Metrics + - description: |- + View API specs stored in the system. + name: Specs - description: API for static analysis name: Static Analysis - description: Manage your status pages and communicate service disruptions to stakeholders via Datadog's API. See the [Status Pages documentation](https://docs.datadoghq.com/incident_response/status_pages/) for more information. diff --git a/examples/v2/specs/ListSpecs.rb b/examples/v2/specs/ListSpecs.rb new file mode 100644 index 000000000000..4a34f6f28cd7 --- /dev/null +++ b/examples/v2/specs/ListSpecs.rb @@ -0,0 +1,5 @@ +# List API specs returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::SpecsAPI.new +p api_instance.list_specs() diff --git a/features/v2/specs.feature b/features/v2/specs.feature new file mode 100644 index 000000000000..830e1d6f6cf8 --- /dev/null +++ b/features/v2/specs.feature @@ -0,0 +1,12 @@ +@endpoint(specs) @endpoint(specs-v2) +Feature: Specs + View API specs stored in the system. + + @generated @skip @team:DataDog/web-frameworks-test + Scenario: List API specs returns "OK" response + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "Specs" API + And new "ListSpecs" request + When the request is sent + Then the response status is 200 OK diff --git a/features/v2/undo.json b/features/v2/undo.json index dc1a8b2fbbde..1a41e1001be9 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -6252,6 +6252,12 @@ "type": "safe" } }, + "ListSpecs": { + "tag": "Specs", + "undo": { + "type": "safe" + } + }, "CreateSCAResult": { "tag": "Static Analysis", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 9f5558e0d1ac..228c66d10dfc 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -5622,6 +5622,11 @@ def overrides "v2.spans_type" => "SpansType", "v2.spans_warning" => "SpansWarning", "v2.spec" => "Spec", + "v2.spec_attributes" => "SpecAttributes", + "v2.spec_attributes_status" => "SpecAttributesStatus", + "v2.spec_data" => "SpecData", + "v2.specs_list_response" => "SpecsListResponse", + "v2.spec_type" => "SpecType", "v2.spec_version" => "SpecVersion", "v2.split_api_key" => "SplitAPIKey", "v2.split_api_key_type" => "SplitAPIKeyType", @@ -6548,6 +6553,7 @@ def overrides "v2.spa_api" => "SpaAPI", "v2.spans_api" => "SpansAPI", "v2.spans_metrics_api" => "SpansMetricsAPI", + "v2.specs_api" => "SpecsAPI", "v2.static_analysis_api" => "StaticAnalysisAPI", "v2.status_pages_api" => "StatusPagesAPI", "v2.storage_management_api" => "StorageManagementAPI", diff --git a/lib/datadog_api_client/v2/api/specs_api.rb b/lib/datadog_api_client/v2/api/specs_api.rb new file mode 100644 index 000000000000..df42ef3927f3 --- /dev/null +++ b/lib/datadog_api_client/v2/api/specs_api.rb @@ -0,0 +1,86 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'cgi' + +module DatadogAPIClient::V2 + class SpecsAPI + attr_accessor :api_client + + def initialize(api_client = DatadogAPIClient::APIClient.default) + @api_client = api_client + end + + # List API specs. + # + # @see #list_specs_with_http_info + def list_specs(opts = {}) + data, _status_code, _headers = list_specs_with_http_info(opts) + data + end + + # List API specs. + # + # Returns a list of API specs stored in the system. + # + # @param opts [Hash] the optional parameters + # @return [Array<(SpecsListResponse, Integer, Hash)>] SpecsListResponse data, response status code and response headers + def list_specs_with_http_info(opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: SpecsAPI.list_specs ...' + end + # resource path + local_var_path = '/api/v2/specs' + + # 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] || 'SpecsListResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :list_specs, + :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: SpecsAPI#list_specs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/datadog_api_client/v2/models/spec_attributes.rb b/lib/datadog_api_client/v2/models/spec_attributes.rb new file mode 100644 index 000000000000..eff84e260aea --- /dev/null +++ b/lib/datadog_api_client/v2/models/spec_attributes.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 + # Attributes of an API spec. + class SpecAttributes + include BaseGenericModel + + # The name of the spec. + attr_accessor :name + + # The publication status of the spec. + attr_accessor :status + + # The version of the spec. + attr_accessor :version + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'status' => :'status', + :'version' => :'version' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'status' => :'SpecAttributesStatus', + :'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::SpecAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'version') + self.version = attributes[:'version'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + status == o.status && + version == o.version && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, status, version, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/spec_attributes_status.rb b/lib/datadog_api_client/v2/models/spec_attributes_status.rb new file mode 100644 index 000000000000..55719b21b3be --- /dev/null +++ b/lib/datadog_api_client/v2/models/spec_attributes_status.rb @@ -0,0 +1,28 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The publication status of the spec. + class SpecAttributesStatus + include BaseEnumModel + + PUBLISHED = "published".freeze + DRAFT = "draft".freeze + DEPRECATED = "deprecated".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/spec_data.rb b/lib/datadog_api_client/v2/models/spec_data.rb new file mode 100644 index 000000000000..e61ecc26aa6f --- /dev/null +++ b/lib/datadog_api_client/v2/models/spec_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 + # A single API spec resource. + class SpecData + include BaseGenericModel + + # Attributes of an API spec. + attr_accessor :attributes + + # The unique identifier of the spec. + attr_accessor :id + + # Type of the spec resource. + 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' => :'SpecAttributes', + :'id' => :'String', + :'type' => :'SpecType' + } + 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::SpecData` 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/spec_type.rb b/lib/datadog_api_client/v2/models/spec_type.rb new file mode 100644 index 000000000000..f4829ada2235 --- /dev/null +++ b/lib/datadog_api_client/v2/models/spec_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 + # Type of the spec resource. + class SpecType + include BaseEnumModel + + SPEC = "spec".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/specs_list_response.rb b/lib/datadog_api_client/v2/models/specs_list_response.rb new file mode 100644 index 000000000000..817fa6f0dcfa --- /dev/null +++ b/lib/datadog_api_client/v2/models/specs_list_response.rb @@ -0,0 +1,107 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response containing a list of specs. + class SpecsListResponse + include BaseGenericModel + + # List of specs. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::SpecsListResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end