Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,14 @@ components:
required: false
schema:
type: boolean
SlackUserUuidQueryParameter:
description: The UUID of the Datadog user to list Slack bindings for.
in: query
name: user_uuid
required: true
schema:
format: uuid
type: string
SloID:
description: The ID of the SLO.
in: path
Expand Down Expand Up @@ -86535,6 +86543,37 @@ components:
required:
- slackTrigger
type: object
SlackUserBindingData:
description: Slack team ID data from a response.
properties:
id:
description: The Slack team ID.
example: "T01234567"
type: string
type:
$ref: "#/components/schemas/SlackUserBindingType"
type: object
SlackUserBindingType:
default: team_id
description: Slack user binding resource type.
enum:
- team_id
example: team_id
type: string
x-enum-varnames:
- TEAM_ID
SlackUserBindingsResponse:
description: Response with a list of Slack user bindings.
properties:
data:
description: An array of Slack user bindings.
example: [{"id": "T01234567", "type": "team_id"}, {"id": "T09876543", "type": "team_id"}]
items:
$ref: "#/components/schemas/SlackUserBindingData"
type: array
required:
- data
type: object
SloDataSource:
default: slo
description: A data source for SLO queries.
Expand Down Expand Up @@ -132237,6 +132276,36 @@ paths:
summary: List ServiceNow users
tags:
- ServiceNow Integration
/api/v2/integration/slack/user-bindings:
get:
description: List all Slack user bindings for a given Datadog user from the Datadog Slack integration.
operationId: ListSlackUserBindings
parameters:
- $ref: "#/components/parameters/SlackUserUuidQueryParameter"
responses:
"200":
content:
application/json:
examples:
default:
value:
data:
- id: T01234567
type: team_id
- id: T09876543
type: team_id
schema:
$ref: "#/components/schemas/SlackUserBindingsResponse"
description: OK
"400":
$ref: "#/components/responses/BadRequestResponse"
"403":
$ref: "#/components/responses/ForbiddenResponse"
"429":
$ref: "#/components/responses/TooManyRequestsResponse"
summary: List Slack user bindings
tags:
- Slack Integration
/api/v2/integration/statuspage/account:
delete:
description: Delete the Statuspage account configured for your organization.
Expand Down Expand Up @@ -181539,6 +181608,13 @@ tags:
name: Service Level Objectives
- description: Manage your ServiceNow Integration. ServiceNow is a cloud-based platform that helps organizations manage digital workflows for enterprise operations.
name: ServiceNow Integration
- description: |-
Configure your [Datadog Slack integration](https://docs.datadoghq.com/integrations/slack/)
directly through the Datadog API.
externalDocs:
description: For more information about the Datadog Slack integration, see the integration page.
url: https://docs.datadoghq.com/integrations/slack/
name: Slack Integration
- description: |-
API to create, update, retrieve, and delete Software Catalog entities.
externalDocs:
Expand Down
5 changes: 5 additions & 0 deletions examples/v2/slack-integration/ListSlackUserBindings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# List Slack user bindings returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::SlackIntegrationAPI.new
p api_instance.list_slack_user_bindings("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")
3 changes: 3 additions & 0 deletions features/scenarios_model_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3562,6 +3562,9 @@
"v2.ListServiceNowUsers" => {
"instance_id" => "UUID",
},
"v2.ListSlackUserBindings" => {
"user_uuid" => "UUID",
},
"v2.UpdateStatuspageAccount" => {
"body" => "StatuspageAccountUpdateRequest",
},
Expand Down
23 changes: 23 additions & 0 deletions features/v2/slack_integration.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@endpoint(slack-integration) @endpoint(slack-integration-v2)
Feature: Slack Integration
Configure your [Datadog Slack
integration](https://docs.datadoghq.com/integrations/slack/) directly
through the Datadog API.

Background:
Given a valid "apiKeyAuth" key in the system
And a valid "appKeyAuth" key in the system
And an instance of "SlackIntegration" API
And new "ListSlackUserBindings" request

@generated @skip @team:DataDog/chat-integrations
Scenario: List Slack user bindings returns "Bad Request" response
Given request contains "user_uuid" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/chat-integrations
Scenario: List Slack user bindings returns "OK" response
Given request contains "user_uuid" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 200 OK
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3634,6 +3634,12 @@
"type": "safe"
}
},
"ListSlackUserBindings": {
"tag": "Slack Integration",
"undo": {
"type": "safe"
}
},
"DeleteStatuspageAccount": {
"tag": "Statuspage Integration",
"undo": {
Expand Down
4 changes: 4 additions & 0 deletions lib/datadog_api_client/inflector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6433,6 +6433,9 @@ def overrides
"v2.slack_integration_metadata" => "SlackIntegrationMetadata",
"v2.slack_integration_metadata_channel_item" => "SlackIntegrationMetadataChannelItem",
"v2.slack_trigger_wrapper" => "SlackTriggerWrapper",
"v2.slack_user_binding_data" => "SlackUserBindingData",
"v2.slack_user_bindings_response" => "SlackUserBindingsResponse",
"v2.slack_user_binding_type" => "SlackUserBindingType",
"v2.slo_data_source" => "SloDataSource",
"v2.slo_query" => "SloQuery",
"v2.slo_report_create_request" => "SloReportCreateRequest",
Expand Down Expand Up @@ -7558,6 +7561,7 @@ def overrides
"v2.service_definition_api" => "ServiceDefinitionAPI",
"v2.service_level_objectives_api" => "ServiceLevelObjectivesAPI",
"v2.service_now_integration_api" => "ServiceNowIntegrationAPI",
"v2.slack_integration_api" => "SlackIntegrationAPI",
"v2.software_catalog_api" => "SoftwareCatalogAPI",
"v2.spa_api" => "SpaAPI",
"v2.spans_api" => "SpansAPI",
Expand Down
92 changes: 92 additions & 0 deletions lib/datadog_api_client/v2/api/slack_integration_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
=begin
#Datadog API V2 Collection

#Collection of all Datadog Public endpoints.

The version of the OpenAPI document: 1.0
Contact: support@datadoghq.com
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator

Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
This product includes software developed at Datadog (https://www.datadoghq.com/).
Copyright 2020-Present Datadog, Inc.

=end

require 'cgi'

module DatadogAPIClient::V2
class SlackIntegrationAPI
attr_accessor :api_client

def initialize(api_client = DatadogAPIClient::APIClient.default)
@api_client = api_client
end

# List Slack user bindings.
#
# @see #list_slack_user_bindings_with_http_info
def list_slack_user_bindings(user_uuid, opts = {})
data, _status_code, _headers = list_slack_user_bindings_with_http_info(user_uuid, opts)
data
end

# List Slack user bindings.
#
# List all Slack user bindings for a given Datadog user from the Datadog Slack integration.
#
# @param user_uuid [UUID] The UUID of the Datadog user to list Slack bindings for.
# @param opts [Hash] the optional parameters
# @return [Array<(SlackUserBindingsResponse, Integer, Hash)>] SlackUserBindingsResponse data, response status code and response headers
def list_slack_user_bindings_with_http_info(user_uuid, opts = {})

if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: SlackIntegrationAPI.list_slack_user_bindings ...'
end
# verify the required parameter 'user_uuid' is set
if @api_client.config.client_side_validation && user_uuid.nil?
fail ArgumentError, "Missing the required parameter 'user_uuid' when calling SlackIntegrationAPI.list_slack_user_bindings"
end
# resource path
local_var_path = '/api/v2/integration/slack/user-bindings'

# query parameters
query_params = opts[:query_params] || {}
query_params[:'user_uuid'] = user_uuid

# 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] || 'SlackUserBindingsResponse'

# auth_names
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth]

new_options = opts.merge(
:operation => :list_slack_user_bindings,
: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: SlackIntegrationAPI#list_slack_user_bindings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end
115 changes: 115 additions & 0 deletions lib/datadog_api_client/v2/models/slack_user_binding_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
=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
# Slack team ID data from a response.
class SlackUserBindingData
include BaseGenericModel

# The Slack team ID.
attr_accessor :id

# Slack user binding resource type.
attr_accessor :type

attr_accessor :additional_properties

# Attribute mapping from ruby-style variable name to JSON key.
# @!visibility private
def self.attribute_map
{
:'id' => :'id',
:'type' => :'type'
}
end

# Attribute type mapping.
# @!visibility private
def self.openapi_types
{
:'id' => :'String',
:'type' => :'SlackUserBindingType'
}
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::SlackUserBindingData` 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?(:'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 &&
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
[id, type, additional_properties].hash
end
end
end
Loading
Loading