Class: LaunchDarklyApi::WorkflowsApi
- Inherits:
-
Object
- Object
- LaunchDarklyApi::WorkflowsApi
- Defined in:
- lib/launchdarkly_api/api/workflows_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#delete_workflow(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) ⇒ nil
Delete workflow Delete a workflow from a feature flag.
-
#delete_workflow_with_http_info(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>
Delete workflow Delete a workflow from a feature flag.
-
#get_custom_workflow(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) ⇒ CustomWorkflowOutput
Get custom workflow Get a specific workflow by ID.
-
#get_custom_workflow_with_http_info(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) ⇒ Array<(CustomWorkflowOutput, Integer, Hash)>
Get custom workflow Get a specific workflow by ID.
-
#get_workflows(project_key, feature_flag_key, environment_key, opts = {}) ⇒ CustomWorkflowsListingOutput
Get workflows Display workflows associated with a feature flag.
-
#get_workflows_with_http_info(project_key, feature_flag_key, environment_key, opts = {}) ⇒ Array<(CustomWorkflowsListingOutput, Integer, Hash)>
Get workflows Display workflows associated with a feature flag.
-
#initialize(api_client = ApiClient.default) ⇒ WorkflowsApi
constructor
A new instance of WorkflowsApi.
-
#post_workflow(project_key, feature_flag_key, environment_key, custom_workflow_input, opts = {}) ⇒ CustomWorkflowOutput
Create workflow > ### Workflows are in maintenance mode > > The workflows feature is in maintenance mode, and is planned for future deprecation at a date not yet specified.
-
#post_workflow_with_http_info(project_key, feature_flag_key, environment_key, custom_workflow_input, opts = {}) ⇒ Array<(CustomWorkflowOutput, Integer, Hash)>
Create workflow > ### Workflows are in maintenance mode > > The workflows feature is in maintenance mode, and is planned for future deprecation at a date not yet specified.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ WorkflowsApi
Returns a new instance of WorkflowsApi.
19 20 21 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#delete_workflow(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) ⇒ nil
Delete workflow Delete a workflow from a feature flag.
30 31 32 33 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 30 def delete_workflow(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) delete_workflow_with_http_info(project_key, feature_flag_key, environment_key, workflow_id, opts) nil end |
#delete_workflow_with_http_info(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>
Delete workflow Delete a workflow from a feature flag.
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 101 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 43 def delete_workflow_with_http_info(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WorkflowsApi.delete_workflow ...' 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 WorkflowsApi.delete_workflow" 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 WorkflowsApi.delete_workflow" 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 WorkflowsApi.delete_workflow" end # verify the required parameter 'workflow_id' is set if @api_client.config.client_side_validation && workflow_id.nil? fail ArgumentError, "Missing the required parameter 'workflow_id' when calling WorkflowsApi.delete_workflow" end # resource path local_var_path = '/api/v2/projects/{projectKey}/flags/{featureFlagKey}/environments/{environmentKey}/workflows/{workflowId}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'workflowId' + '}', CGI.escape(workflow_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']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['ApiKey'] = opts.merge( :operation => :"WorkflowsApi.delete_workflow", :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: WorkflowsApi#delete_workflow\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_custom_workflow(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) ⇒ CustomWorkflowOutput
Get custom workflow Get a specific workflow by ID.
111 112 113 114 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 111 def get_custom_workflow(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) data, _status_code, _headers = get_custom_workflow_with_http_info(project_key, feature_flag_key, environment_key, workflow_id, opts) data end |
#get_custom_workflow_with_http_info(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) ⇒ Array<(CustomWorkflowOutput, Integer, Hash)>
Get custom workflow Get a specific workflow by ID.
124 125 126 127 128 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 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 124 def get_custom_workflow_with_http_info(project_key, feature_flag_key, environment_key, workflow_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WorkflowsApi.get_custom_workflow ...' 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 WorkflowsApi.get_custom_workflow" 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 WorkflowsApi.get_custom_workflow" 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 WorkflowsApi.get_custom_workflow" end # verify the required parameter 'workflow_id' is set if @api_client.config.client_side_validation && workflow_id.nil? fail ArgumentError, "Missing the required parameter 'workflow_id' when calling WorkflowsApi.get_custom_workflow" end # resource path local_var_path = '/api/v2/projects/{projectKey}/flags/{featureFlagKey}/environments/{environmentKey}/workflows/{workflowId}'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)).sub('{' + 'workflowId' + '}', CGI.escape(workflow_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']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CustomWorkflowOutput' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKey'] = opts.merge( :operation => :"WorkflowsApi.get_custom_workflow", :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: WorkflowsApi#get_custom_workflow\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_workflows(project_key, feature_flag_key, environment_key, opts = {}) ⇒ CustomWorkflowsListingOutput
Get workflows Display workflows associated with a feature flag.
195 196 197 198 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 195 def get_workflows(project_key, feature_flag_key, environment_key, opts = {}) data, _status_code, _headers = get_workflows_with_http_info(project_key, feature_flag_key, environment_key, opts) data end |
#get_workflows_with_http_info(project_key, feature_flag_key, environment_key, opts = {}) ⇒ Array<(CustomWorkflowsListingOutput, Integer, Hash)>
Get workflows Display workflows associated with a feature flag.
211 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 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 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 211 def get_workflows_with_http_info(project_key, feature_flag_key, environment_key, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WorkflowsApi.get_workflows ...' 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 WorkflowsApi.get_workflows" 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 WorkflowsApi.get_workflows" 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 WorkflowsApi.get_workflows" end # resource path local_var_path = '/api/v2/projects/{projectKey}/flags/{featureFlagKey}/environments/{environmentKey}/workflows'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil? query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].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] || 'CustomWorkflowsListingOutput' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKey'] = opts.merge( :operation => :"WorkflowsApi.get_workflows", :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: WorkflowsApi#get_workflows\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#post_workflow(project_key, feature_flag_key, environment_key, custom_workflow_input, opts = {}) ⇒ CustomWorkflowOutput
Create workflow > ### Workflows are in maintenance mode > > The workflows feature is in maintenance mode, and is planned for future deprecation at a date not yet specified. We will work with existing customers using workflows to migrate to a replacement solution when deprecation occurs. Create a workflow for a feature flag. You can create a workflow directly, or you can apply a template to create a new workflow. ### Creating a workflow You can use the create workflow endpoint to create a workflow directly by adding a ‘stages` array to the request body. For each stage, define the `name`, `conditions` when the stage should be executed, and `action` that describes the stage. For approval stages, only standard LaunchDarkly approvals are permitted. Workflows of `kind` `integration-approval` cannot be used for custom workflows. <details> <summary>Click to expand example</summary> _Example request body_ “`json { "name": "Progressive rollout starting in two days", "description": "Turn flag targeting on and increase feature rollout in 10% increments each day", "stages": [ { "name": "10% rollout on day 1", "conditions": [ { "kind": "schedule", "scheduleKind": "relative", // or "absolute" // If "scheduleKind" is "absolute", set "executionDate"; // "waitDuration" and "waitDurationUnit" will be ignored "waitDuration": 2, "waitDurationUnit": "calendarDay" }, { "kind": "ld-approval", "notifyMemberIds": [ "507f1f77bcf86cd799439011" ], "notifyTeamKeys": [ "team-key-123abc" ] } ], "action": { "instructions": [ { "kind": "turnFlagOn" }, { "kind": "updateFallthroughVariationOrRollout", "rolloutWeights": { "452f5fb5-7320-4ba3-81a1-8f4324f79d49": 90000, "fc15f6a4-05d3-4aa4-a997-446be461345d": 10000 } } ] } } ] } “` </details> ### Creating a workflow by applying a workflow template You can also create a workflow by applying a workflow template. If you pass a valid workflow template key as the `templateKey` query parameter with the request, the API will attempt to create a new workflow with the stages defined in the workflow template with the corresponding key. #### Applicability of stages Templates are created in the context of a particular flag in a particular environment in a particular project. However, because workflows created from a template can be applied to any project, environment, and flag, some steps of the workflow may need to be updated in order to be applicable for the target resource. You can pass a `dryRun` query parameter to tell the API to return a report of which steps of the workflow template are applicable in the target project/environment/flag, and which will need to be updated. When the `dryRun` query parameter is present the response body includes a `meta` property that holds a list of parameters that could potentially be inapplicable for the target resource. Each of these parameters will include a `valid` field. You will need to update any invalid parameters in order to create the new workflow. You can do this using the `parameters` property, which overrides the workflow template parameters. #### Overriding template parameters You can use the `parameters` property in the request body to tell the API to override the specified workflow template parameters with new values that are specific to your target project/environment/flag. <details> <summary>Click to expand example</summary> _Example request body_ “`json { "name": "workflow created from my-template", "description": "description of my workflow", "parameters": [ { "_id": "62cf2bc4cadbeb7697943f3b", "path": "/clauses/0/values", "default": { "value": ["updated-segment"] } }, { "_id": "62cf2bc4cadbeb7697943f3d", "path": "/variationId", "default": { "value": "abcd1234-abcd-1234-abcd-1234abcd12" } } ] } “` </details> If there are any steps in the template that are not applicable to the target resource, the workflow will not be created, and the `meta` property will be included in the response body detailing which parameters need to be updated.
281 282 283 284 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 281 def post_workflow(project_key, feature_flag_key, environment_key, custom_workflow_input, opts = {}) data, _status_code, _headers = post_workflow_with_http_info(project_key, feature_flag_key, environment_key, custom_workflow_input, opts) data end |
#post_workflow_with_http_info(project_key, feature_flag_key, environment_key, custom_workflow_input, opts = {}) ⇒ Array<(CustomWorkflowOutput, Integer, Hash)>
Create workflow > ### Workflows are in maintenance mode > > The workflows feature is in maintenance mode, and is planned for future deprecation at a date not yet specified. We will work with existing customers using workflows to migrate to a replacement solution when deprecation occurs. Create a workflow for a feature flag. You can create a workflow directly, or you can apply a template to create a new workflow. ### Creating a workflow You can use the create workflow endpoint to create a workflow directly by adding a `stages` array to the request body. For each stage, define the `name`, `conditions` when the stage should be executed, and `action` that describes the stage. For approval stages, only standard LaunchDarkly approvals are permitted. Workflows of `kind` `integration-approval` cannot be used for custom workflows. <details> <summary>Click to expand example</summary> _Example request body_ ```json { "name": "Progressive rollout starting in two days", "description": "Turn flag targeting on and increase feature rollout in 10% increments each day", "stages": [ { "name": "10% rollout on day 1", "conditions": [ { "kind": "schedule", "scheduleKind": "relative", // or "absolute" // If "scheduleKind" is "absolute", set "executionDate"; // "waitDuration" and "waitDurationUnit" will be ignored "waitDuration": 2, "waitDurationUnit": "calendarDay" }, { "kind": "ld-approval", "notifyMemberIds": [ "507f1f77bcf86cd799439011" ], "notifyTeamKeys": [ "team-key-123abc" ] } ], "action": { "instructions": [ { "kind": "turnFlagOn" }, { "kind": "updateFallthroughVariationOrRollout", "rolloutWeights": { "452f5fb5-7320-4ba3-81a1-8f4324f79d49": 90000, "fc15f6a4-05d3-4aa4-a997-446be461345d": 10000 } } ] } } ] } ``` </details> ### Creating a workflow by applying a workflow template You can also create a workflow by applying a workflow template. If you pass a valid workflow template key as the `templateKey` query parameter with the request, the API will attempt to create a new workflow with the stages defined in the workflow template with the corresponding key. #### Applicability of stages Templates are created in the context of a particular flag in a particular environment in a particular project. However, because workflows created from a template can be applied to any project, environment, and flag, some steps of the workflow may need to be updated in order to be applicable for the target resource. You can pass a `dryRun` query parameter to tell the API to return a report of which steps of the workflow template are applicable in the target project/environment/flag, and which will need to be updated. When the `dryRun` query parameter is present the response body includes a `meta` property that holds a list of parameters that could potentially be inapplicable for the target resource. Each of these parameters will include a `valid` field. You will need to update any invalid parameters in order to create the new workflow. You can do this using the `parameters` property, which overrides the workflow template parameters. #### Overriding template parameters You can use the `parameters` property in the request body to tell the API to override the specified workflow template parameters with new values that are specific to your target project/environment/flag. <details> <summary>Click to expand example</summary> _Example request body_ ```json { "name": "workflow created from my-template", "description": "description of my workflow", "parameters": [ { "_id": "62cf2bc4cadbeb7697943f3b", "path": "/clauses/0/values", "default": { "value": ["updated-segment"] } }, { "_id": "62cf2bc4cadbeb7697943f3d", "path": "/variationId", "default": { "value": "abcd1234-abcd-1234-abcd-1234abcd12" } } ] } ``` </details> If there are any steps in the template that are not applicable to the target resource, the workflow will not be created, and the `meta` property will be included in the response body detailing which parameters need to be updated.
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/launchdarkly_api/api/workflows_api.rb', line 296 def post_workflow_with_http_info(project_key, feature_flag_key, environment_key, custom_workflow_input, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: WorkflowsApi.post_workflow ...' 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 WorkflowsApi.post_workflow" 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 WorkflowsApi.post_workflow" 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 WorkflowsApi.post_workflow" end # verify the required parameter 'custom_workflow_input' is set if @api_client.config.client_side_validation && custom_workflow_input.nil? fail ArgumentError, "Missing the required parameter 'custom_workflow_input' when calling WorkflowsApi.post_workflow" end # resource path local_var_path = '/api/v2/projects/{projectKey}/flags/{featureFlagKey}/environments/{environmentKey}/workflows'.sub('{' + 'projectKey' + '}', CGI.escape(project_key.to_s)).sub('{' + 'featureFlagKey' + '}', CGI.escape(feature_flag_key.to_s)).sub('{' + 'environmentKey' + '}', CGI.escape(environment_key.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'templateKey'] = opts[:'template_key'] if !opts[:'template_key'].nil? query_params[:'dryRun'] = opts[:'dry_run'] if !opts[:'dry_run'].nil? # 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(custom_workflow_input) # return_type return_type = opts[:debug_return_type] || 'CustomWorkflowOutput' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKey'] = opts.merge( :operation => :"WorkflowsApi.post_workflow", :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: WorkflowsApi#post_workflow\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |