diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a3477e5791c5..28246fadb698 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -37347,6 +37347,75 @@ components: type: string x-enum-varnames: - INCIDENTS_GLOBAL_SETTINGS + GlobalOrg: + description: Organization information for a global organization association. + properties: + id: + description: The numeric ID of the organization. + example: 123 + format: int64 + type: integer + name: + description: The name of the organization. + example: Example Org + type: string + public_id: + description: The public identifier of the organization. + example: abcdef12345 + nullable: true + type: string + subdomain: + description: The subdomain used to access the organization, if configured. + example: example + nullable: true + type: string + uuid: + description: The UUID of the organization. + example: "13d10a96-6ff2-49be-be7b-4f56ebb13335" + format: uuid + type: string + required: + - id + - uuid + - name + type: object + GlobalOrgAttributes: + description: Attributes of an organization associated with the authenticated user. + properties: + org: + $ref: "#/components/schemas/GlobalOrg" + redirect_url: + description: The login URL used to switch into the organization, if available. + example: "https://app.datadoghq.com/account/login/password?dd_oid=13d10a96-6ff2-49be-be7b-4f56ebb13335&login_hint=user%40example.com" + nullable: true + type: string + source_region: + description: The source region of the organization. + example: us1.prod.dog + type: string + user: + $ref: "#/components/schemas/GlobalOrgUser" + required: + - user + - org + - source_region + type: object + GlobalOrgData: + description: An organization associated with the authenticated user. + properties: + attributes: + $ref: "#/components/schemas/GlobalOrgAttributes" + id: + description: A unique identifier for this user and organization association. + example: "cfab5cf9-5472-48ea-a79c-a64045f4f745-13d10a96-6ff2-49be-be7b-4f56ebb13335" + type: string + type: + $ref: "#/components/schemas/GlobalOrgType" + required: + - id + - type + - attributes + type: object GlobalOrgIdentifier: description: A unique identifier for an organization including its site. properties: @@ -37363,6 +37432,104 @@ components: - org_uuid - org_site type: object + GlobalOrgType: + description: The resource type for global user organizations. + enum: [global_user_orgs] + example: global_user_orgs + type: string + x-enum-varnames: + - GLOBAL_USER_ORGS + GlobalOrgUser: + description: User information for a global organization association. + properties: + handle: + description: The handle of the user. + example: user@example.com + type: string + id: + description: The numeric ID of the user. + example: 42 + format: int64 + type: integer + uuid: + description: The UUID of the user. + example: "cfab5cf9-5472-48ea-a79c-a64045f4f745" + format: uuid + type: string + required: + - id + - uuid + - handle + type: object + GlobalOrgsLinks: + description: Pagination links. + properties: + next: + description: Link to the next page. + example: "https://app.datadoghq.com/api/v2/global_orgs?user_handle=user@example.com&page[limit]=100&page[cursor]=next-page" + nullable: true + type: string + prev: + description: Link to the previous page. + nullable: true + type: string + self: + description: Link to the current page. + example: "https://app.datadoghq.com/api/v2/global_orgs?user_handle=user@example.com&page[limit]=100" + type: string + type: object + GlobalOrgsMeta: + description: Response metadata object. + properties: + page: + $ref: "#/components/schemas/GlobalOrgsMetaPage" + type: object + GlobalOrgsMetaPage: + description: Paging attributes. + properties: + cursor: + description: The cursor used to get the current results, if any. + example: "" + type: string + limit: + description: Number of results returned. + example: 100 + format: int32 + type: integer + next_cursor: + description: The cursor used to get the next results, if any. + example: next-page + nullable: true + type: string + prev_cursor: + description: The cursor used to get the previous results, if any. + nullable: true + type: string + type: + $ref: "#/components/schemas/GlobalOrgsMetaPageType" + type: object + GlobalOrgsMetaPageType: + description: Type of global orgs pagination. + enum: [cursor] + example: cursor + type: string + x-enum-varnames: + - CURSOR + GlobalOrgsResponse: + description: Response containing organizations across regions for the authenticated user. + properties: + data: + description: Organizations across regions for the authenticated user. + items: + $ref: "#/components/schemas/GlobalOrgData" + type: array + links: + $ref: "#/components/schemas/GlobalOrgsLinks" + meta: + $ref: "#/components/schemas/GlobalOrgsMeta" + required: + - data + type: object GlobalVariableData: description: Synthetics global variable data. Wrapper around the global variable object. properties: @@ -119736,6 +119903,93 @@ paths: permissions: - feature_flag_config_write - feature_flag_environment_config_read + /api/v2/global_orgs: + get: + description: |- + Returns organizations across regions for the authenticated user. The `user_handle` query parameter must match the authenticated user's handle. + operationId: ListGlobalOrgs + parameters: + - description: The handle of the authenticated user. + in: query + name: user_handle + required: true + schema: + example: user@example.com + type: string + - description: Maximum number of results returned. + in: query + name: page[limit] + required: false + schema: + default: 100 + format: int32 + maximum: 1000 + minimum: 1 + type: integer + - description: |- + String to query the next page of results. + This key is provided with each valid response from the API in `meta.page.next_cursor`. + in: query + name: page[cursor] + required: false + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + org: + id: 123 + name: Example Org + public_id: abcdef12345 + subdomain: example + uuid: "13d10a96-6ff2-49be-be7b-4f56ebb13335" + redirect_url: "https://app.datadoghq.com/account/login/password?dd_oid=13d10a96-6ff2-49be-be7b-4f56ebb13335&login_hint=user%40example.com" + source_region: us1.prod.dog + user: + handle: user@example.com + id: 42 + uuid: "cfab5cf9-5472-48ea-a79c-a64045f4f745" + id: "cfab5cf9-5472-48ea-a79c-a64045f4f745-13d10a96-6ff2-49be-be7b-4f56ebb13335" + type: global_user_orgs + links: + next: "https://app.datadoghq.com/api/v2/global_orgs?user_handle=user@example.com&page[limit]=100&page[cursor]=next-page" + self: "https://app.datadoghq.com/api/v2/global_orgs?user_handle=user@example.com&page[limit]=100" + meta: + page: + cursor: "" + limit: 100 + next_cursor: next-page + type: cursor + schema: + $ref: "#/components/schemas/GlobalOrgsResponse" + description: OK + "400": {$ref: "#/components/responses/BadRequestResponse"} + "401": {$ref: "#/components/responses/UnauthorizedResponse"} + "403": {$ref: "#/components/responses/ForbiddenResponse"} + "429": {$ref: "#/components/responses/TooManyRequestsResponse"} + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - user_access_read + summary: List global orgs + tags: + - Organizations + x-pagination: + cursorParam: page[cursor] + cursorPath: meta.page.next_cursor + limitParam: page[limit] + resultsPath: data + "x-permission": + operator: OR + permissions: + - user_access_read /api/v2/hamr: get: description: |- diff --git a/examples/v2/organizations/ListGlobalOrgs.rb b/examples/v2/organizations/ListGlobalOrgs.rb new file mode 100644 index 000000000000..043d2405c695 --- /dev/null +++ b/examples/v2/organizations/ListGlobalOrgs.rb @@ -0,0 +1,5 @@ +# List global orgs returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OrganizationsAPI.new +p api_instance.list_global_orgs("user@example.com") diff --git a/examples/v2/organizations/ListGlobalOrgs_465966063.rb b/examples/v2/organizations/ListGlobalOrgs_465966063.rb new file mode 100644 index 000000000000..611f7b866305 --- /dev/null +++ b/examples/v2/organizations/ListGlobalOrgs_465966063.rb @@ -0,0 +1,5 @@ +# List global orgs returns "OK" response with pagination + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OrganizationsAPI.new +api_instance.list_global_orgs_with_pagination("user@example.com") { |item| puts item } diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 920e80f058e0..b1364560c6a9 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3099,6 +3099,24 @@ "v2.UnarchiveFeatureFlag" => { "feature_flag_id" => "UUID", }, + "v2.ListGlobalOrgs" => { + "user_handle" => "String", + "page_limit" => "Integer", + "page_cursor" => "String", + }, + "v2.ListOrgs" => { + "filter_name" => "String", + }, + "v2.GetOrgConfig" => { + "org_config_name" => "String", + }, + "v2.UpdateOrgConfig" => { + "org_config_name" => "String", + "body" => "OrgConfigWriteRequest", + }, + "v2.UploadIdPMetadata" => { + "idp_file" => "File", + }, "v2.CreateHamrOrgConnection" => { "body" => "HamrOrgConnectionRequest", }, @@ -4083,19 +4101,6 @@ "v2.ResolveOnCallPage" => { "page_id" => "UUID", }, - "v2.ListOrgs" => { - "filter_name" => "String", - }, - "v2.GetOrgConfig" => { - "org_config_name" => "String", - }, - "v2.UpdateOrgConfig" => { - "org_config_name" => "String", - "body" => "OrgConfigWriteRequest", - }, - "v2.UploadIdPMetadata" => { - "idp_file" => "File", - }, "v2.ListOrgConnections" => { "sink_org_id" => "String", "source_org_id" => "String", diff --git a/features/v2/organizations.feature b/features/v2/organizations.feature index d50c9a305d59..330aeabd221f 100644 --- a/features/v2/organizations.feature +++ b/features/v2/organizations.feature @@ -41,6 +41,27 @@ Feature: Organizations When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/delegated-auth-login + Scenario: List global orgs returns "Bad Request" response + Given new "ListGlobalOrgs" request + And request contains "user_handle" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: List global orgs returns "OK" response + Given new "ListGlobalOrgs" request + And request contains "user_handle" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/delegated-auth-login @with-pagination + Scenario: List global orgs returns "OK" response with pagination + Given new "ListGlobalOrgs" request + And request contains "user_handle" parameter from "REPLACE.ME" + When the request with pagination is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/org-management Scenario: List your managed organizations returns "OK" response Given new "ListOrgs" request diff --git a/features/v2/undo.json b/features/v2/undo.json index f1a04b48a1aa..c6acd86254ae 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -2609,6 +2609,12 @@ "type": "unsafe" } }, + "ListGlobalOrgs": { + "tag": "Organizations", + "undo": { + "type": "safe" + } + }, "GetHamrOrgConnection": { "tag": "High Availability MultiRegion", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index bfa0086bf6f1..e90d2fc26c46 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -3313,7 +3313,17 @@ def overrides "v2.global_incident_settings_request" => "GlobalIncidentSettingsRequest", "v2.global_incident_settings_response" => "GlobalIncidentSettingsResponse", "v2.global_incident_settings_type" => "GlobalIncidentSettingsType", + "v2.global_org" => "GlobalOrg", + "v2.global_org_attributes" => "GlobalOrgAttributes", + "v2.global_org_data" => "GlobalOrgData", "v2.global_org_identifier" => "GlobalOrgIdentifier", + "v2.global_orgs_links" => "GlobalOrgsLinks", + "v2.global_orgs_meta" => "GlobalOrgsMeta", + "v2.global_orgs_meta_page" => "GlobalOrgsMetaPage", + "v2.global_orgs_meta_page_type" => "GlobalOrgsMetaPageType", + "v2.global_orgs_response" => "GlobalOrgsResponse", + "v2.global_org_type" => "GlobalOrgType", + "v2.global_org_user" => "GlobalOrgUser", "v2.global_variable_data" => "GlobalVariableData", "v2.global_variable_json_patch_request" => "GlobalVariableJsonPatchRequest", "v2.global_variable_json_patch_request_data" => "GlobalVariableJsonPatchRequestData", diff --git a/lib/datadog_api_client/v2/api/organizations_api.rb b/lib/datadog_api_client/v2/api/organizations_api.rb index ea537b66bfef..9944cdb92690 100644 --- a/lib/datadog_api_client/v2/api/organizations_api.rb +++ b/lib/datadog_api_client/v2/api/organizations_api.rb @@ -88,6 +88,103 @@ def get_org_config_with_http_info(org_config_name, opts = {}) return data, status_code, headers end + # List global orgs. + # + # @see #list_global_orgs_with_http_info + def list_global_orgs(user_handle, opts = {}) + data, _status_code, _headers = list_global_orgs_with_http_info(user_handle, opts) + data + end + + # List global orgs. + # + # Returns organizations across regions for the authenticated user. The `user_handle` query parameter must match the authenticated user's handle. + # + # @param user_handle [String] The handle of the authenticated user. + # @param opts [Hash] the optional parameters + # @option opts [Integer] :page_limit Maximum number of results returned. + # @option opts [String] :page_cursor String to query the next page of results. This key is provided with each valid response from the API in `meta.page.next_cursor`. + # @return [Array<(GlobalOrgsResponse, Integer, Hash)>] GlobalOrgsResponse data, response status code and response headers + def list_global_orgs_with_http_info(user_handle, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrganizationsAPI.list_global_orgs ...' + end + # verify the required parameter 'user_handle' is set + if @api_client.config.client_side_validation && user_handle.nil? + fail ArgumentError, "Missing the required parameter 'user_handle' when calling OrganizationsAPI.list_global_orgs" + end + if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] > 1000 + fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling OrganizationsAPI.list_global_orgs, must be smaller than or equal to 1000.' + end + if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling OrganizationsAPI.list_global_orgs, must be greater than or equal to 1.' + end + # resource path + local_var_path = '/api/v2/global_orgs' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'user_handle'] = user_handle + query_params[:'page[limit]'] = opts[:'page_limit'] if !opts[:'page_limit'].nil? + query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil? + + # 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] || 'GlobalOrgsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_global_orgs, + :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: OrganizationsAPI#list_global_orgs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List global orgs. + # + # Provide a paginated version of {#list_global_orgs}, returning all items. + # + # To use it you need to use a block: list_global_orgs_with_pagination { |item| p item } + # + # @yield [GlobalOrgData] Paginated items + def list_global_orgs_with_pagination(user_handle, opts = {}) + api_version = "V2" + page_size = @api_client.get_attribute_from_path(opts, "page_limit", 100) + @api_client.set_attribute_from_path(api_version, opts, "page_limit", Integer, page_size) + while true do + response = list_global_orgs(user_handle, opts) + @api_client.get_attribute_from_path(response, "data").each { |item| yield(item) } + if @api_client.get_attribute_from_path(response, "data").length == 0 + break + end + @api_client.set_attribute_from_path(api_version, opts, "page_cursor", String, @api_client.get_attribute_from_path(response, "meta.page.next_cursor")) + end + end + # List Org Configs. # # @see #list_org_configs_with_http_info diff --git a/lib/datadog_api_client/v2/models/global_org.rb b/lib/datadog_api_client/v2/models/global_org.rb new file mode 100644 index 000000000000..28c6dfcdd99d --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_org.rb @@ -0,0 +1,194 @@ +=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 + # Organization information for a global organization association. + class GlobalOrg + include BaseGenericModel + + # The numeric ID of the organization. + attr_reader :id + + # The name of the organization. + attr_reader :name + + # The public identifier of the organization. + attr_accessor :public_id + + # The subdomain used to access the organization, if configured. + attr_accessor :subdomain + + # The UUID of the organization. + attr_reader :uuid + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'public_id' => :'public_id', + :'subdomain' => :'subdomain', + :'uuid' => :'uuid' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'id' => :'Integer', + :'name' => :'String', + :'public_id' => :'String', + :'subdomain' => :'String', + :'uuid' => :'UUID' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'public_id', + :'subdomain', + ]) + 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::GlobalOrg` 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?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'public_id') + self.public_id = attributes[:'public_id'] + end + + if attributes.key?(:'subdomain') + self.subdomain = attributes[:'subdomain'] + end + + if attributes.key?(:'uuid') + self.uuid = attributes[:'uuid'] + 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 @id.nil? + return false if @name.nil? + return false if @uuid.nil? + true + 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 uuid [Object] Object to be assigned + # @!visibility private + def uuid=(uuid) + if uuid.nil? + fail ArgumentError, 'invalid value for "uuid", uuid cannot be nil.' + end + @uuid = uuid + 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 && + id == o.id && + name == o.name && + public_id == o.public_id && + subdomain == o.subdomain && + uuid == o.uuid && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [id, name, public_id, subdomain, uuid, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/global_org_attributes.rb b/lib/datadog_api_client/v2/models/global_org_attributes.rb new file mode 100644 index 000000000000..96c1a998ae81 --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_org_attributes.rb @@ -0,0 +1,183 @@ +=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 organization associated with the authenticated user. + class GlobalOrgAttributes + include BaseGenericModel + + # Organization information for a global organization association. + attr_reader :org + + # The login URL used to switch into the organization, if available. + attr_accessor :redirect_url + + # The source region of the organization. + attr_reader :source_region + + # User information for a global organization association. + attr_reader :user + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'org' => :'org', + :'redirect_url' => :'redirect_url', + :'source_region' => :'source_region', + :'user' => :'user' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'org' => :'GlobalOrg', + :'redirect_url' => :'String', + :'source_region' => :'String', + :'user' => :'GlobalOrgUser' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'redirect_url', + ]) + 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::GlobalOrgAttributes` 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?(:'org') + self.org = attributes[:'org'] + end + + if attributes.key?(:'redirect_url') + self.redirect_url = attributes[:'redirect_url'] + end + + if attributes.key?(:'source_region') + self.source_region = attributes[:'source_region'] + end + + if attributes.key?(:'user') + self.user = attributes[:'user'] + 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 @org.nil? + return false if @source_region.nil? + return false if @user.nil? + true + end + + # Custom attribute writer method with validation + # @param org [Object] Object to be assigned + # @!visibility private + def org=(org) + if org.nil? + fail ArgumentError, 'invalid value for "org", org cannot be nil.' + end + @org = org + end + + # Custom attribute writer method with validation + # @param source_region [Object] Object to be assigned + # @!visibility private + def source_region=(source_region) + if source_region.nil? + fail ArgumentError, 'invalid value for "source_region", source_region cannot be nil.' + end + @source_region = source_region + end + + # Custom attribute writer method with validation + # @param user [Object] Object to be assigned + # @!visibility private + def user=(user) + if user.nil? + fail ArgumentError, 'invalid value for "user", user cannot be nil.' + end + @user = user + 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 && + org == o.org && + redirect_url == o.redirect_url && + source_region == o.source_region && + user == o.user && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [org, redirect_url, source_region, user, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/global_org_data.rb b/lib/datadog_api_client/v2/models/global_org_data.rb new file mode 100644 index 000000000000..75a98fd81a35 --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_org_data.rb @@ -0,0 +1,165 @@ +=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 + # An organization associated with the authenticated user. + class GlobalOrgData + include BaseGenericModel + + # Attributes of an organization associated with the authenticated user. + attr_reader :attributes + + # A unique identifier for this user and organization association. + attr_reader :id + + # The resource type for global user organizations. + 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' => :'GlobalOrgAttributes', + :'id' => :'String', + :'type' => :'GlobalOrgType' + } + 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::GlobalOrgData` 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 @attributes.nil? + return false if @id.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + 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 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/global_org_type.rb b/lib/datadog_api_client/v2/models/global_org_type.rb new file mode 100644 index 000000000000..c6db59d7f362 --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_org_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 + # The resource type for global user organizations. + class GlobalOrgType + include BaseEnumModel + + GLOBAL_USER_ORGS = "global_user_orgs".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/global_org_user.rb b/lib/datadog_api_client/v2/models/global_org_user.rb new file mode 100644 index 000000000000..cab562e62940 --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_org_user.rb @@ -0,0 +1,165 @@ +=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 + # User information for a global organization association. + class GlobalOrgUser + include BaseGenericModel + + # The handle of the user. + attr_reader :handle + + # The numeric ID of the user. + attr_reader :id + + # The UUID of the user. + attr_reader :uuid + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'handle' => :'handle', + :'id' => :'id', + :'uuid' => :'uuid' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'handle' => :'String', + :'id' => :'Integer', + :'uuid' => :'UUID' + } + 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::GlobalOrgUser` 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?(:'handle') + self.handle = attributes[:'handle'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'uuid') + self.uuid = attributes[:'uuid'] + 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 @uuid.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 uuid [Object] Object to be assigned + # @!visibility private + def uuid=(uuid) + if uuid.nil? + fail ArgumentError, 'invalid value for "uuid", uuid cannot be nil.' + end + @uuid = uuid + 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 && + handle == o.handle && + id == o.id && + uuid == o.uuid && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [handle, id, uuid, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/global_orgs_links.rb b/lib/datadog_api_client/v2/models/global_orgs_links.rb new file mode 100644 index 000000000000..ec97d29998fe --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_orgs_links.rb @@ -0,0 +1,134 @@ +=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 + # Pagination links. + class GlobalOrgsLinks + include BaseGenericModel + + # Link to the next page. + attr_accessor :_next + + # Link to the previous page. + attr_accessor :prev + + # Link to the current page. + attr_accessor :_self + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'_next' => :'next', + :'prev' => :'prev', + :'_self' => :'self' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'_next' => :'String', + :'prev' => :'String', + :'_self' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'_next', + :'prev', + ]) + 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::GlobalOrgsLinks` 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?(:'_next') + self._next = attributes[:'_next'] + end + + if attributes.key?(:'prev') + self.prev = attributes[:'prev'] + end + + if attributes.key?(:'_self') + self._self = attributes[:'_self'] + 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 && + _next == o._next && + prev == o.prev && + _self == o._self && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [_next, prev, _self, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/global_orgs_meta.rb b/lib/datadog_api_client/v2/models/global_orgs_meta.rb new file mode 100644 index 000000000000..6da5567d6e30 --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_orgs_meta.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 + # Response metadata object. + class GlobalOrgsMeta + include BaseGenericModel + + # Paging attributes. + attr_accessor :page + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'page' => :'page' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'page' => :'GlobalOrgsMetaPage' + } + 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::GlobalOrgsMeta` 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?(:'page') + self.page = attributes[:'page'] + 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 && + page == o.page && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [page, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/global_orgs_meta_page.rb b/lib/datadog_api_client/v2/models/global_orgs_meta_page.rb new file mode 100644 index 000000000000..b6494bfb2f10 --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_orgs_meta_page.rb @@ -0,0 +1,154 @@ +=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 + # Paging attributes. + class GlobalOrgsMetaPage + include BaseGenericModel + + # The cursor used to get the current results, if any. + attr_accessor :cursor + + # Number of results returned. + attr_accessor :limit + + # The cursor used to get the next results, if any. + attr_accessor :next_cursor + + # The cursor used to get the previous results, if any. + attr_accessor :prev_cursor + + # Type of global orgs pagination. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'cursor' => :'cursor', + :'limit' => :'limit', + :'next_cursor' => :'next_cursor', + :'prev_cursor' => :'prev_cursor', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'cursor' => :'String', + :'limit' => :'Integer', + :'next_cursor' => :'String', + :'prev_cursor' => :'String', + :'type' => :'GlobalOrgsMetaPageType' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'next_cursor', + :'prev_cursor', + ]) + 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::GlobalOrgsMetaPage` 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?(:'cursor') + self.cursor = attributes[:'cursor'] + end + + if attributes.key?(:'limit') + self.limit = attributes[:'limit'] + end + + if attributes.key?(:'next_cursor') + self.next_cursor = attributes[:'next_cursor'] + end + + if attributes.key?(:'prev_cursor') + self.prev_cursor = attributes[:'prev_cursor'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + 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 && + cursor == o.cursor && + limit == o.limit && + next_cursor == o.next_cursor && + prev_cursor == o.prev_cursor && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [cursor, limit, next_cursor, prev_cursor, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/global_orgs_meta_page_type.rb b/lib/datadog_api_client/v2/models/global_orgs_meta_page_type.rb new file mode 100644 index 000000000000..2d2d8d8feb7a --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_orgs_meta_page_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 global orgs pagination. + class GlobalOrgsMetaPageType + include BaseEnumModel + + CURSOR = "cursor".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/global_orgs_response.rb b/lib/datadog_api_client/v2/models/global_orgs_response.rb new file mode 100644 index 000000000000..c4236c62750e --- /dev/null +++ b/lib/datadog_api_client/v2/models/global_orgs_response.rb @@ -0,0 +1,145 @@ +=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 organizations across regions for the authenticated user. + class GlobalOrgsResponse + include BaseGenericModel + + # Organizations across regions for the authenticated user. + attr_reader :data + + # Pagination links. + attr_accessor :links + + # Response metadata object. + attr_accessor :meta + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'links' => :'links', + :'meta' => :'meta' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'links' => :'GlobalOrgsLinks', + :'meta' => :'GlobalOrgsMeta' + } + 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::GlobalOrgsResponse` 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 + + if attributes.key?(:'links') + self.links = attributes[:'links'] + end + + if attributes.key?(:'meta') + self.meta = attributes[:'meta'] + 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 @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + 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 && + links == o.links && + meta == o.meta && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, links, meta, additional_properties].hash + end + end +end