Skip to content

Files

Latest commit

e44d477 · Apr 4, 2025

History

History
372 lines (264 loc) · 11 KB

CustomRolesApi.md

File metadata and controls

372 lines (264 loc) · 11 KB

LaunchDarklyApi::CustomRolesApi

All URIs are relative to https://app.launchdarkly.com

Method HTTP request Description
delete_custom_role DELETE /api/v2/roles/{customRoleKey} Delete custom role
get_custom_role GET /api/v2/roles/{customRoleKey} Get custom role
get_custom_roles GET /api/v2/roles List custom roles
patch_custom_role PATCH /api/v2/roles/{customRoleKey} Update custom role
post_custom_role POST /api/v2/roles Create custom role

delete_custom_role

delete_custom_role(custom_role_key)

Delete custom role

Delete a custom role by key

Examples

require 'time'
require 'launchdarkly_api'
# setup authorization
LaunchDarklyApi.configure do |config|
  # Configure API key authorization: ApiKey
  config.api_key['ApiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['ApiKey'] = 'Bearer'
end

api_instance = LaunchDarklyApi::CustomRolesApi.new
custom_role_key = 'custom_role_key_example' # String | The custom role key

begin
  # Delete custom role
  api_instance.delete_custom_role(custom_role_key)
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->delete_custom_role: #{e}"
end

Using the delete_custom_role_with_http_info variant

This returns an Array which contains the response data (nil in this case), status code and headers.

<Array(nil, Integer, Hash)> delete_custom_role_with_http_info(custom_role_key)

begin
  # Delete custom role
  data, status_code, headers = api_instance.delete_custom_role_with_http_info(custom_role_key)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => nil
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->delete_custom_role_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
custom_role_key String The custom role key

Return type

nil (empty response body)

Authorization

ApiKey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

get_custom_role

get_custom_role(custom_role_key)

Get custom role

Get a single custom role by key or ID

Examples

require 'time'
require 'launchdarkly_api'
# setup authorization
LaunchDarklyApi.configure do |config|
  # Configure API key authorization: ApiKey
  config.api_key['ApiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['ApiKey'] = 'Bearer'
end

api_instance = LaunchDarklyApi::CustomRolesApi.new
custom_role_key = 'custom_role_key_example' # String | The custom role key or ID

begin
  # Get custom role
  result = api_instance.get_custom_role(custom_role_key)
  p result
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->get_custom_role: #{e}"
end

Using the get_custom_role_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> get_custom_role_with_http_info(custom_role_key)

begin
  # Get custom role
  data, status_code, headers = api_instance.get_custom_role_with_http_info(custom_role_key)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CustomRole>
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->get_custom_role_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
custom_role_key String The custom role key or ID

Return type

CustomRole

Authorization

ApiKey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

get_custom_roles

get_custom_roles(opts)

List custom roles

Get a complete list of custom roles. Custom roles let you create flexible policies providing fine-grained access control to everything in LaunchDarkly, from feature flags to goals, environments, and teams. With custom roles, it's possible to enforce access policies that meet your exact workflow needs. Custom roles are available to customers on our enterprise plans. If you're interested in learning more about our enterprise plans, contact sales@launchdarkly.com.

Examples

require 'time'
require 'launchdarkly_api'
# setup authorization
LaunchDarklyApi.configure do |config|
  # Configure API key authorization: ApiKey
  config.api_key['ApiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['ApiKey'] = 'Bearer'
end

api_instance = LaunchDarklyApi::CustomRolesApi.new
opts = {
  limit: 789, # Integer | The maximum number of custom roles to return. Defaults to 20.
  offset: 789 # Integer | Where to start in the list. Defaults to 0. Use this with pagination. For example, an offset of 10 skips the first ten items and then returns the next items in the list, up to the query `limit`.
}

begin
  # List custom roles
  result = api_instance.get_custom_roles(opts)
  p result
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->get_custom_roles: #{e}"
end

Using the get_custom_roles_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> get_custom_roles_with_http_info(opts)

begin
  # List custom roles
  data, status_code, headers = api_instance.get_custom_roles_with_http_info(opts)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CustomRoles>
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->get_custom_roles_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
limit Integer The maximum number of custom roles to return. Defaults to 20. [optional]
offset Integer Where to start in the list. Defaults to 0. Use this with pagination. For example, an offset of 10 skips the first ten items and then returns the next items in the list, up to the query `limit`. [optional]

Return type

CustomRoles

Authorization

ApiKey

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

patch_custom_role

patch_custom_role(custom_role_key, patch_with_comment)

Update custom role

Update a single custom role. Updating a custom role uses a JSON patch or JSON merge patch representation of the desired changes. To learn more, read Updates.

To add an element to the policy array, set the path to /policy and then append /<array index>. Use /0 to add to the beginning of the array. Use /- to add to the end of the array.

Examples

require 'time'
require 'launchdarkly_api'
# setup authorization
LaunchDarklyApi.configure do |config|
  # Configure API key authorization: ApiKey
  config.api_key['ApiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['ApiKey'] = 'Bearer'
end

api_instance = LaunchDarklyApi::CustomRolesApi.new
custom_role_key = 'custom_role_key_example' # String | The custom role key
patch_with_comment = LaunchDarklyApi::PatchWithComment.new({patch: [LaunchDarklyApi::PatchOperation.new({op: 'replace', path: '/exampleField'})]}) # PatchWithComment | 

begin
  # Update custom role
  result = api_instance.patch_custom_role(custom_role_key, patch_with_comment)
  p result
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->patch_custom_role: #{e}"
end

Using the patch_custom_role_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> patch_custom_role_with_http_info(custom_role_key, patch_with_comment)

begin
  # Update custom role
  data, status_code, headers = api_instance.patch_custom_role_with_http_info(custom_role_key, patch_with_comment)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CustomRole>
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->patch_custom_role_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
custom_role_key String The custom role key
patch_with_comment PatchWithComment

Return type

CustomRole

Authorization

ApiKey

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

post_custom_role

post_custom_role(custom_role_post)

Create custom role

Create a new custom role

Examples

require 'time'
require 'launchdarkly_api'
# setup authorization
LaunchDarklyApi.configure do |config|
  # Configure API key authorization: ApiKey
  config.api_key['ApiKey'] = 'YOUR API KEY'
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['ApiKey'] = 'Bearer'
end

api_instance = LaunchDarklyApi::CustomRolesApi.new
custom_role_post = LaunchDarklyApi::CustomRolePost.new({name: 'Ops team', key: 'role-key-123abc', policy: [LaunchDarklyApi::StatementPost.new({effect: 'allow'})]}) # CustomRolePost | 

begin
  # Create custom role
  result = api_instance.post_custom_role(custom_role_post)
  p result
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->post_custom_role: #{e}"
end

Using the post_custom_role_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> post_custom_role_with_http_info(custom_role_post)

begin
  # Create custom role
  data, status_code, headers = api_instance.post_custom_role_with_http_info(custom_role_post)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CustomRole>
rescue LaunchDarklyApi::ApiError => e
  puts "Error when calling CustomRolesApi->post_custom_role_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
custom_role_post CustomRolePost

Return type

CustomRole

Authorization

ApiKey

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json