diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 4bc99f94bc1d..045a30b94d7e 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1088,6 +1088,13 @@ components: required: true schema: type: string + OpsgenieAccountIDPathParameter: + description: The UUID of the Opsgenie account. + in: path + name: account_id + required: true + schema: + type: string OpsgenieServiceIDPathParameter: description: The UUID of the service. in: path @@ -61684,6 +61691,129 @@ components: format: binary type: string type: object + OpsgenieAccountCreateAttributes: + description: The Opsgenie account attributes for a create request. + properties: + api_key: + description: The Opsgenie API key for your Opsgenie account. + example: "00000000-0000-0000-0000-000000000000" + minLength: 1 + type: string + region: + $ref: "#/components/schemas/OpsgenieServiceRegionType" + required: + - api_key + - region + type: object + OpsgenieAccountCreateData: + description: Opsgenie account data for a create request. + properties: + attributes: + $ref: "#/components/schemas/OpsgenieAccountCreateAttributes" + type: + $ref: "#/components/schemas/OpsgenieAccountType" + required: + - type + - attributes + type: object + OpsgenieAccountCreateRequest: + description: Create request for an Opsgenie account. + properties: + data: + $ref: "#/components/schemas/OpsgenieAccountCreateData" + required: + - data + type: object + OpsgenieAccountResponse: + description: Response containing an Opsgenie account. + properties: + data: + $ref: "#/components/schemas/OpsgenieAccountResponseData" + required: + - data + type: object + OpsgenieAccountResponseAttributes: + description: The attributes from an Opsgenie account response. + properties: + region: + $ref: "#/components/schemas/OpsgenieServiceRegionType" + type: object + OpsgenieAccountResponseData: + description: Opsgenie account data from a response. + properties: + attributes: + $ref: "#/components/schemas/OpsgenieAccountResponseAttributes" + id: + description: The ID of the Opsgenie account. + example: "596da4af-0563-4097-90ff-07230c3f9db3" + maxLength: 100 + minLength: 1 + type: string + type: + $ref: "#/components/schemas/OpsgenieAccountType" + required: + - id + - type + - attributes + type: object + OpsgenieAccountType: + default: opsgenie-account + description: Opsgenie account resource type. + enum: + - opsgenie-account + example: opsgenie-account + type: string + x-enum-varnames: + - OPSGENIE_ACCOUNT + OpsgenieAccountUpdateAttributes: + description: The Opsgenie account attributes for an update request. + properties: + api_key: + description: The Opsgenie API key for your Opsgenie account. + example: "00000000-0000-0000-0000-000000000000" + minLength: 1 + type: string + region: + $ref: "#/components/schemas/OpsgenieServiceRegionType" + type: object + OpsgenieAccountUpdateData: + description: Opsgenie account data for an update request. + properties: + attributes: + $ref: "#/components/schemas/OpsgenieAccountUpdateAttributes" + id: + description: The ID of the Opsgenie account. + example: "596da4af-0563-4097-90ff-07230c3f9db3" + maxLength: 100 + minLength: 1 + type: string + type: + $ref: "#/components/schemas/OpsgenieAccountType" + required: + - id + - type + - attributes + type: object + OpsgenieAccountUpdateRequest: + description: Update request for an Opsgenie account. + properties: + data: + $ref: "#/components/schemas/OpsgenieAccountUpdateData" + required: + - data + type: object + OpsgenieAccountsResponse: + description: Response with a list of Opsgenie accounts. + properties: + data: + description: An array of Opsgenie accounts. + example: [{"attributes": {"region": "us"}, "id": "596da4af-0563-4097-90ff-07230c3f9db3", "type": "opsgenie-account"}, {"attributes": {"region": "eu"}, "id": "0d2937f1-b561-44fa-914a-99910f848014", "type": "opsgenie-account"}] + items: + $ref: "#/components/schemas/OpsgenieAccountResponseData" + type: array + required: + - data + type: object OpsgenieServiceCreateAttributes: description: The Opsgenie service attributes for a create request. properties: @@ -124953,6 +125083,161 @@ paths: summary: Update tenancy config tags: - OCI Integration + /api/v2/integration/opsgenie/accounts: + get: + description: Get a list of all Opsgenie accounts from the Datadog Opsgenie integration. + operationId: ListOpsgenieAccounts + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + region: us + id: 00000000-0000-0000-0000-000000000001 + type: opsgenie-account + schema: + $ref: "#/components/schemas/OpsgenieAccountsResponse" + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get all Opsgenie accounts + tags: + - Opsgenie Integration + "x-permission": + operator: OR + permissions: + - integrations_read + post: + description: Create a new Opsgenie account in the Datadog Opsgenie integration. + operationId: CreateOpsgenieAccount + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + api_key: 00000000-0000-0000-0000-000000000000 + region: us + type: opsgenie-account + schema: + $ref: "#/components/schemas/OpsgenieAccountCreateRequest" + description: Opsgenie account payload. + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + region: us + id: 00000000-0000-0000-0000-000000000002 + type: opsgenie-account + schema: + $ref: "#/components/schemas/OpsgenieAccountResponse" + description: CREATED + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Create a new Opsgenie account + tags: + - Opsgenie Integration + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - manage_integrations + /api/v2/integration/opsgenie/accounts/{account_id}: + delete: + description: Delete a single Opsgenie account from the Datadog Opsgenie integration. + operationId: DeleteOpsgenieAccount + parameters: + - $ref: "#/components/parameters/OpsgenieAccountIDPathParameter" + responses: + "204": + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete an Opsgenie account + tags: + - Opsgenie Integration + "x-permission": + operator: OR + permissions: + - manage_integrations + patch: + description: Update a single Opsgenie account in the Datadog Opsgenie integration. + operationId: UpdateOpsgenieAccount + parameters: + - $ref: "#/components/parameters/OpsgenieAccountIDPathParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + api_key: 00000000-0000-0000-0000-000000000000 + region: us + id: 596da4af-0563-4097-90ff-07230c3f9db3 + type: opsgenie-account + schema: + $ref: "#/components/schemas/OpsgenieAccountUpdateRequest" + description: Opsgenie account payload. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + region: us + id: 00000000-0000-0000-0000-000000000003 + type: opsgenie-account + schema: + $ref: "#/components/schemas/OpsgenieAccountResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "422": + $ref: "#/components/responses/UnprocessableEntityResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Update an Opsgenie account + tags: + - Opsgenie Integration + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - manage_integrations /api/v2/integration/opsgenie/services: get: description: Get a list of all services from the Datadog Opsgenie integration. diff --git a/examples/v2/opsgenie-integration/CreateOpsgenieAccount.rb b/examples/v2/opsgenie-integration/CreateOpsgenieAccount.rb new file mode 100644 index 000000000000..fdd0193d161b --- /dev/null +++ b/examples/v2/opsgenie-integration/CreateOpsgenieAccount.rb @@ -0,0 +1,15 @@ +# Create a new Opsgenie account returns "CREATED" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OpsgenieIntegrationAPI.new + +body = DatadogAPIClient::V2::OpsgenieAccountCreateRequest.new({ + data: DatadogAPIClient::V2::OpsgenieAccountCreateData.new({ + attributes: DatadogAPIClient::V2::OpsgenieAccountCreateAttributes.new({ + api_key: "00000000-0000-0000-0000-000000000000", + region: DatadogAPIClient::V2::OpsgenieServiceRegionType::US, + }), + type: DatadogAPIClient::V2::OpsgenieAccountType::OPSGENIE_ACCOUNT, + }), +}) +p api_instance.create_opsgenie_account(body) diff --git a/examples/v2/opsgenie-integration/DeleteOpsgenieAccount.rb b/examples/v2/opsgenie-integration/DeleteOpsgenieAccount.rb new file mode 100644 index 000000000000..c87ac19690af --- /dev/null +++ b/examples/v2/opsgenie-integration/DeleteOpsgenieAccount.rb @@ -0,0 +1,5 @@ +# Delete an Opsgenie account returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OpsgenieIntegrationAPI.new +api_instance.delete_opsgenie_account("account_id") diff --git a/examples/v2/opsgenie-integration/ListOpsgenieAccounts.rb b/examples/v2/opsgenie-integration/ListOpsgenieAccounts.rb new file mode 100644 index 000000000000..35e5cada8d12 --- /dev/null +++ b/examples/v2/opsgenie-integration/ListOpsgenieAccounts.rb @@ -0,0 +1,5 @@ +# Get all Opsgenie accounts returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OpsgenieIntegrationAPI.new +p api_instance.list_opsgenie_accounts() diff --git a/examples/v2/opsgenie-integration/UpdateOpsgenieAccount.rb b/examples/v2/opsgenie-integration/UpdateOpsgenieAccount.rb new file mode 100644 index 000000000000..d30e72fde9d2 --- /dev/null +++ b/examples/v2/opsgenie-integration/UpdateOpsgenieAccount.rb @@ -0,0 +1,16 @@ +# Update an Opsgenie account returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::OpsgenieIntegrationAPI.new + +body = DatadogAPIClient::V2::OpsgenieAccountUpdateRequest.new({ + data: DatadogAPIClient::V2::OpsgenieAccountUpdateData.new({ + attributes: DatadogAPIClient::V2::OpsgenieAccountUpdateAttributes.new({ + api_key: "00000000-0000-0000-0000-000000000000", + region: DatadogAPIClient::V2::OpsgenieServiceRegionType::US, + }), + id: "596da4af-0563-4097-90ff-07230c3f9db3", + type: DatadogAPIClient::V2::OpsgenieAccountType::OPSGENIE_ACCOUNT, + }), +}) +p api_instance.update_opsgenie_account("account_id", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index fb9b295c7eca..1029e09f3d5e 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3435,6 +3435,16 @@ "tenancy_ocid" => "String", "body" => "UpdateTenancyConfigRequest", }, + "v2.CreateOpsgenieAccount" => { + "body" => "OpsgenieAccountCreateRequest", + }, + "v2.DeleteOpsgenieAccount" => { + "account_id" => "String", + }, + "v2.UpdateOpsgenieAccount" => { + "account_id" => "String", + "body" => "OpsgenieAccountUpdateRequest", + }, "v2.CreateOpsgenieService" => { "body" => "OpsgenieServiceCreateRequest", }, diff --git a/features/v2/given.json b/features/v2/given.json index 7139a86ede5c..41a3abc9b519 100644 --- a/features/v2/given.json +++ b/features/v2/given.json @@ -674,6 +674,18 @@ "tag": "Microsoft Teams Integration", "operationId": "CreateWorkflowsWebhookHandle" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"api_key\": \"00000000-0000-0000-0000-000000000000\",\n \"region\": \"us\"\n },\n \"type\": \"opsgenie-account\"\n }\n}" + } + ], + "step": "there is a valid \"opsgenie_account\" in the system", + "key": "opsgenie_account", + "tag": "Opsgenie Integration", + "operationId": "CreateOpsgenieAccount" + }, { "parameters": [ { diff --git a/features/v2/opsgenie_integration.feature b/features/v2/opsgenie_integration.feature index 5df3907ac035..453d4a302775 100644 --- a/features/v2/opsgenie_integration.feature +++ b/features/v2/opsgenie_integration.feature @@ -9,6 +9,20 @@ Feature: Opsgenie Integration And a valid "appKeyAuth" key in the system And an instance of "OpsgenieIntegration" API + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Create a new Opsgenie account returns "Bad Request" response + Given new "CreateOpsgenieAccount" request + And body with value {"data": {"attributes": {"api_key": "00000000-0000-0000-0000-000000000000", "region": "us"}, "type": "opsgenie-account"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Create a new Opsgenie account returns "CREATED" response + Given new "CreateOpsgenieAccount" request + And body with value {"data": {"attributes": {"api_key": "00000000-0000-0000-0000-000000000000", "region": "us"}, "type": "opsgenie-account"}} + When the request is sent + Then the response status is 201 CREATED + @skip @team:Datadog/collaboration-integrations Scenario: Create a new service object returns "Bad Request" response Given new "CreateOpsgenieService" request @@ -54,6 +68,27 @@ Feature: Opsgenie Integration When the request is sent Then the response status is 204 OK + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Delete an Opsgenie account returns "Bad Request" response + Given new "DeleteOpsgenieAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Delete an Opsgenie account returns "Not Found" response + Given new "DeleteOpsgenieAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Delete an Opsgenie account returns "OK" response + Given new "DeleteOpsgenieAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + @generated @skip @team:Datadog/collaboration-integrations Scenario: Get a single service object returns "Bad Request" response Given new "GetOpsgenieService" request @@ -85,6 +120,12 @@ Feature: Opsgenie Integration And the response "data.attributes.name" has the same value as "opsgenie_service.data.attributes.name" And the response "data.attributes.region" is equal to "us" + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Get all Opsgenie accounts returns "OK" response + Given new "ListOpsgenieAccounts" request + When the request is sent + Then the response status is 200 OK + @team:Datadog/collaboration-integrations Scenario: Get all service objects returns "OK" response Given there is a valid "opsgenie_service" in the system @@ -127,3 +168,35 @@ Feature: Opsgenie Integration Then the response status is 200 OK And the response "data.attributes.name" is equal to "{{ opsgenie_service.data.attributes.name }}--updated" And the response "data.attributes.region" is equal to "eu" + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Update an Opsgenie account returns "Bad Request" response + Given new "UpdateOpsgenieAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"api_key": "00000000-0000-0000-0000-000000000000", "region": "us"}, "id": "596da4af-0563-4097-90ff-07230c3f9db3", "type": "opsgenie-account"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Update an Opsgenie account returns "Not Found" response + Given new "UpdateOpsgenieAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"api_key": "00000000-0000-0000-0000-000000000000", "region": "us"}, "id": "596da4af-0563-4097-90ff-07230c3f9db3", "type": "opsgenie-account"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Update an Opsgenie account returns "OK" response + Given new "UpdateOpsgenieAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"api_key": "00000000-0000-0000-0000-000000000000", "region": "us"}, "id": "596da4af-0563-4097-90ff-07230c3f9db3", "type": "opsgenie-account"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Update an Opsgenie account returns "The server cannot process the request because it contains invalid data." response + Given new "UpdateOpsgenieAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"api_key": "00000000-0000-0000-0000-000000000000", "region": "us"}, "id": "596da4af-0563-4097-90ff-07230c3f9db3", "type": "opsgenie-account"}} + When the request is sent + Then the response status is 422 The server cannot process the request because it contains invalid data. diff --git a/features/v2/undo.json b/features/v2/undo.json index b6003df86834..e16c17893f65 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -3456,6 +3456,37 @@ "type": "idempotent" } }, + "ListOpsgenieAccounts": { + "tag": "Opsgenie Integration", + "undo": { + "type": "safe" + } + }, + "CreateOpsgenieAccount": { + "tag": "Opsgenie Integration", + "undo": { + "operationId": "DeleteOpsgenieAccount", + "parameters": [ + { + "name": "account_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteOpsgenieAccount": { + "tag": "Opsgenie Integration", + "undo": { + "type": "idempotent" + } + }, + "UpdateOpsgenieAccount": { + "tag": "Opsgenie Integration", + "undo": { + "type": "idempotent" + } + }, "ListOpsgenieServices": { "tag": "Opsgenie Integration", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 6ed9f06191bc..b72efd10d9bd 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -4846,6 +4846,17 @@ def overrides "v2.open_ai_integration_update" => "OpenAIIntegrationUpdate", "v2.open_api_endpoint" => "OpenAPIEndpoint", "v2.open_api_file" => "OpenAPIFile", + "v2.opsgenie_account_create_attributes" => "OpsgenieAccountCreateAttributes", + "v2.opsgenie_account_create_data" => "OpsgenieAccountCreateData", + "v2.opsgenie_account_create_request" => "OpsgenieAccountCreateRequest", + "v2.opsgenie_account_response" => "OpsgenieAccountResponse", + "v2.opsgenie_account_response_attributes" => "OpsgenieAccountResponseAttributes", + "v2.opsgenie_account_response_data" => "OpsgenieAccountResponseData", + "v2.opsgenie_accounts_response" => "OpsgenieAccountsResponse", + "v2.opsgenie_account_type" => "OpsgenieAccountType", + "v2.opsgenie_account_update_attributes" => "OpsgenieAccountUpdateAttributes", + "v2.opsgenie_account_update_data" => "OpsgenieAccountUpdateData", + "v2.opsgenie_account_update_request" => "OpsgenieAccountUpdateRequest", "v2.opsgenie_service_create_attributes" => "OpsgenieServiceCreateAttributes", "v2.opsgenie_service_create_data" => "OpsgenieServiceCreateData", "v2.opsgenie_service_create_request" => "OpsgenieServiceCreateRequest", diff --git a/lib/datadog_api_client/v2/api/opsgenie_integration_api.rb b/lib/datadog_api_client/v2/api/opsgenie_integration_api.rb index f89024119f80..fcd4b00f53b7 100644 --- a/lib/datadog_api_client/v2/api/opsgenie_integration_api.rb +++ b/lib/datadog_api_client/v2/api/opsgenie_integration_api.rb @@ -23,6 +23,73 @@ def initialize(api_client = DatadogAPIClient::APIClient.default) @api_client = api_client end + # Create a new Opsgenie account. + # + # @see #create_opsgenie_account_with_http_info + def create_opsgenie_account(body, opts = {}) + data, _status_code, _headers = create_opsgenie_account_with_http_info(body, opts) + data + end + + # Create a new Opsgenie account. + # + # Create a new Opsgenie account in the Datadog Opsgenie integration. + # + # @param body [OpsgenieAccountCreateRequest] Opsgenie account payload. + # @param opts [Hash] the optional parameters + # @return [Array<(OpsgenieAccountResponse, Integer, Hash)>] OpsgenieAccountResponse data, response status code and response headers + def create_opsgenie_account_with_http_info(body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OpsgenieIntegrationAPI.create_opsgenie_account ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling OpsgenieIntegrationAPI.create_opsgenie_account" + end + # resource path + local_var_path = '/api/v2/integration/opsgenie/accounts' + + # 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']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'OpsgenieAccountResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_opsgenie_account, + :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::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OpsgenieIntegrationAPI#create_opsgenie_account\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Create a new service object. # # @see #create_opsgenie_service_with_http_info @@ -90,6 +157,71 @@ def create_opsgenie_service_with_http_info(body, opts = {}) return data, status_code, headers end + # Delete an Opsgenie account. + # + # @see #delete_opsgenie_account_with_http_info + def delete_opsgenie_account(account_id, opts = {}) + delete_opsgenie_account_with_http_info(account_id, opts) + nil + end + + # Delete an Opsgenie account. + # + # Delete a single Opsgenie account from the Datadog Opsgenie integration. + # + # @param account_id [String] The UUID of the Opsgenie account. + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_opsgenie_account_with_http_info(account_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OpsgenieIntegrationAPI.delete_opsgenie_account ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling OpsgenieIntegrationAPI.delete_opsgenie_account" + end + # resource path + local_var_path = '/api/v2/integration/opsgenie/accounts/{account_id}'.sub('{account_id}', CGI.escape(account_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :delete_opsgenie_account, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OpsgenieIntegrationAPI#delete_opsgenie_account\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete a single service object. # # @see #delete_opsgenie_service_with_http_info @@ -220,6 +352,66 @@ def get_opsgenie_service_with_http_info(integration_service_id, opts = {}) return data, status_code, headers end + # Get all Opsgenie accounts. + # + # @see #list_opsgenie_accounts_with_http_info + def list_opsgenie_accounts(opts = {}) + data, _status_code, _headers = list_opsgenie_accounts_with_http_info(opts) + data + end + + # Get all Opsgenie accounts. + # + # Get a list of all Opsgenie accounts from the Datadog Opsgenie integration. + # + # @param opts [Hash] the optional parameters + # @return [Array<(OpsgenieAccountsResponse, Integer, Hash)>] OpsgenieAccountsResponse data, response status code and response headers + def list_opsgenie_accounts_with_http_info(opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OpsgenieIntegrationAPI.list_opsgenie_accounts ...' + end + # resource path + local_var_path = '/api/v2/integration/opsgenie/accounts' + + # 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] || 'OpsgenieAccountsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :list_opsgenie_accounts, + :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: OpsgenieIntegrationAPI#list_opsgenie_accounts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get all service objects. # # @see #list_opsgenie_services_with_http_info @@ -280,6 +472,78 @@ def list_opsgenie_services_with_http_info(opts = {}) return data, status_code, headers end + # Update an Opsgenie account. + # + # @see #update_opsgenie_account_with_http_info + def update_opsgenie_account(account_id, body, opts = {}) + data, _status_code, _headers = update_opsgenie_account_with_http_info(account_id, body, opts) + data + end + + # Update an Opsgenie account. + # + # Update a single Opsgenie account in the Datadog Opsgenie integration. + # + # @param account_id [String] The UUID of the Opsgenie account. + # @param body [OpsgenieAccountUpdateRequest] Opsgenie account payload. + # @param opts [Hash] the optional parameters + # @return [Array<(OpsgenieAccountResponse, Integer, Hash)>] OpsgenieAccountResponse data, response status code and response headers + def update_opsgenie_account_with_http_info(account_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OpsgenieIntegrationAPI.update_opsgenie_account ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling OpsgenieIntegrationAPI.update_opsgenie_account" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling OpsgenieIntegrationAPI.update_opsgenie_account" + end + # resource path + local_var_path = '/api/v2/integration/opsgenie/accounts/{account_id}'.sub('{account_id}', CGI.escape(account_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'OpsgenieAccountResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :update_opsgenie_account, + :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::Patch, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OpsgenieIntegrationAPI#update_opsgenie_account\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Update a single service object. # # @see #update_opsgenie_service_with_http_info diff --git a/lib/datadog_api_client/v2/models/opsgenie_account_create_attributes.rb b/lib/datadog_api_client/v2/models/opsgenie_account_create_attributes.rb new file mode 100644 index 000000000000..360f7440cf8b --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_create_attributes.rb @@ -0,0 +1,148 @@ +=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 Opsgenie account attributes for a create request. + class OpsgenieAccountCreateAttributes + include BaseGenericModel + + # The Opsgenie API key for your Opsgenie account. + attr_reader :api_key + + # The region for the Opsgenie service. + attr_reader :region + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'api_key' => :'api_key', + :'region' => :'region' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'api_key' => :'String', + :'region' => :'OpsgenieServiceRegionType' + } + 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::OpsgenieAccountCreateAttributes` 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?(:'api_key') + self.api_key = attributes[:'api_key'] + end + + if attributes.key?(:'region') + self.region = attributes[:'region'] + 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 @api_key.nil? + return false if @api_key.to_s.length < 1 + return false if @region.nil? + true + end + + # Custom attribute writer method with validation + # @param api_key [Object] Object to be assigned + # @!visibility private + def api_key=(api_key) + if api_key.nil? + fail ArgumentError, 'invalid value for "api_key", api_key cannot be nil.' + end + if api_key.to_s.length < 1 + fail ArgumentError, 'invalid value for "api_key", the character length must be great than or equal to 1.' + end + @api_key = api_key + end + + # Custom attribute writer method with validation + # @param region [Object] Object to be assigned + # @!visibility private + def region=(region) + if region.nil? + fail ArgumentError, 'invalid value for "region", region cannot be nil.' + end + @region = region + 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 && + api_key == o.api_key && + region == o.region && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [api_key, region, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/opsgenie_account_create_data.rb b/lib/datadog_api_client/v2/models/opsgenie_account_create_data.rb new file mode 100644 index 000000000000..46d481488bc0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_create_data.rb @@ -0,0 +1,144 @@ +=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 + # Opsgenie account data for a create request. + class OpsgenieAccountCreateData + include BaseGenericModel + + # The Opsgenie account attributes for a create request. + attr_reader :attributes + + # Opsgenie account resource type. + 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', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'OpsgenieAccountCreateAttributes', + :'type' => :'OpsgenieAccountType' + } + 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::OpsgenieAccountCreateData` 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?(:'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 @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 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 && + 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, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/opsgenie_account_create_request.rb b/lib/datadog_api_client/v2/models/opsgenie_account_create_request.rb new file mode 100644 index 000000000000..56e2355d2d8f --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_create_request.rb @@ -0,0 +1,123 @@ +=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 + # Create request for an Opsgenie account. + class OpsgenieAccountCreateRequest + include BaseGenericModel + + # Opsgenie account data for a create request. + attr_reader :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' => :'OpsgenieAccountCreateData' + } + 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::OpsgenieAccountCreateRequest` 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 + + # 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 && + 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/opsgenie_account_response.rb b/lib/datadog_api_client/v2/models/opsgenie_account_response.rb new file mode 100644 index 000000000000..d880f23c583a --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_response.rb @@ -0,0 +1,123 @@ +=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 an Opsgenie account. + class OpsgenieAccountResponse + include BaseGenericModel + + # Opsgenie account data from a response. + attr_reader :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' => :'OpsgenieAccountResponseData' + } + 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::OpsgenieAccountResponse` 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 + + # 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 && + 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/opsgenie_account_response_attributes.rb b/lib/datadog_api_client/v2/models/opsgenie_account_response_attributes.rb new file mode 100644 index 000000000000..4e1286ed8329 --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_response_attributes.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 + # The attributes from an Opsgenie account response. + class OpsgenieAccountResponseAttributes + include BaseGenericModel + + # The region for the Opsgenie service. + attr_accessor :region + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'region' => :'region' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'region' => :'OpsgenieServiceRegionType' + } + 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::OpsgenieAccountResponseAttributes` 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?(:'region') + self.region = attributes[:'region'] + 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 && + region == o.region && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [region, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/opsgenie_account_response_data.rb b/lib/datadog_api_client/v2/models/opsgenie_account_response_data.rb new file mode 100644 index 000000000000..5b08c01052b7 --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_response_data.rb @@ -0,0 +1,173 @@ +=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 + # Opsgenie account data from a response. + class OpsgenieAccountResponseData + include BaseGenericModel + + # The attributes from an Opsgenie account response. + attr_reader :attributes + + # The ID of the Opsgenie account. + attr_reader :id + + # Opsgenie account resource type. + 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' => :'OpsgenieAccountResponseAttributes', + :'id' => :'String', + :'type' => :'OpsgenieAccountType' + } + 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::OpsgenieAccountResponseData` 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 @id.to_s.length > 100 + return false if @id.to_s.length < 1 + 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 + if id.to_s.length > 100 + fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 100.' + end + if id.to_s.length < 1 + fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 1.' + 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/opsgenie_account_type.rb b/lib/datadog_api_client/v2/models/opsgenie_account_type.rb new file mode 100644 index 000000000000..b988d7397a7d --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_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 + # Opsgenie account resource type. + class OpsgenieAccountType + include BaseEnumModel + + OPSGENIE_ACCOUNT = "opsgenie-account".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/opsgenie_account_update_attributes.rb b/lib/datadog_api_client/v2/models/opsgenie_account_update_attributes.rb new file mode 100644 index 000000000000..2ca4a649dadb --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_update_attributes.rb @@ -0,0 +1,133 @@ +=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 Opsgenie account attributes for an update request. + class OpsgenieAccountUpdateAttributes + include BaseGenericModel + + # The Opsgenie API key for your Opsgenie account. + attr_reader :api_key + + # The region for the Opsgenie service. + attr_accessor :region + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'api_key' => :'api_key', + :'region' => :'region' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'api_key' => :'String', + :'region' => :'OpsgenieServiceRegionType' + } + 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::OpsgenieAccountUpdateAttributes` 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?(:'api_key') + self.api_key = attributes[:'api_key'] + end + + if attributes.key?(:'region') + self.region = attributes[:'region'] + 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 !@api_key.nil? && @api_key.to_s.length < 1 + true + end + + # Custom attribute writer method with validation + # @param api_key [Object] Object to be assigned + # @!visibility private + def api_key=(api_key) + if !api_key.nil? && api_key.to_s.length < 1 + fail ArgumentError, 'invalid value for "api_key", the character length must be great than or equal to 1.' + end + @api_key = api_key + 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 && + api_key == o.api_key && + region == o.region && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [api_key, region, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/opsgenie_account_update_data.rb b/lib/datadog_api_client/v2/models/opsgenie_account_update_data.rb new file mode 100644 index 000000000000..dec5ec3e59e1 --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_update_data.rb @@ -0,0 +1,173 @@ +=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 + # Opsgenie account data for an update request. + class OpsgenieAccountUpdateData + include BaseGenericModel + + # The Opsgenie account attributes for an update request. + attr_reader :attributes + + # The ID of the Opsgenie account. + attr_reader :id + + # Opsgenie account resource type. + 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' => :'OpsgenieAccountUpdateAttributes', + :'id' => :'String', + :'type' => :'OpsgenieAccountType' + } + 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::OpsgenieAccountUpdateData` 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 @id.to_s.length > 100 + return false if @id.to_s.length < 1 + 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 + if id.to_s.length > 100 + fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 100.' + end + if id.to_s.length < 1 + fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 1.' + 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/opsgenie_account_update_request.rb b/lib/datadog_api_client/v2/models/opsgenie_account_update_request.rb new file mode 100644 index 000000000000..413e4bb62dc8 --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_account_update_request.rb @@ -0,0 +1,123 @@ +=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 + # Update request for an Opsgenie account. + class OpsgenieAccountUpdateRequest + include BaseGenericModel + + # Opsgenie account data for an update request. + attr_reader :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' => :'OpsgenieAccountUpdateData' + } + 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::OpsgenieAccountUpdateRequest` 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 + + # 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 && + 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/opsgenie_accounts_response.rb b/lib/datadog_api_client/v2/models/opsgenie_accounts_response.rb new file mode 100644 index 000000000000..afa9fd4449a8 --- /dev/null +++ b/lib/datadog_api_client/v2/models/opsgenie_accounts_response.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 + # Response with a list of Opsgenie accounts. + class OpsgenieAccountsResponse + include BaseGenericModel + + # An array of Opsgenie accounts. + attr_reader :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::OpsgenieAccountsResponse` 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 + + # 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 && + 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