Class: TrophyApiClient::Admin::AsyncTenantsClient
- Inherits:
-
Object
- Object
- TrophyApiClient::Admin::AsyncTenantsClient
- Defined in:
- lib/trophy_api_client/admin/tenants/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(request:, request_options: nil) ⇒ TrophyApiClient::CreateTenantsResponse
Create tenants.
-
#delete(ids: nil, request_options: nil) ⇒ TrophyApiClient::DeleteTenantsResponse
Delete tenants by ID.
-
#get(id:, request_options: nil) ⇒ TrophyApiClient::AdminTenant
Get a tenant by ID.
- #initialize(request_client:) ⇒ TrophyApiClient::Admin::AsyncTenantsClient constructor
-
#list(limit: nil, skip: nil, request_options: nil) ⇒ TrophyApiClient::LIST_TENANTS_RESPONSE
List tenants in the current environment.
-
#update(request:, request_options: nil) ⇒ TrophyApiClient::UpdateTenantsResponse
Update tenants by ID.
Constructor Details
#initialize(request_client:) ⇒ TrophyApiClient::Admin::AsyncTenantsClient
195 196 197 |
# File 'lib/trophy_api_client/admin/tenants/client.rb', line 195 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ TrophyApiClient::AsyncRequestClient (readonly)
191 192 193 |
# File 'lib/trophy_api_client/admin/tenants/client.rb', line 191 def request_client @request_client end |
Instance Method Details
#create(request:, request_options: nil) ⇒ TrophyApiClient::CreateTenantsResponse
Create tenants.
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/trophy_api_client/admin/tenants/client.rb', line 253 def create(request:, request_options: nil) Async do response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers["Tenant-ID"] = .tenant_id unless &.tenant_id.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: admin, request_options: )}/tenants" end TrophyApiClient::CreateTenantsResponse.from_json(json_object: response.body) end end |
#delete(ids: nil, request_options: nil) ⇒ TrophyApiClient::DeleteTenantsResponse
Delete tenants by ID.
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/trophy_api_client/admin/tenants/client.rb', line 286 def delete(ids: nil, request_options: nil) Async do response = @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers["Tenant-ID"] = .tenant_id unless &.tenant_id.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "ids": ids }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: admin, request_options: )}/tenants" end TrophyApiClient::DeleteTenantsResponse.from_json(json_object: response.body) end end |
#get(id:, request_options: nil) ⇒ TrophyApiClient::AdminTenant
Get a tenant by ID.
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/trophy_api_client/admin/tenants/client.rb', line 352 def get(id:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers["Tenant-ID"] = .tenant_id unless &.tenant_id.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: admin, request_options: )}/tenants/#{id}" end TrophyApiClient::AdminTenant.from_json(json_object: response.body) end end |
#list(limit: nil, skip: nil, request_options: nil) ⇒ TrophyApiClient::LIST_TENANTS_RESPONSE
List tenants in the current environment.
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/trophy_api_client/admin/tenants/client.rb', line 212 def list(limit: nil, skip: nil, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers["Tenant-ID"] = .tenant_id unless &.tenant_id.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "limit": limit, "skip": skip }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(environment: admin, request_options: )}/tenants" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json TrophyApiClient::AdminTenant.from_json(json_object: item) end end end |
#update(request:, request_options: nil) ⇒ TrophyApiClient::UpdateTenantsResponse
Update tenants by ID.
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/trophy_api_client/admin/tenants/client.rb', line 319 def update(request:, request_options: nil) Async do response = @request_client.conn.patch do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["X-API-KEY"] = .api_key unless &.api_key.nil? req.headers["Tenant-ID"] = .tenant_id unless &.tenant_id.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: admin, request_options: )}/tenants" end TrophyApiClient::UpdateTenantsResponse.from_json(json_object: response.body) end end |