Skip to content
Merged
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
65 changes: 65 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38435,6 +38435,49 @@ components:
permissions:
$ref: '#/components/schemas/RelationshipToPermissions'
type: object
RoleTemplateArray:
description: The definition of `RoleTemplateArray` object.
properties:
data:
description: The `RoleTemplateArray` `data`.
items:
$ref: '#/components/schemas/RoleTemplateData'
type: array
required:
- data
type: object
RoleTemplateData:
description: The definition of `RoleTemplateData` object.
properties:
attributes:
$ref: '#/components/schemas/RoleTemplateDataAttributes'
id:
description: The `RoleTemplateData` `id`.
type: string
type:
$ref: '#/components/schemas/RoleTemplateDataType'
required:
- type
type: object
RoleTemplateDataAttributes:
description: The definition of `RoleTemplateDataAttributes` object.
properties:
description:
description: The `attributes` `description`.
type: string
name:
description: The `attributes` `name`.
type: string
type: object
RoleTemplateDataType:
default: roles
description: Roles resource type.
enum:
- roles
example: roles
type: string
x-enum-varnames:
- ROLES
RoleUpdateAttributes:
description: Attributes of the role.
properties:
Expand Down Expand Up @@ -67658,6 +67701,28 @@ paths:
operator: OR
permissions:
- user_access_manage
/api/v2/roles/templates:
get:
description: List all role templates
operationId: ListRoleTemplates
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/RoleTemplateArray'
description: OK
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- user_access_read
summary: List role templates
tags:
- Roles
x-unstable: '**Note**: This endpoint may be subject to changes.'
/api/v2/roles/{role_id}:
delete:
description: Disables a role.
Expand Down
8 changes: 8 additions & 0 deletions examples/v2/roles/ListRoleTemplates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# List role templates returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.unstable_operations["v2.list_role_templates".to_sym] = true
end
api_instance = DatadogAPIClient::V2::RolesAPI.new
p api_instance.list_role_templates()
7 changes: 7 additions & 0 deletions features/v2/roles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ Feature: Roles
And the response "data" has item with field "attributes.restricted" with value false
And the response "data" has item with field "attributes.name" with value "admin"

@generated @skip @team:DataDog/aaa-core-access
Scenario: List role templates returns "OK" response
Given operation "ListRoleTemplates" enabled
And new "ListRoleTemplates" request
When the request is sent
Then the response status is 200 OK

@team:DataDog/aaa-core-access
Scenario: List roles returns "OK" response
Given there is a valid "role" in the system
Expand Down
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -2869,6 +2869,12 @@
"type": "unsafe"
}
},
"ListRoleTemplates": {
"tag": "Roles",
"undo": {
"type": "safe"
}
},
"DeleteRole": {
"tag": "Roles",
"undo": {
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def initialize
"v2.update_monitor_user_template": false,
"v2.validate_existing_monitor_user_template": false,
"v2.validate_monitor_user_template": false,
"v2.list_role_templates": false,
"v2.create_pipeline": false,
"v2.delete_pipeline": false,
"v2.get_pipeline": false,
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 @@ -3302,6 +3302,10 @@ def overrides
"v2.roles_response" => "RolesResponse",
"v2.roles_sort" => "RolesSort",
"v2.roles_type" => "RolesType",
"v2.role_template_array" => "RoleTemplateArray",
"v2.role_template_data" => "RoleTemplateData",
"v2.role_template_data_attributes" => "RoleTemplateDataAttributes",
"v2.role_template_data_type" => "RoleTemplateDataType",
"v2.role_update_attributes" => "RoleUpdateAttributes",
"v2.role_update_data" => "RoleUpdateData",
"v2.role_update_request" => "RoleUpdateRequest",
Expand Down
66 changes: 66 additions & 0 deletions lib/datadog_api_client/v2/api/roles_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,72 @@ def list_roles_with_http_info(opts = {})
return data, status_code, headers
end

# List role templates.
#
# @see #list_role_templates_with_http_info
def list_role_templates(opts = {})
data, _status_code, _headers = list_role_templates_with_http_info(opts)
data
end

# List role templates.
#
# List all role templates
#
# @param opts [Hash] the optional parameters
# @return [Array<(RoleTemplateArray, Integer, Hash)>] RoleTemplateArray data, response status code and response headers
def list_role_templates_with_http_info(opts = {})
unstable_enabled = @api_client.config.unstable_operations["v2.list_role_templates".to_sym]
if unstable_enabled
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_role_templates")
else
raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_role_templates"))
end

if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: RolesAPI.list_role_templates ...'
end
# resource path
local_var_path = '/api/v2/roles/templates'

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

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

new_options = opts.merge(
:operation => :list_role_templates,
: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: RolesAPI#list_role_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

# Get all users of a role.
#
# @see #list_role_users_with_http_info
Expand Down
125 changes: 125 additions & 0 deletions lib/datadog_api_client/v2/models/role_template_array.rb
Original file line number Diff line number Diff line change
@@ -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
# The definition of `RoleTemplateArray` object.
class RoleTemplateArray
include BaseGenericModel

# The `RoleTemplateArray` `data`.
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<RoleTemplateData>'
}
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::RoleTemplateArray` 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
Loading
Loading