Class: LaunchDarklyApi::ContextSettingsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/launchdarkly_api/api/context_settings_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ContextSettingsApi

Returns a new instance of ContextSettingsApi.



19
20
21
# File 'lib/launchdarkly_api/api/context_settings_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/launchdarkly_api/api/context_settings_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#put_context_flag_setting(project_key, environment_key, context_kind, context_key, feature_flag_key, value_put, opts = {}) ⇒ nil

Update flag settings for context

Enable or disable a feature flag for a context based on its context kind and key.  In the request body, the `setting` should be the variation value to set for the context. It must match the flag's variation type. For example, for a boolean flag you can use `\"setting\": true` or `\"setting\": false` in the request body. For a string flag, you can use `\"setting\": \"existing_variation_value_to_use\"`.  Omitting the `setting` attribute from the request body, or including a `setting` of `null`, erases the current setting for a context.  If you previously patched the flag, and the patch included the context's data, LaunchDarkly continues to use that data. If LaunchDarkly has never encountered the combination of the context's key and kind before, it calculates the flag values based on the context kind and key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • context_kind (String)

    The context kind

  • context_key (String)

    The context key

  • feature_flag_key (String)

    The feature flag key

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

    the optional parameters

Returns:

  • (nil)


32
33
34
35
# File 'lib/launchdarkly_api/api/context_settings_api.rb', line 32

def put_context_flag_setting(project_key, environment_key, context_kind, context_key, feature_flag_key, value_put, opts = {})
  put_context_flag_setting_with_http_info(project_key, environment_key, context_kind, context_key, feature_flag_key, value_put, opts)
  nil
end

#put_context_flag_setting_with_http_info(project_key, environment_key, context_kind, context_key, feature_flag_key, value_put, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Update flag settings for context

Enable or disable a feature flag for a context based on its context kind and key.  In the request body, the &#x60;setting&#x60; should be the variation value to set for the context. It must match the flag&#39;s variation type. For example, for a boolean flag you can use &#x60;\&quot;setting\&quot;: true&#x60; or &#x60;\&quot;setting\&quot;: false&#x60; in the request body. For a string flag, you can use &#x60;\&quot;setting\&quot;: \&quot;existing_variation_value_to_use\&quot;&#x60;.  Omitting the &#x60;setting&#x60; attribute from the request body, or including a &#x60;setting&#x60; of &#x60;null&#x60;, erases the current setting for a context.  If you previously patched the flag, and the patch included the context&#39;s data, LaunchDarkly continues to use that data. If LaunchDarkly has never encountered the combination of the context&#39;s key and kind before, it calculates the flag values based on the context kind and key.

Parameters:

  • project_key (String)

    The project key

  • environment_key (String)

    The environment key

  • context_kind (String)

    The context kind

  • context_key (String)

    The context key

  • feature_flag_key (String)

    The feature flag key

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/launchdarkly_api/api/context_settings_api.rb', line 47

def put_context_flag_setting_with_http_info(project_key, environment_key, context_kind, context_key, feature_flag_key, value_put, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ContextSettingsApi.put_context_flag_setting ...'
  end
  # verify the required parameter 'project_key' is set
  if @api_client.config.client_side_validation && project_key.nil?
    fail ArgumentError, "Missing the required parameter 'project_key' when calling ContextSettingsApi.put_context_flag_setting"
  end
  # verify the required parameter 'environment_key' is set
  if @api_client.config.client_side_validation && environment_key.nil?
    fail ArgumentError, "Missing the required parameter 'environment_key' when calling ContextSettingsApi.put_context_flag_setting"
  end
  # verify the required parameter 'context_kind' is set
  if @api_client.config.client_side_validation && context_kind.nil?
    fail ArgumentError, "Missing the required parameter 'context_kind' when calling ContextSettingsApi.put_context_flag_setting"
  end
  # verify the required parameter 'context_key' is set
  if @api_client.config.client_side_validation && context_key.nil?
    fail ArgumentError, "Missing the required parameter 'context_key' when calling ContextSettingsApi.put_context_flag_setting"
  end
  # verify the required parameter 'feature_flag_key' is set
  if @api_client.config.client_side_validation && feature_flag_key.nil?
    fail ArgumentError, "Missing the required parameter 'feature_flag_key' when calling ContextSettingsApi.put_context_flag_setting"
  end
  # verify the required parameter 'value_put' is set
  if @api_client.config.client_side_validation && value_put.nil?
    fail ArgumentError, "Missing the required parameter 'value_put' when calling ContextSettingsApi.put_context_flag_setting"
  end
  # resource path
  local_var_path = '/api/v2/projects/{projectKey}/environments/{environmentKey}/contexts/{contextKind}/{contextKey}/flags/{featureFlagKey}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'contextKind' + '}', CGI.escape(context_kind.to_s)).sub('{' + 'contextKey' + '}', CGI.escape(context_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.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(value_put)

  # return_type
  return_type = opts[:debug_return_type]

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

  new_options = opts.merge(
    :operation => :"ContextSettingsApi.put_context_flag_setting",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ContextSettingsApi#put_context_flag_setting\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end