diff --git a/.apigentools-info b/.apigentools-info index 0a910cb200df..13d37c4c9fe1 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.4.1.dev11", - "regenerated": "2021-07-20 10:13:11.748010", - "spec_repo_commit": "9c185b5" + "regenerated": "2021-07-21 12:33:34.038866", + "spec_repo_commit": "00e20be" }, "v2": { "apigentools_version": "1.4.1.dev11", - "regenerated": "2021-07-20 10:14:02.056296", - "spec_repo_commit": "9c185b5" + "regenerated": "2021-07-21 12:34:20.323630", + "spec_repo_commit": "00e20be" } } } \ No newline at end of file diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index e30af558e429..583331a14f72 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -207,6 +207,7 @@ docs/MetricsAndMetricTagConfigurations.md docs/MetricsAndMetricTagConfigurationsResponse.md docs/Organization.md docs/OrganizationAttributes.md +docs/OrganizationsResponse.md docs/OrganizationsType.md docs/Pagination.md docs/PartialAPIKey.md @@ -547,6 +548,7 @@ lib/datadog_api_client/v2/models/metrics_and_metric_tag_configurations.rb lib/datadog_api_client/v2/models/metrics_and_metric_tag_configurations_response.rb lib/datadog_api_client/v2/models/organization.rb lib/datadog_api_client/v2/models/organization_attributes.rb +lib/datadog_api_client/v2/models/organizations_response.rb lib/datadog_api_client/v2/models/organizations_type.rb lib/datadog_api_client/v2/models/pagination.rb lib/datadog_api_client/v2/models/partial_api_key.rb @@ -881,6 +883,7 @@ spec/models/metrics_and_metric_tag_configurations_response_spec.rb spec/models/metrics_and_metric_tag_configurations_spec.rb spec/models/organization_attributes_spec.rb spec/models/organization_spec.rb +spec/models/organizations_response_spec.rb spec/models/organizations_type_spec.rb spec/models/pagination_spec.rb spec/models/partial_api_key_attributes_spec.rb diff --git a/data/v2/openapi.yaml b/data/v2/openapi.yaml index 1f28cfac8e88..94a1ee47e720 100644 --- a/data/v2/openapi.yaml +++ b/data/v2/openapi.yaml @@ -3256,6 +3256,18 @@ components: description: URL of the site that this organization exists at. type: string type: object + OrganizationsResponse: + description: Response containing information about multiple organizations. + properties: + data: + description: Array of returned organizations. + items: + $ref: '#/components/schemas/Organization' + type: array + meta: + $ref: '#/components/schemas/ResponseMetaAttributes' + readOnly: true + type: object OrganizationsType: default: orgs description: Organizations resource type. @@ -8702,7 +8714,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/UserResponse' + $ref: '#/components/schemas/OrganizationsResponse' description: OK '403': content: diff --git a/docs/v2/OrganizationsResponse.md b/docs/v2/OrganizationsResponse.md new file mode 100644 index 000000000000..a4e3dfad11a5 --- /dev/null +++ b/docs/v2/OrganizationsResponse.md @@ -0,0 +1,20 @@ +# DatadogAPIClient::V2::OrganizationsResponse + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **data** | [**Array<Organization>**](Organization.md) | Array of returned organizations. | [optional] | +| **meta** | [**ResponseMetaAttributes**](ResponseMetaAttributes.md) | | [optional] | + +## Example + +```ruby +require 'datadog_api_client/v2' + +instance = DatadogAPIClient::V2::OrganizationsResponse.new( + data: null, + meta: null +) +``` + diff --git a/docs/v2/README.md b/docs/v2/README.md index 12c0f2aad169..3a8d10e62207 100644 --- a/docs/v2/README.md +++ b/docs/v2/README.md @@ -325,6 +325,7 @@ Class | Method | HTTP request | Description - [DatadogAPIClient::V2::MetricsAndMetricTagConfigurationsResponse](MetricsAndMetricTagConfigurationsResponse.md) - [DatadogAPIClient::V2::Organization](Organization.md) - [DatadogAPIClient::V2::OrganizationAttributes](OrganizationAttributes.md) + - [DatadogAPIClient::V2::OrganizationsResponse](OrganizationsResponse.md) - [DatadogAPIClient::V2::OrganizationsType](OrganizationsType.md) - [DatadogAPIClient::V2::Pagination](Pagination.md) - [DatadogAPIClient::V2::PartialAPIKey](PartialAPIKey.md) diff --git a/docs/v2/UsersAPI.md b/docs/v2/UsersAPI.md index 0e8eb0000106..838003fe6668 100644 --- a/docs/v2/UsersAPI.md +++ b/docs/v2/UsersAPI.md @@ -257,7 +257,7 @@ end ## list_user_organizations -> list_user_organizations(user_id) +> list_user_organizations(user_id) Get a user organization. Returns the user information and all organizations joined by this user. @@ -282,7 +282,7 @@ end This returns an Array which contains the response data, status code and headers. -> , Integer, Hash)> list_user_organizations_with_http_info(user_id) +> , Integer, Hash)> list_user_organizations_with_http_info(user_id) ```ruby begin @@ -290,7 +290,7 @@ begin data, status_code, headers = api_instance.list_user_organizations_with_http_info(user_id) p status_code # => 2xx p headers # => { ... } - p data # => + p data # => rescue DatadogAPIClient::V2::APIError => e puts "Error when calling UsersAPI->list_user_organizations_with_http_info: #{e}" end @@ -304,7 +304,7 @@ end ### Return type -[**UserResponse**](UserResponse.md) +[**OrganizationsResponse**](OrganizationsResponse.md) ### Authorization diff --git a/features/v2/users.feature b/features/v2/users.feature index c64c1d34ec71..b0051a909c39 100644 --- a/features/v2/users.feature +++ b/features/v2/users.feature @@ -59,10 +59,11 @@ Feature: Users When the request is sent Then the response status is 404 Not found - @generated @skip + @skip Scenario: Get a user organization returns "OK" response - Given new "ListUserOrganizations" request - And request contains "user_id" parameter from "" + Given there is a valid "user" in the system + And new "ListUserOrganizations" request + And request contains "user_id" parameter from "user.data.id" When the request is sent Then the response status is 200 OK diff --git a/lib/datadog_api_client/v2.rb b/lib/datadog_api_client/v2.rb index b4ffb05f9eed..d6fe922ae12a 100644 --- a/lib/datadog_api_client/v2.rb +++ b/lib/datadog_api_client/v2.rb @@ -217,6 +217,7 @@ require 'datadog_api_client/v2/models/metrics_and_metric_tag_configurations_response' require 'datadog_api_client/v2/models/organization' require 'datadog_api_client/v2/models/organization_attributes' +require 'datadog_api_client/v2/models/organizations_response' require 'datadog_api_client/v2/models/organizations_type' require 'datadog_api_client/v2/models/pagination' require 'datadog_api_client/v2/models/partial_api_key' diff --git a/lib/datadog_api_client/v2/api/users_api.rb b/lib/datadog_api_client/v2/api/users_api.rb index aa93d5752ebf..a66e5a9a2710 100644 --- a/lib/datadog_api_client/v2/api/users_api.rb +++ b/lib/datadog_api_client/v2/api/users_api.rb @@ -320,7 +320,7 @@ def get_user_with_http_info(user_id, opts = {}) # Get a user organization. Returns the user information and all organizations joined by this user. # @param user_id [String] The ID of the user. # @param [Hash] opts the optional parameters - # @return [UserResponse] + # @return [OrganizationsResponse] def list_user_organizations(user_id, opts = {}) data, _status_code, _headers = list_user_organizations_with_http_info(user_id, opts) data @@ -330,7 +330,7 @@ def list_user_organizations(user_id, opts = {}) # Get a user organization. Returns the user information and all organizations joined by this user. # @param user_id [String] The ID of the user. # @param [Hash] opts the optional parameters - # @return [Array<(UserResponse, Integer, Hash)>] UserResponse data, response status code and response headers + # @return [Array<(OrganizationsResponse, Integer, Hash)>] OrganizationsResponse data, response status code and response headers def list_user_organizations_with_http_info(user_id, opts = {}) if @api_client.config.unstable_operations.has_key?(:list_user_organizations) @@ -367,7 +367,7 @@ def list_user_organizations_with_http_info(user_id, opts = {}) post_body = opts[:debug_body] # return_type - return_type = opts[:debug_return_type] || 'UserResponse' + return_type = opts[:debug_return_type] || 'OrganizationsResponse' # auth_names auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] diff --git a/lib/datadog_api_client/v2/models/organizations_response.rb b/lib/datadog_api_client/v2/models/organizations_response.rb new file mode 100644 index 000000000000..4c31f5477081 --- /dev/null +++ b/lib/datadog_api_client/v2/models/organizations_response.rb @@ -0,0 +1,237 @@ +=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://openapi-generator.tech + + 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 information about multiple organizations. + class OrganizationsResponse + # Array of returned organizations. + attr_accessor :data + + attr_accessor :meta + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'data' => :'data', + :'meta' => :'meta' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'data' => :'Array', + :'meta' => :'ResponseMetaAttributes' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::OrganizationsResponse` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::OrganizationsResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'meta') + self.meta = attributes[:'meta'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + meta == o.meta + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [data, meta].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when :Array + # generic array, return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = DatadogAPIClient::V2.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end + +end diff --git a/spec/v2/models/organizations_response_spec.rb b/spec/v2/models/organizations_response_spec.rb new file mode 100644 index 000000000000..95d2e650a316 --- /dev/null +++ b/spec/v2/models/organizations_response_spec.rb @@ -0,0 +1,43 @@ +=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://openapi-generator.tech + + 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 'spec_helper' +require 'json' +require 'date' + +# Unit tests for DatadogAPIClient::V2::OrganizationsResponse +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe DatadogAPIClient::V2::OrganizationsResponse do + let(:instance) { DatadogAPIClient::V2::OrganizationsResponse.new } + + describe 'test an instance of OrganizationsResponse' do + it 'should create an instance of OrganizationsResponse' do + expect(instance).to be_instance_of(DatadogAPIClient::V2::OrganizationsResponse) + end + end + describe 'test attribute "data"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "meta"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end