Skip to content

Commit d619850

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Document /api/v2/roles/templates (#2703)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent e0f1e94 commit d619850

File tree

11 files changed

+566
-0
lines changed

11 files changed

+566
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38435,6 +38435,49 @@ components:
3843538435
permissions:
3843638436
$ref: '#/components/schemas/RelationshipToPermissions'
3843738437
type: object
38438+
RoleTemplateArray:
38439+
description: The definition of `RoleTemplateArray` object.
38440+
properties:
38441+
data:
38442+
description: The `RoleTemplateArray` `data`.
38443+
items:
38444+
$ref: '#/components/schemas/RoleTemplateData'
38445+
type: array
38446+
required:
38447+
- data
38448+
type: object
38449+
RoleTemplateData:
38450+
description: The definition of `RoleTemplateData` object.
38451+
properties:
38452+
attributes:
38453+
$ref: '#/components/schemas/RoleTemplateDataAttributes'
38454+
id:
38455+
description: The `RoleTemplateData` `id`.
38456+
type: string
38457+
type:
38458+
$ref: '#/components/schemas/RoleTemplateDataType'
38459+
required:
38460+
- type
38461+
type: object
38462+
RoleTemplateDataAttributes:
38463+
description: The definition of `RoleTemplateDataAttributes` object.
38464+
properties:
38465+
description:
38466+
description: The `attributes` `description`.
38467+
type: string
38468+
name:
38469+
description: The `attributes` `name`.
38470+
type: string
38471+
type: object
38472+
RoleTemplateDataType:
38473+
default: roles
38474+
description: Roles resource type.
38475+
enum:
38476+
- roles
38477+
example: roles
38478+
type: string
38479+
x-enum-varnames:
38480+
- ROLES
3843838481
RoleUpdateAttributes:
3843938482
description: Attributes of the role.
3844038483
properties:
@@ -67658,6 +67701,28 @@ paths:
6765867701
operator: OR
6765967702
permissions:
6766067703
- user_access_manage
67704+
/api/v2/roles/templates:
67705+
get:
67706+
description: List all role templates
67707+
operationId: ListRoleTemplates
67708+
responses:
67709+
'200':
67710+
content:
67711+
application/json:
67712+
schema:
67713+
$ref: '#/components/schemas/RoleTemplateArray'
67714+
description: OK
67715+
'429':
67716+
$ref: '#/components/responses/TooManyRequestsResponse'
67717+
security:
67718+
- apiKeyAuth: []
67719+
appKeyAuth: []
67720+
- AuthZ:
67721+
- user_access_read
67722+
summary: List role templates
67723+
tags:
67724+
- Roles
67725+
x-unstable: '**Note**: This endpoint may be subject to changes.'
6766167726
/api/v2/roles/{role_id}:
6766267727
delete:
6766367728
description: Disables a role.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# List role templates returns "OK" response
2+
3+
require "datadog_api_client"
4+
DatadogAPIClient.configure do |config|
5+
config.unstable_operations["v2.list_role_templates".to_sym] = true
6+
end
7+
api_instance = DatadogAPIClient::V2::RolesAPI.new
8+
p api_instance.list_role_templates()

features/v2/roles.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ Feature: Roles
216216
And the response "data" has item with field "attributes.restricted" with value false
217217
And the response "data" has item with field "attributes.name" with value "admin"
218218

219+
@generated @skip @team:DataDog/aaa-core-access
220+
Scenario: List role templates returns "OK" response
221+
Given operation "ListRoleTemplates" enabled
222+
And new "ListRoleTemplates" request
223+
When the request is sent
224+
Then the response status is 200 OK
225+
219226
@team:DataDog/aaa-core-access
220227
Scenario: List roles returns "OK" response
221228
Given there is a valid "role" in the system

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,6 +2869,12 @@
28692869
"type": "unsafe"
28702870
}
28712871
},
2872+
"ListRoleTemplates": {
2873+
"tag": "Roles",
2874+
"undo": {
2875+
"type": "safe"
2876+
}
2877+
},
28722878
"DeleteRole": {
28732879
"tag": "Roles",
28742880
"undo": {

lib/datadog_api_client/configuration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ def initialize
263263
"v2.update_monitor_user_template": false,
264264
"v2.validate_existing_monitor_user_template": false,
265265
"v2.validate_monitor_user_template": false,
266+
"v2.list_role_templates": false,
266267
"v2.create_pipeline": false,
267268
"v2.delete_pipeline": false,
268269
"v2.get_pipeline": false,

lib/datadog_api_client/inflector.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,6 +3302,10 @@ def overrides
33023302
"v2.roles_response" => "RolesResponse",
33033303
"v2.roles_sort" => "RolesSort",
33043304
"v2.roles_type" => "RolesType",
3305+
"v2.role_template_array" => "RoleTemplateArray",
3306+
"v2.role_template_data" => "RoleTemplateData",
3307+
"v2.role_template_data_attributes" => "RoleTemplateDataAttributes",
3308+
"v2.role_template_data_type" => "RoleTemplateDataType",
33053309
"v2.role_update_attributes" => "RoleUpdateAttributes",
33063310
"v2.role_update_data" => "RoleUpdateData",
33073311
"v2.role_update_request" => "RoleUpdateRequest",

lib/datadog_api_client/v2/api/roles_api.rb

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,72 @@ def list_roles_with_http_info(opts = {})
635635
return data, status_code, headers
636636
end
637637

638+
# List role templates.
639+
#
640+
# @see #list_role_templates_with_http_info
641+
def list_role_templates(opts = {})
642+
data, _status_code, _headers = list_role_templates_with_http_info(opts)
643+
data
644+
end
645+
646+
# List role templates.
647+
#
648+
# List all role templates
649+
#
650+
# @param opts [Hash] the optional parameters
651+
# @return [Array<(RoleTemplateArray, Integer, Hash)>] RoleTemplateArray data, response status code and response headers
652+
def list_role_templates_with_http_info(opts = {})
653+
unstable_enabled = @api_client.config.unstable_operations["v2.list_role_templates".to_sym]
654+
if unstable_enabled
655+
@api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_role_templates")
656+
else
657+
raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_role_templates"))
658+
end
659+
660+
if @api_client.config.debugging
661+
@api_client.config.logger.debug 'Calling API: RolesAPI.list_role_templates ...'
662+
end
663+
# resource path
664+
local_var_path = '/api/v2/roles/templates'
665+
666+
# query parameters
667+
query_params = opts[:query_params] || {}
668+
669+
# header parameters
670+
header_params = opts[:header_params] || {}
671+
# HTTP header 'Accept' (if needed)
672+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
673+
674+
# form parameters
675+
form_params = opts[:form_params] || {}
676+
677+
# http body (model)
678+
post_body = opts[:debug_body]
679+
680+
# return_type
681+
return_type = opts[:debug_return_type] || 'RoleTemplateArray'
682+
683+
# auth_names
684+
auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ]
685+
686+
new_options = opts.merge(
687+
:operation => :list_role_templates,
688+
:header_params => header_params,
689+
:query_params => query_params,
690+
:form_params => form_params,
691+
:body => post_body,
692+
:auth_names => auth_names,
693+
:return_type => return_type,
694+
:api_version => "V2"
695+
)
696+
697+
data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options)
698+
if @api_client.config.debugging
699+
@api_client.config.logger.debug "API called: RolesAPI#list_role_templates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
700+
end
701+
return data, status_code, headers
702+
end
703+
638704
# Get all users of a role.
639705
#
640706
# @see #list_role_users_with_http_info
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
=begin
2+
#Datadog API V2 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
Contact: support@datadoghq.com
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V2
20+
# The definition of `RoleTemplateArray` object.
21+
class RoleTemplateArray
22+
include BaseGenericModel
23+
24+
# The `RoleTemplateArray` `data`.
25+
attr_reader :data
26+
27+
attr_accessor :additional_properties
28+
29+
# Attribute mapping from ruby-style variable name to JSON key.
30+
# @!visibility private
31+
def self.attribute_map
32+
{
33+
:'data' => :'data'
34+
}
35+
end
36+
37+
# Attribute type mapping.
38+
# @!visibility private
39+
def self.openapi_types
40+
{
41+
:'data' => :'Array<RoleTemplateData>'
42+
}
43+
end
44+
45+
# Initializes the object
46+
# @param attributes [Hash] Model attributes in the form of hash
47+
# @!visibility private
48+
def initialize(attributes = {})
49+
if (!attributes.is_a?(Hash))
50+
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::RoleTemplateArray` initialize method"
51+
end
52+
53+
self.additional_properties = {}
54+
# check to see if the attribute exists and convert string to symbol for hash key
55+
attributes = attributes.each_with_object({}) { |(k, v), h|
56+
if (!self.class.attribute_map.key?(k.to_sym))
57+
self.additional_properties[k.to_sym] = v
58+
else
59+
h[k.to_sym] = v
60+
end
61+
}
62+
63+
if attributes.key?(:'data')
64+
if (value = attributes[:'data']).is_a?(Array)
65+
self.data = value
66+
end
67+
end
68+
end
69+
70+
# Check to see if the all the properties in the model are valid
71+
# @return true if the model is valid
72+
# @!visibility private
73+
def valid?
74+
return false if @data.nil?
75+
true
76+
end
77+
78+
# Custom attribute writer method with validation
79+
# @param data [Object] Object to be assigned
80+
# @!visibility private
81+
def data=(data)
82+
if data.nil?
83+
fail ArgumentError, 'invalid value for "data", data cannot be nil.'
84+
end
85+
@data = data
86+
end
87+
88+
# Returns the object in the form of hash, with additionalProperties support.
89+
# @return [Hash] Returns the object in the form of hash
90+
# @!visibility private
91+
def to_hash
92+
hash = {}
93+
self.class.attribute_map.each_pair do |attr, param|
94+
value = self.send(attr)
95+
if value.nil?
96+
is_nullable = self.class.openapi_nullable.include?(attr)
97+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
98+
end
99+
100+
hash[param] = _to_hash(value)
101+
end
102+
self.additional_properties.each_pair do |attr, value|
103+
hash[attr] = value
104+
end
105+
hash
106+
end
107+
108+
# Checks equality by comparing each attribute.
109+
# @param o [Object] Object to be compared
110+
# @!visibility private
111+
def ==(o)
112+
return true if self.equal?(o)
113+
self.class == o.class &&
114+
data == o.data &&
115+
additional_properties == o.additional_properties
116+
end
117+
118+
# Calculates hash code according to all attributes.
119+
# @return [Integer] Hash code
120+
# @!visibility private
121+
def hash
122+
[data, additional_properties].hash
123+
end
124+
end
125+
end

0 commit comments

Comments
 (0)