Class: OpenapiClient::RoleAssignmentsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_client/api/role_assignments_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ RoleAssignmentsApi

Returns a new instance of RoleAssignmentsApi.



19
20
21
# File 'lib/openapi_client/api/role_assignments_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/openapi_client/api/role_assignments_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#assign_role(proj_id, env_id, role_assignment_create, opts = {}) ⇒ RoleAssignmentRead

Assign Role Assigns a role to a user within a tenant. The tenant defines the scope of the assignment. In other words, the role is effective only within the tenant.

Parameters:

  • proj_id (String)

    Either the unique id of the project, or the URL-friendly key of the project (i.e: the "slug").

  • env_id (String)

    Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the "slug").

  • role_assignment_create (RoleAssignmentCreate)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



29
30
31
32
# File 'lib/openapi_client/api/role_assignments_api.rb', line 29

def assign_role(proj_id, env_id, role_assignment_create, opts = {})
  data, _status_code, _headers = assign_role_with_http_info(proj_id, env_id, role_assignment_create, opts)
  data
end

#assign_role_with_http_info(proj_id, env_id, role_assignment_create, opts = {}) ⇒ Array<(RoleAssignmentRead, Integer, Hash)>

Assign Role Assigns a role to a user within a tenant. The tenant defines the scope of the assignment. In other words, the role is effective only within the tenant.

Parameters:

  • proj_id (String)

    Either the unique id of the project, or the URL-friendly key of the project (i.e: the &quot;slug&quot;).

  • env_id (String)

    Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the &quot;slug&quot;).

  • role_assignment_create (RoleAssignmentCreate)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(RoleAssignmentRead, Integer, Hash)>)

    RoleAssignmentRead data, response status code and response headers



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/openapi_client/api/role_assignments_api.rb', line 41

def assign_role_with_http_info(proj_id, env_id, role_assignment_create, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RoleAssignmentsApi.assign_role ...'
  end
  # verify the required parameter 'proj_id' is set
  if @api_client.config.client_side_validation && proj_id.nil?
    fail ArgumentError, "Missing the required parameter 'proj_id' when calling RoleAssignmentsApi.assign_role"
  end
  # verify the required parameter 'env_id' is set
  if @api_client.config.client_side_validation && env_id.nil?
    fail ArgumentError, "Missing the required parameter 'env_id' when calling RoleAssignmentsApi.assign_role"
  end
  # verify the required parameter 'role_assignment_create' is set
  if @api_client.config.client_side_validation && role_assignment_create.nil?
    fail ArgumentError, "Missing the required parameter 'role_assignment_create' when calling RoleAssignmentsApi.assign_role"
  end
  # resource path
  local_var_path = '/v2/facts/{proj_id}/{env_id}/role_assignments'.sub('{' + 'proj_id' + '}', CGI.escape(proj_id.to_s)).sub('{' + 'env_id' + '}', CGI.escape(env_id.to_s))

  # 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'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(role_assignment_create)

  # return_type
  return_type = opts[:debug_return_type] || 'RoleAssignmentRead'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"RoleAssignmentsApi.assign_role",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RoleAssignmentsApi#assign_role\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_role_assignments(proj_id, env_id, opts = {}) ⇒ Array<RoleAssignmentRead>

List Role Assignments Lists the role assignments defined within an environment. - If the ‘user` filter is present, will only return the role assignments of that user. - If the `tenant` filter is present, will only return the role assignments in that tenant. - If the `role` filter is present, will only return role assignments that are granting that role.

Parameters:

  • proj_id (String)

    Either the unique id of the project, or the URL-friendly key of the project (i.e: the &quot;slug&quot;).

  • env_id (String)

    Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the &quot;slug&quot;).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :user (String)

    optional user filter, will only return role assignments granted to this user.

  • :role (String)

    optional role filter, will only return role assignments granting this role.

  • :tenant (String)

    optional tenant filter, will only return role assignments granted in that tenant.

  • :page (Integer)

    Page number of the results to fetch, starting at 1. (default to 1)

  • :per_page (Integer)

    The number of results per page (max 100). (default to 30)

Returns:



113
114
115
116
# File 'lib/openapi_client/api/role_assignments_api.rb', line 113

def list_role_assignments(proj_id, env_id, opts = {})
  data, _status_code, _headers = list_role_assignments_with_http_info(proj_id, env_id, opts)
  data
end

#list_role_assignments_with_http_info(proj_id, env_id, opts = {}) ⇒ Array<(Array<RoleAssignmentRead>, Integer, Hash)>

List Role Assignments Lists the role assignments defined within an environment. - If the &#x60;user&#x60; filter is present, will only return the role assignments of that user. - If the &#x60;tenant&#x60; filter is present, will only return the role assignments in that tenant. - If the &#x60;role&#x60; filter is present, will only return role assignments that are granting that role.

Parameters:

  • proj_id (String)

    Either the unique id of the project, or the URL-friendly key of the project (i.e: the &quot;slug&quot;).

  • env_id (String)

    Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the &quot;slug&quot;).

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :user (String)

    optional user filter, will only return role assignments granted to this user.

  • :role (String)

    optional role filter, will only return role assignments granting this role.

  • :tenant (String)

    optional tenant filter, will only return role assignments granted in that tenant.

  • :page (Integer)

    Page number of the results to fetch, starting at 1. (default to 1)

  • :per_page (Integer)

    The number of results per page (max 100). (default to 30)

Returns:

  • (Array<(Array<RoleAssignmentRead>, Integer, Hash)>)

    Array<RoleAssignmentRead> data, response status code and response headers



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/openapi_client/api/role_assignments_api.rb', line 129

def list_role_assignments_with_http_info(proj_id, env_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RoleAssignmentsApi.list_role_assignments ...'
  end
  # verify the required parameter 'proj_id' is set
  if @api_client.config.client_side_validation && proj_id.nil?
    fail ArgumentError, "Missing the required parameter 'proj_id' when calling RoleAssignmentsApi.list_role_assignments"
  end
  # verify the required parameter 'env_id' is set
  if @api_client.config.client_side_validation && env_id.nil?
    fail ArgumentError, "Missing the required parameter 'env_id' when calling RoleAssignmentsApi.list_role_assignments"
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling RoleAssignmentsApi.list_role_assignments, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] > 100
    fail ArgumentError, 'invalid value for "opts[:"per_page"]" when calling RoleAssignmentsApi.list_role_assignments, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"per_page"]" when calling RoleAssignmentsApi.list_role_assignments, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v2/facts/{proj_id}/{env_id}/role_assignments'.sub('{' + 'proj_id' + '}', CGI.escape(proj_id.to_s)).sub('{' + 'env_id' + '}', CGI.escape(env_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'user'] = opts[:'user'] if !opts[:'user'].nil?
  query_params[:'role'] = opts[:'role'] if !opts[:'role'].nil?
  query_params[:'tenant'] = opts[:'tenant'] if !opts[:'tenant'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'Array<RoleAssignmentRead>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"RoleAssignmentsApi.list_role_assignments",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RoleAssignmentsApi#list_role_assignments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#unassign_role(proj_id, env_id, role_assignment_remove, opts = {}) ⇒ nil

Unassign Role Unassigns a user role within a tenant. The tenant defines the scope of the assignment. In other words, the role is effective only within the tenant. If the role is not actually assigned, will return 404.

Parameters:

  • proj_id (String)

    Either the unique id of the project, or the URL-friendly key of the project (i.e: the &quot;slug&quot;).

  • env_id (String)

    Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the &quot;slug&quot;).

  • role_assignment_remove (RoleAssignmentRemove)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


205
206
207
208
# File 'lib/openapi_client/api/role_assignments_api.rb', line 205

def unassign_role(proj_id, env_id, role_assignment_remove, opts = {})
  unassign_role_with_http_info(proj_id, env_id, role_assignment_remove, opts)
  nil
end

#unassign_role_with_http_info(proj_id, env_id, role_assignment_remove, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Unassign Role Unassigns a user role within a tenant. The tenant defines the scope of the assignment. In other words, the role is effective only within the tenant. If the role is not actually assigned, will return 404.

Parameters:

  • proj_id (String)

    Either the unique id of the project, or the URL-friendly key of the project (i.e: the &quot;slug&quot;).

  • env_id (String)

    Either the unique id of the environment, or the URL-friendly key of the environment (i.e: the &quot;slug&quot;).

  • role_assignment_remove (RoleAssignmentRemove)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/openapi_client/api/role_assignments_api.rb', line 217

def unassign_role_with_http_info(proj_id, env_id, role_assignment_remove, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RoleAssignmentsApi.unassign_role ...'
  end
  # verify the required parameter 'proj_id' is set
  if @api_client.config.client_side_validation && proj_id.nil?
    fail ArgumentError, "Missing the required parameter 'proj_id' when calling RoleAssignmentsApi.unassign_role"
  end
  # verify the required parameter 'env_id' is set
  if @api_client.config.client_side_validation && env_id.nil?
    fail ArgumentError, "Missing the required parameter 'env_id' when calling RoleAssignmentsApi.unassign_role"
  end
  # verify the required parameter 'role_assignment_remove' is set
  if @api_client.config.client_side_validation && role_assignment_remove.nil?
    fail ArgumentError, "Missing the required parameter 'role_assignment_remove' when calling RoleAssignmentsApi.unassign_role"
  end
  # resource path
  local_var_path = '/v2/facts/{proj_id}/{env_id}/role_assignments'.sub('{' + 'proj_id' + '}', CGI.escape(proj_id.to_s)).sub('{' + 'env_id' + '}', CGI.escape(env_id.to_s))

  # 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'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(role_assignment_remove)

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"RoleAssignmentsApi.unassign_role",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RoleAssignmentsApi#unassign_role\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end