launchdarkly_api 18.1.0 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -10
  3. data/docs/AIConfig.md +3 -1
  4. data/docs/AIConfigPost.md +3 -1
  5. data/docs/AIConfigsBetaApi.md +387 -0
  6. data/docs/AccountUsageBetaApi.md +182 -0
  7. data/docs/AgentGraph.md +30 -0
  8. data/docs/AgentGraphEdge.md +24 -0
  9. data/docs/AgentGraphEdgePost.md +24 -0
  10. data/docs/AgentGraphPatch.md +24 -0
  11. data/docs/AgentGraphPost.md +26 -0
  12. data/docs/AgentGraphs.md +22 -0
  13. data/docs/AiConfigsMetricDataSourceRefRep.md +1 -1
  14. data/docs/AiConfigsMetricListingRep.md +1 -1
  15. data/docs/DataExportDestinationsApi.md +74 -0
  16. data/docs/FeatureFlagsApi.md +5 -3
  17. data/docs/GenerateTrustPolicyPostRep.md +18 -0
  18. data/docs/GuardedReleaseConfig.md +10 -2
  19. data/docs/IterationInput.md +0 -2
  20. data/docs/IterationRep.md +1 -3
  21. data/docs/MetricDataSourceRefRep.md +1 -1
  22. data/docs/MetricGroupRep.md +1 -5
  23. data/docs/MetricListingRep.md +1 -1
  24. data/docs/MetricRep.md +1 -1
  25. data/docs/Metrics.md +7 -1
  26. data/docs/MetricsApi.md +3 -3
  27. data/docs/PostReleasePolicyRequest.md +2 -2
  28. data/docs/ProgressiveReleaseConfig.md +20 -0
  29. data/docs/PutReleasePolicyRequest.md +2 -2
  30. data/docs/RelayAutoConfigRep.md +1 -1
  31. data/docs/ReleasePolicy.md +2 -2
  32. data/docs/ReleasePolicyScope.md +3 -1
  33. data/docs/ReleasePolicyStage.md +20 -0
  34. data/docs/Rule.md +2 -0
  35. data/docs/ScheduledChangesApi.md +1 -1
  36. data/docs/SegmentsApi.md +9 -5
  37. data/docs/TagsApi.md +2 -2
  38. data/docs/TrustPolicyDetails.md +20 -0
  39. data/docs/TrustPolicyStatement.md +24 -0
  40. data/lib/launchdarkly_api/api/account_usage_beta_api.rb +171 -0
  41. data/lib/launchdarkly_api/api/ai_configs_beta_api.rb +417 -0
  42. data/lib/launchdarkly_api/api/data_export_destinations_api.rb +69 -0
  43. data/lib/launchdarkly_api/api/feature_flags_api.rb +5 -2
  44. data/lib/launchdarkly_api/api/metrics_api.rb +4 -4
  45. data/lib/launchdarkly_api/api/scheduled_changes_api.rb +2 -2
  46. data/lib/launchdarkly_api/api/segments_api.rb +5 -2
  47. data/lib/launchdarkly_api/api/tags_api.rb +2 -2
  48. data/lib/launchdarkly_api/models/agent_graph.rb +350 -0
  49. data/lib/launchdarkly_api/models/agent_graph_edge.rb +303 -0
  50. data/lib/launchdarkly_api/models/agent_graph_edge_post.rb +303 -0
  51. data/lib/launchdarkly_api/models/agent_graph_patch.rb +254 -0
  52. data/lib/launchdarkly_api/models/agent_graph_post.rb +298 -0
  53. data/lib/launchdarkly_api/models/{covariance_info_rep.rb → agent_graphs.rb} +43 -59
  54. data/lib/launchdarkly_api/models/ai_config.rb +16 -4
  55. data/lib/launchdarkly_api/models/ai_config_post.rb +13 -4
  56. data/lib/launchdarkly_api/models/ai_configs_metric_data_source_ref_rep.rb +17 -0
  57. data/lib/launchdarkly_api/models/ai_configs_metric_listing_rep.rb +17 -0
  58. data/lib/launchdarkly_api/models/destination.rb +2 -2
  59. data/lib/launchdarkly_api/models/destination_post.rb +2 -2
  60. data/lib/launchdarkly_api/models/generate_trust_policy_post_rep.rb +220 -0
  61. data/lib/launchdarkly_api/models/guarded_release_config.rb +50 -21
  62. data/lib/launchdarkly_api/models/iteration_input.rb +1 -11
  63. data/lib/launchdarkly_api/models/iteration_rep.rb +32 -17
  64. data/lib/launchdarkly_api/models/metric_data_source_ref_rep.rb +17 -0
  65. data/lib/launchdarkly_api/models/metric_group_rep.rb +4 -24
  66. data/lib/launchdarkly_api/models/metric_listing_rep.rb +17 -0
  67. data/lib/launchdarkly_api/models/metric_rep.rb +17 -0
  68. data/lib/launchdarkly_api/models/metrics.rb +118 -4
  69. data/lib/launchdarkly_api/models/naming_convention.rb +2 -2
  70. data/lib/launchdarkly_api/models/post_release_policy_request.rb +1 -2
  71. data/lib/launchdarkly_api/models/progressive_release_config.rb +234 -0
  72. data/lib/launchdarkly_api/models/put_release_policy_request.rb +1 -2
  73. data/lib/launchdarkly_api/models/relay_auto_config_rep.rb +0 -17
  74. data/lib/launchdarkly_api/models/release_policy.rb +1 -2
  75. data/lib/launchdarkly_api/models/release_policy_scope.rb +16 -4
  76. data/lib/launchdarkly_api/models/release_policy_stage.rb +263 -0
  77. data/lib/launchdarkly_api/models/rule.rb +11 -1
  78. data/lib/launchdarkly_api/models/trust_policy_details.rb +233 -0
  79. data/lib/launchdarkly_api/models/trust_policy_statement.rb +255 -0
  80. data/lib/launchdarkly_api/version.rb +1 -1
  81. data/lib/launchdarkly_api.rb +11 -1
  82. data/spec/api/account_usage_beta_api_spec.rb +41 -0
  83. data/spec/api/ai_configs_beta_api_spec.rb +72 -0
  84. data/spec/api/data_export_destinations_api_spec.rb +13 -0
  85. data/spec/api/feature_flags_api_spec.rb +2 -1
  86. data/spec/api/metrics_api_spec.rb +2 -2
  87. data/spec/api/scheduled_changes_api_spec.rb +1 -1
  88. data/spec/api/segments_api_spec.rb +2 -1
  89. data/spec/api/tags_api_spec.rb +1 -1
  90. data/spec/models/agent_graph_edge_post_spec.rb +54 -0
  91. data/spec/models/agent_graph_edge_spec.rb +54 -0
  92. data/spec/models/agent_graph_patch_spec.rb +54 -0
  93. data/spec/models/agent_graph_post_spec.rb +60 -0
  94. data/spec/models/agent_graph_spec.rb +72 -0
  95. data/spec/models/{covariance_info_rep_spec.rb → agent_graphs_spec.rb} +9 -9
  96. data/spec/models/ai_config_post_spec.rb +6 -0
  97. data/spec/models/ai_config_spec.rb +6 -0
  98. data/spec/models/destination_post_spec.rb +1 -1
  99. data/spec/models/destination_spec.rb +1 -1
  100. data/spec/models/generate_trust_policy_post_rep_spec.rb +36 -0
  101. data/spec/models/guarded_release_config_spec.rb +24 -0
  102. data/spec/models/iteration_input_spec.rb +0 -6
  103. data/spec/models/iteration_rep_spec.rb +4 -6
  104. data/spec/models/metric_group_rep_spec.rb +0 -12
  105. data/spec/models/metrics_spec.rb +18 -0
  106. data/spec/models/naming_convention_spec.rb +1 -1
  107. data/spec/models/progressive_release_config_spec.rb +42 -0
  108. data/spec/models/release_policy_scope_spec.rb +6 -0
  109. data/spec/models/release_policy_stage_spec.rb +42 -0
  110. data/spec/models/rule_spec.rb +6 -0
  111. data/spec/models/trust_policy_details_spec.rb +42 -0
  112. data/spec/models/trust_policy_statement_spec.rb +54 -0
  113. metadata +46 -6
  114. data/docs/CovarianceInfoRep.md +0 -22
@@ -1141,12 +1141,13 @@ module LaunchDarklyApi
1141
1141
  end
1142
1142
 
1143
1143
  # Patch segment
1144
- # Update a segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. To learn more the different formats, read [Updates](https://launchdarkly.com/docs/api#updates). ### Using semantic patches on a segment To make a semantic patch request, you must append `domain-model=launchdarkly.semanticpatch` to your `Content-Type` header. To learn more, read [Updates using semantic patch](https://launchdarkly.com/docs/api#updates-using-semantic-patch). The body of a semantic patch request for updating segments requires an `environmentKey` in addition to `instructions` and an optional `comment`. The body of the request takes the following properties: * `comment` (string): (Optional) A description of the update. * `environmentKey` (string): (Required) The key of the LaunchDarkly environment. * `instructions` (array): (Required) A list of actions the update should perform. Each action in the list must be an object with a `kind` property that indicates the instruction. If the action requires parameters, you must include those parameters as additional fields in the object. ### Instructions Semantic patch requests support the following `kind` instructions for updating segments. <details> <summary>Click to expand instructions for <strong>updating segment details and settings</strong></summary> #### addTags Adds tags to the segment. ##### Parameters - `values`: A list of tags to add. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addTags\", \"values\": [\"tag1\", \"tag2\"] }] } ``` #### removeTags Removes tags from the segment. ##### Parameters - `values`: A list of tags to remove. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeTags\", \"values\": [\"tag1\", \"tag2\"] }] } ``` #### updateName Updates the name of the segment. ##### Parameters - `value`: Name of the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"updateName\", \"value\": \"Updated segment name\" }] } ``` </details> <details> <summary>Click to expand instructions for <strong>updating segment individual targets</strong></summary> #### addExcludedTargets Adds context keys to the individual context targets excluded from the segment for the specified `contextKind`. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - `contextKind`: The context kind the targets should be added to. - `values`: List of keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addExcludedTargets\", \"contextKind\": \"org\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### addExcludedUsers Adds user keys to the individual user targets excluded from the segment. Returns an error if this causes the same user key to be both included and excluded. If you are working with contexts, use `addExcludedTargets` instead of this instruction. ##### Parameters - `values`: List of user keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addExcludedUsers\", \"values\": [ \"user-key-123abc\", \"user-key-456def\" ] }] } ``` #### addIncludedTargets Adds context keys to the individual context targets included in the segment for the specified `contextKind`. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - `contextKind`: The context kind the targets should be added to. - `values`: List of keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addIncludedTargets\", \"contextKind\": \"org\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### addIncludedUsers Adds user keys to the individual user targets included in the segment. Returns an error if this causes the same user key to be both included and excluded. If you are working with contexts, use `addIncludedTargets` instead of this instruction. ##### Parameters - `values`: List of user keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addIncludedUsers\", \"values\": [ \"user-key-123abc\", \"user-key-456def\" ] }] } ``` #### removeExcludedTargets Removes context keys from the individual context targets excluded from the segment for the specified `contextKind`. ##### Parameters - `contextKind`: The context kind the targets should be removed from. - `values`: List of keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeExcludedTargets\", \"contextKind\": \"org\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### removeExcludedUsers Removes user keys from the individual user targets excluded from the segment. If you are working with contexts, use `removeExcludedTargets` instead of this instruction. ##### Parameters - `values`: List of user keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeExcludedUsers\", \"values\": [ \"user-key-123abc\", \"user-key-456def\" ] }] } ``` #### removeIncludedTargets Removes context keys from the individual context targets included in the segment for the specified `contextKind`. ##### Parameters - `contextKind`: The context kind the targets should be removed from. - `values`: List of keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeIncludedTargets\", \"contextKind\": \"org\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### removeIncludedUsers Removes user keys from the individual user targets included in the segment. If you are working with contexts, use `removeIncludedTargets` instead of this instruction. ##### Parameters - `values`: List of user keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeIncludedUsers\", \"values\": [ \"user-key-123abc\", \"user-key-456def\" ] }] } ``` </details> <details> <summary>Click to expand instructions for <strong>updating segment targeting rules</strong></summary> #### addClauses Adds the given clauses to the rule indicated by `ruleId`. ##### Parameters - `clauses`: Array of clause objects, with `contextKind` (string), `attribute` (string), `op` (string), `negate` (boolean), and `values` (array of strings, numbers, or dates) properties. The `contextKind`, if not provided, defaults to `user`. The `contextKind`, `attribute`, and `values` are case sensitive. The `op` must be lower-case. - `ruleId`: ID of a rule in the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addClauses\", \"clauses\": [ { \"attribute\": \"email\", \"negate\": false, \"op\": \"contains\", \"values\": [\"value1\"] } ], \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", }] } ``` #### addRule Adds a new targeting rule to the segment. The rule may contain `clauses`. ##### Parameters - `clauses`: Array of clause objects, with `contextKind` (string), `attribute` (string), `op` (string), `negate` (boolean), and `values` (array of strings, numbers, or dates) properties. The `contextKind`, if not provided, defaults to `user`. The `contextKind`, `attribute`, and `values` are case sensitive. The `op` must be lower-case. - `description`: A description of the rule. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addRule\", \"clauses\": [ { \"attribute\": \"email\", \"op\": \"contains\", \"negate\": false, \"values\": [\"@launchdarkly.com\"] } ], \"description\": \"Targeting rule for LaunchDarkly employees\", }] } ``` #### addValuesToClause Adds `values` to the values of the clause that `ruleId` and `clauseId` indicate. Does not update the context kind, attribute, or operator. ##### Parameters - `ruleId`: ID of a rule in the segment. - `clauseId`: ID of a clause in that rule. - `values`: Array of strings, case sensitive. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addValuesToClause\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"clauseId\": \"10a58772-3121-400f-846b-b8a04e8944ed\", \"values\": [\"beta_testers\"] }] } ``` #### removeClauses Removes the clauses specified by `clauseIds` from the rule indicated by `ruleId`. ##### Parameters - `ruleId`: ID of a rule in the segment. - `clauseIds`: Array of IDs of clauses in the rule. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeClauses\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"clauseIds\": [\"10a58772-3121-400f-846b-b8a04e8944ed\", \"36a461dc-235e-4b08-97b9-73ce9365873e\"] }] } ``` #### removeRule Removes the targeting rule specified by `ruleId`. Does nothing if the rule does not exist. ##### Parameters - `ruleId`: ID of a rule in the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeRule\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\" }] } ``` #### removeValuesFromClause Removes `values` from the values of the clause indicated by `ruleId` and `clauseId`. Does not update the context kind, attribute, or operator. ##### Parameters - `ruleId`: ID of a rule in the segment. - `clauseId`: ID of a clause in that rule. - `values`: Array of strings, case sensitive. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeValuesFromClause\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"clauseId\": \"10a58772-3121-400f-846b-b8a04e8944ed\", \"values\": [\"beta_testers\"] }] } ``` #### reorderRules Rearranges the rules to match the order given in `ruleIds`. Returns an error if `ruleIds` does not match the current set of rules in the segment. ##### Parameters - `ruleIds`: Array of IDs of all targeting rules in the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"reorderRules\", \"ruleIds\": [\"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"63c238d1-835d-435e-8f21-c8d5e40b2a3d\"] }] } ``` #### updateClause Replaces the clause indicated by `ruleId` and `clauseId` with `clause`. ##### Parameters - `ruleId`: ID of a rule in the segment. - `clauseId`: ID of a clause in that rule. - `clause`: New `clause` object, with `contextKind` (string), `attribute` (string), `op` (string), `negate` (boolean), and `values` (array of strings, numbers, or dates) properties. The `contextKind`, if not provided, defaults to `user`. The `contextKind`, `attribute`, and `values` are case sensitive. The `op` must be lower-case. Here's an example: ```json { \"instructions\": [{ \"kind\": \"updateClause\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"clauseId\": \"10c7462a-2062-45ba-a8bb-dfb3de0f8af5\", \"clause\": { \"contextKind\": \"user\", \"attribute\": \"country\", \"op\": \"in\", \"negate\": false, \"values\": [\"Mexico\", \"Canada\"] } }] } ``` #### updateRuleDescription Updates the description of the segment targeting rule. ##### Parameters - `description`: The new human-readable description for this rule. - `ruleId`: The ID of the rule. You can retrieve this by making a GET request for the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"updateRuleDescription\", \"description\": \"New rule description\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\" }] } ``` #### updateRuleRolloutAndContextKind For a rule that includes a percentage of targets, updates the percentage and the context kind of the targets to include. ##### Parameters - `ruleId`: The ID of a targeting rule in the segment that includes a percentage of targets. - `weight`: The weight, in thousandths of a percent (0-100000). - `contextKind`: The context kind. Here's an example: ```json { \"instructions\": [{ \"kind\": \"reorderRules\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"weight\": \"20000\", \"contextKind\": \"device\" }] } ``` </details> <details> <summary>Click to expand instructions for <strong>working with Big Segments</strong></summary> A \"big segment\" is a segment that is either a synced segment, or a list-based segment with more than 15,000 entries that includes only one targeted context kind. LaunchDarkly uses different implementations for different types of segments so that all of your segments have good performance. The following semantic patch instructions apply only to these [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments). #### addBigSegmentExcludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Adds context keys to the context targets excluded from the segment. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - `values`: List of context keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addBigSegmentExcludedTargets\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### addBigSegmentIncludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Adds context keys to the context targets included in the segment. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - `values`: List of context keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addBigSegmentIncludedTargets\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### processBigSegmentImport For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Processes a segment import. ##### Parameters - `importId`: The ID of the import. The import ID is returned in the `Location` header as part of the [Create big segment import](https://launchdarkly.com/docs/api/segments/create-big-segment-import) request. Here's an example: ```json { \"instructions\": [{ \"kind\": \"processBigSegmentImport\", \"importId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\" }] } ``` #### removeBigSegmentExcludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Removes context keys from the context targets excluded from the segment. ##### Parameters - `values`: List of context keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeBigSegmentExcludedTargets\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### removeBigSegmentIncludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Removes context keys from the context targets included in the segment. ##### Parameters - `values`: List of context keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeBigSegmentIncludedTargets\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` </details> ### Using JSON patches on a segment If you do not include the header described above, you can use a [JSON patch](https://launchdarkly.com/docs/api#updates-using-json-patch) or [JSON merge patch](https://datatracker.ietf.org/doc/html/rfc7386) representation of the desired changes. For example, to update the description for a segment with a JSON patch, use the following request body: ```json { \"patch\": [ { \"op\": \"replace\", \"path\": \"/description\", \"value\": \"new description\" } ] } ``` To update fields in the segment that are arrays, set the `path` to the name of the field and then append `/<array index>`. Use `/0` to add the new entry to the beginning of the array. Use `/-` to add the new entry to the end of the array. For example, to add a rule to a segment, use the following request body: ```json { \"patch\":[ { \"op\": \"add\", \"path\": \"/rules/0\", \"value\": { \"clauses\": [{ \"contextKind\": \"user\", \"attribute\": \"email\", \"op\": \"endsWith\", \"values\": [\".edu\"], \"negate\": false }] } } ] } ``` To add or remove targets from segments, we recommend using semantic patch. Semantic patch for segments includes specific instructions for adding and removing both included and excluded targets.
1144
+ # Update a segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. To learn more the different formats, read [Updates](https://launchdarkly.com/docs/api#updates). ### Using semantic patches on a segment To make a semantic patch request, you must append `domain-model=launchdarkly.semanticpatch` to your `Content-Type` header. To learn more, read [Updates using semantic patch](https://launchdarkly.com/docs/api#updates-using-semantic-patch). The body of a semantic patch request for updating segments requires an `environmentKey` in addition to `instructions` and an optional `comment`. The body of the request takes the following properties: * `comment` (string): (Optional) A description of the update. * `environmentKey` (string): (Required) The key of the LaunchDarkly environment. * `instructions` (array): (Required) A list of actions the update should perform. Each action in the list must be an object with a `kind` property that indicates the instruction. If the action requires parameters, you must include those parameters as additional fields in the object. ### Instructions Semantic patch requests support the following `kind` instructions for updating segments. <details> <summary>Click to expand instructions for <strong>updating segment details and settings</strong></summary> #### addTags Adds tags to the segment. ##### Parameters - `values`: A list of tags to add. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addTags\", \"values\": [\"tag1\", \"tag2\"] }] } ``` #### removeTags Removes tags from the segment. ##### Parameters - `values`: A list of tags to remove. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeTags\", \"values\": [\"tag1\", \"tag2\"] }] } ``` #### updateName Updates the name of the segment. ##### Parameters - `value`: Name of the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"updateName\", \"value\": \"Updated segment name\" }] } ``` </details> <details> <summary>Click to expand instructions for <strong>updating segment individual targets</strong></summary> #### addExcludedTargets Adds context keys to the individual context targets excluded from the segment for the specified `contextKind`. Returns an error if this causes the same context key to be both included and excluded, or if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - `contextKind`: The context kind the targets should be added to. - `values`: List of keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addExcludedTargets\", \"contextKind\": \"org\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### addExcludedUsers Adds user keys to the individual user targets excluded from the segment. Returns an error if this causes the same user key to be both included and excluded, or if the number of operations on targets exceeds the batch limit of 1,500. If you are working with contexts, use `addExcludedTargets` instead of this instruction. ##### Parameters - `values`: List of user keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addExcludedUsers\", \"values\": [ \"user-key-123abc\", \"user-key-456def\" ] }] } ``` #### addIncludedTargets Adds context keys to the individual context targets included in the segment for the specified `contextKind`. Returns an error if this causes the same context key to be both included and excluded, or if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - `contextKind`: The context kind the targets should be added to. - `values`: List of keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addIncludedTargets\", \"contextKind\": \"org\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### addIncludedUsers Adds user keys to the individual user targets included in the segment. Returns an error if this causes the same user key to be both included and excluded, or if the number of operations on targets exceeds the batch limit of 1,500. If you are working with contexts, use `addIncludedTargets` instead of this instruction. ##### Parameters - `values`: List of user keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addIncludedUsers\", \"values\": [ \"user-key-123abc\", \"user-key-456def\" ] }] } ``` #### removeExcludedTargets Removes context keys from the individual context targets excluded from the segment for the specified `contextKind`. Returns an error if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - `contextKind`: The context kind the targets should be removed from. - `values`: List of keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeExcludedTargets\", \"contextKind\": \"org\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### removeExcludedUsers Removes user keys from the individual user targets excluded from the segment. If you are working with contexts, use `removeExcludedTargets` instead of this instruction. Returns an error if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - `values`: List of user keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeExcludedUsers\", \"values\": [ \"user-key-123abc\", \"user-key-456def\" ] }] } ``` #### removeIncludedTargets Removes context keys from the individual context targets included in the segment for the specified `contextKind`. Returns an error if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - `contextKind`: The context kind the targets should be removed from. - `values`: List of keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeIncludedTargets\", \"contextKind\": \"org\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### removeIncludedUsers Removes user keys from the individual user targets included in the segment. If you are working with contexts, use `removeIncludedTargets` instead of this instruction. Returns an error if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - `values`: List of user keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeIncludedUsers\", \"values\": [ \"user-key-123abc\", \"user-key-456def\" ] }] } ``` </details> <details> <summary>Click to expand instructions for <strong>updating segment targeting rules</strong></summary> #### addClauses Adds the given clauses to the rule indicated by `ruleId`. ##### Parameters - `clauses`: Array of clause objects, with `contextKind` (string), `attribute` (string), `op` (string), `negate` (boolean), and `values` (array of strings, numbers, or dates) properties. The `contextKind`, if not provided, defaults to `user`. The `contextKind`, `attribute`, and `values` are case sensitive. The `op` must be lower-case. - `ruleId`: ID of a rule in the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addClauses\", \"clauses\": [ { \"attribute\": \"email\", \"negate\": false, \"op\": \"contains\", \"values\": [\"value1\"] } ], \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", }] } ``` #### addRule Adds a new targeting rule to the segment. The rule may contain `clauses`. ##### Parameters - `clauses`: Array of clause objects, with `contextKind` (string), `attribute` (string), `op` (string), `negate` (boolean), and `values` (array of strings, numbers, or dates) properties. The `contextKind`, if not provided, defaults to `user`. The `contextKind`, `attribute`, and `values` are case sensitive. The `op` must be lower-case. - `description`: A description of the rule. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addRule\", \"clauses\": [ { \"attribute\": \"email\", \"op\": \"contains\", \"negate\": false, \"values\": [\"@launchdarkly.com\"] } ], \"description\": \"Targeting rule for LaunchDarkly employees\", }] } ``` #### addValuesToClause Adds `values` to the values of the clause that `ruleId` and `clauseId` indicate. Does not update the context kind, attribute, or operator. ##### Parameters - `ruleId`: ID of a rule in the segment. - `clauseId`: ID of a clause in that rule. - `values`: Array of strings, case sensitive. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addValuesToClause\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"clauseId\": \"10a58772-3121-400f-846b-b8a04e8944ed\", \"values\": [\"beta_testers\"] }] } ``` #### removeClauses Removes the clauses specified by `clauseIds` from the rule indicated by `ruleId`. ##### Parameters - `ruleId`: ID of a rule in the segment. - `clauseIds`: Array of IDs of clauses in the rule. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeClauses\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"clauseIds\": [\"10a58772-3121-400f-846b-b8a04e8944ed\", \"36a461dc-235e-4b08-97b9-73ce9365873e\"] }] } ``` #### removeRule Removes the targeting rule specified by `ruleId`. Does nothing if the rule does not exist. ##### Parameters - `ruleId`: ID of a rule in the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeRule\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\" }] } ``` #### removeValuesFromClause Removes `values` from the values of the clause indicated by `ruleId` and `clauseId`. Does not update the context kind, attribute, or operator. ##### Parameters - `ruleId`: ID of a rule in the segment. - `clauseId`: ID of a clause in that rule. - `values`: Array of strings, case sensitive. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeValuesFromClause\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"clauseId\": \"10a58772-3121-400f-846b-b8a04e8944ed\", \"values\": [\"beta_testers\"] }] } ``` #### reorderRules Rearranges the rules to match the order given in `ruleIds`. Returns an error if `ruleIds` does not match the current set of rules in the segment. ##### Parameters - `ruleIds`: Array of IDs of all targeting rules in the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"reorderRules\", \"ruleIds\": [\"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"63c238d1-835d-435e-8f21-c8d5e40b2a3d\"] }] } ``` #### updateClause Replaces the clause indicated by `ruleId` and `clauseId` with `clause`. ##### Parameters - `ruleId`: ID of a rule in the segment. - `clauseId`: ID of a clause in that rule. - `clause`: New `clause` object, with `contextKind` (string), `attribute` (string), `op` (string), `negate` (boolean), and `values` (array of strings, numbers, or dates) properties. The `contextKind`, if not provided, defaults to `user`. The `contextKind`, `attribute`, and `values` are case sensitive. The `op` must be lower-case. Here's an example: ```json { \"instructions\": [{ \"kind\": \"updateClause\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"clauseId\": \"10c7462a-2062-45ba-a8bb-dfb3de0f8af5\", \"clause\": { \"contextKind\": \"user\", \"attribute\": \"country\", \"op\": \"in\", \"negate\": false, \"values\": [\"Mexico\", \"Canada\"] } }] } ``` #### updateRuleDescription Updates the description of the segment targeting rule. ##### Parameters - `description`: The new human-readable description for this rule. - `ruleId`: The ID of the rule. You can retrieve this by making a GET request for the segment. Here's an example: ```json { \"instructions\": [{ \"kind\": \"updateRuleDescription\", \"description\": \"New rule description\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\" }] } ``` #### updateRuleRolloutAndContextKind For a rule that includes a percentage of targets, updates the percentage and the context kind of the targets to include. ##### Parameters - `ruleId`: The ID of a targeting rule in the segment that includes a percentage of targets. - `weight`: The weight, in thousandths of a percent (0-100000). - `contextKind`: The context kind. Here's an example: ```json { \"instructions\": [{ \"kind\": \"reorderRules\", \"ruleId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\", \"weight\": \"20000\", \"contextKind\": \"device\" }] } ``` </details> <details> <summary>Click to expand instructions for <strong>working with Big Segments</strong></summary> A \"big segment\" is a segment that is either a synced segment, or a list-based segment with more than 15,000 entries that includes only one targeted context kind. LaunchDarkly uses different implementations for different types of segments so that all of your segments have good performance. The following semantic patch instructions apply only to these [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments). #### addBigSegmentExcludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Adds context keys to the context targets excluded from the segment. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - `values`: List of context keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addBigSegmentExcludedTargets\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### addBigSegmentIncludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Adds context keys to the context targets included in the segment. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - `values`: List of context keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"addBigSegmentIncludedTargets\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### processBigSegmentImport For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Processes a segment import. ##### Parameters - `importId`: The ID of the import. The import ID is returned in the `Location` header as part of the [Create big segment import](https://launchdarkly.com/docs/api/segments/create-big-segment-import) request. Here's an example: ```json { \"instructions\": [{ \"kind\": \"processBigSegmentImport\", \"importId\": \"a902ef4a-2faf-4eaf-88e1-ecc356708a29\" }] } ``` #### removeBigSegmentExcludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Removes context keys from the context targets excluded from the segment. ##### Parameters - `values`: List of context keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeBigSegmentExcludedTargets\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` #### removeBigSegmentIncludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Removes context keys from the context targets included in the segment. ##### Parameters - `values`: List of context keys. Here's an example: ```json { \"instructions\": [{ \"kind\": \"removeBigSegmentIncludedTargets\", \"values\": [ \"org-key-123abc\", \"org-key-456def\" ] }] } ``` </details> ### Using JSON patches on a segment If you do not include the header described above, you can use a [JSON patch](https://launchdarkly.com/docs/api#updates-using-json-patch) or [JSON merge patch](https://datatracker.ietf.org/doc/html/rfc7386) representation of the desired changes. For example, to update the description for a segment with a JSON patch, use the following request body: ```json { \"patch\": [ { \"op\": \"replace\", \"path\": \"/description\", \"value\": \"new description\" } ] } ``` To update fields in the segment that are arrays, set the `path` to the name of the field and then append `/<array index>`. Use `/0` to add the new entry to the beginning of the array. Use `/-` to add the new entry to the end of the array. For example, to add a rule to a segment, use the following request body: ```json { \"patch\":[ { \"op\": \"add\", \"path\": \"/rules/0\", \"value\": { \"clauses\": [{ \"contextKind\": \"user\", \"attribute\": \"email\", \"op\": \"endsWith\", \"values\": [\".edu\"], \"negate\": false }] } } ] } ``` To add or remove targets from segments, we recommend using semantic patch. Semantic patch for segments includes specific instructions for adding and removing both included and excluded targets.
1145
1145
  # @param project_key [String] The project key
1146
1146
  # @param environment_key [String] The environment key
1147
1147
  # @param segment_key [String] The segment key
1148
1148
  # @param patch_with_comment [PatchWithComment]
1149
1149
  # @param [Hash] opts the optional parameters
1150
+ # @option opts [Boolean] :dry_run If true, the patch will be validated but not persisted. Returns a preview of the segment after the patch is applied.
1150
1151
  # @return [UserSegment]
1151
1152
  def patch_segment(project_key, environment_key, segment_key, patch_with_comment, opts = {})
1152
1153
  data, _status_code, _headers = patch_segment_with_http_info(project_key, environment_key, segment_key, patch_with_comment, opts)
@@ -1154,12 +1155,13 @@ module LaunchDarklyApi
1154
1155
  end
1155
1156
 
1156
1157
  # Patch segment
1157
- # Update a segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. To learn more the different formats, read [Updates](https://launchdarkly.com/docs/api#updates). ### Using semantic patches on a segment To make a semantic patch request, you must append &#x60;domain-model&#x3D;launchdarkly.semanticpatch&#x60; to your &#x60;Content-Type&#x60; header. To learn more, read [Updates using semantic patch](https://launchdarkly.com/docs/api#updates-using-semantic-patch). The body of a semantic patch request for updating segments requires an &#x60;environmentKey&#x60; in addition to &#x60;instructions&#x60; and an optional &#x60;comment&#x60;. The body of the request takes the following properties: * &#x60;comment&#x60; (string): (Optional) A description of the update. * &#x60;environmentKey&#x60; (string): (Required) The key of the LaunchDarkly environment. * &#x60;instructions&#x60; (array): (Required) A list of actions the update should perform. Each action in the list must be an object with a &#x60;kind&#x60; property that indicates the instruction. If the action requires parameters, you must include those parameters as additional fields in the object. ### Instructions Semantic patch requests support the following &#x60;kind&#x60; instructions for updating segments. &lt;details&gt; &lt;summary&gt;Click to expand instructions for &lt;strong&gt;updating segment details and settings&lt;/strong&gt;&lt;/summary&gt; #### addTags Adds tags to the segment. ##### Parameters - &#x60;values&#x60;: A list of tags to add. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addTags\&quot;, \&quot;values\&quot;: [\&quot;tag1\&quot;, \&quot;tag2\&quot;] }] } &#x60;&#x60;&#x60; #### removeTags Removes tags from the segment. ##### Parameters - &#x60;values&#x60;: A list of tags to remove. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeTags\&quot;, \&quot;values\&quot;: [\&quot;tag1\&quot;, \&quot;tag2\&quot;] }] } &#x60;&#x60;&#x60; #### updateName Updates the name of the segment. ##### Parameters - &#x60;value&#x60;: Name of the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;updateName\&quot;, \&quot;value\&quot;: \&quot;Updated segment name\&quot; }] } &#x60;&#x60;&#x60; &lt;/details&gt; &lt;details&gt; &lt;summary&gt;Click to expand instructions for &lt;strong&gt;updating segment individual targets&lt;/strong&gt;&lt;/summary&gt; #### addExcludedTargets Adds context keys to the individual context targets excluded from the segment for the specified &#x60;contextKind&#x60;. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - &#x60;contextKind&#x60;: The context kind the targets should be added to. - &#x60;values&#x60;: List of keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addExcludedTargets\&quot;, \&quot;contextKind\&quot;: \&quot;org\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### addExcludedUsers Adds user keys to the individual user targets excluded from the segment. Returns an error if this causes the same user key to be both included and excluded. If you are working with contexts, use &#x60;addExcludedTargets&#x60; instead of this instruction. ##### Parameters - &#x60;values&#x60;: List of user keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addExcludedUsers\&quot;, \&quot;values\&quot;: [ \&quot;user-key-123abc\&quot;, \&quot;user-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### addIncludedTargets Adds context keys to the individual context targets included in the segment for the specified &#x60;contextKind&#x60;. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - &#x60;contextKind&#x60;: The context kind the targets should be added to. - &#x60;values&#x60;: List of keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addIncludedTargets\&quot;, \&quot;contextKind\&quot;: \&quot;org\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### addIncludedUsers Adds user keys to the individual user targets included in the segment. Returns an error if this causes the same user key to be both included and excluded. If you are working with contexts, use &#x60;addIncludedTargets&#x60; instead of this instruction. ##### Parameters - &#x60;values&#x60;: List of user keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addIncludedUsers\&quot;, \&quot;values\&quot;: [ \&quot;user-key-123abc\&quot;, \&quot;user-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeExcludedTargets Removes context keys from the individual context targets excluded from the segment for the specified &#x60;contextKind&#x60;. ##### Parameters - &#x60;contextKind&#x60;: The context kind the targets should be removed from. - &#x60;values&#x60;: List of keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeExcludedTargets\&quot;, \&quot;contextKind\&quot;: \&quot;org\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeExcludedUsers Removes user keys from the individual user targets excluded from the segment. If you are working with contexts, use &#x60;removeExcludedTargets&#x60; instead of this instruction. ##### Parameters - &#x60;values&#x60;: List of user keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeExcludedUsers\&quot;, \&quot;values\&quot;: [ \&quot;user-key-123abc\&quot;, \&quot;user-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeIncludedTargets Removes context keys from the individual context targets included in the segment for the specified &#x60;contextKind&#x60;. ##### Parameters - &#x60;contextKind&#x60;: The context kind the targets should be removed from. - &#x60;values&#x60;: List of keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeIncludedTargets\&quot;, \&quot;contextKind\&quot;: \&quot;org\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeIncludedUsers Removes user keys from the individual user targets included in the segment. If you are working with contexts, use &#x60;removeIncludedTargets&#x60; instead of this instruction. ##### Parameters - &#x60;values&#x60;: List of user keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeIncludedUsers\&quot;, \&quot;values\&quot;: [ \&quot;user-key-123abc\&quot;, \&quot;user-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; &lt;/details&gt; &lt;details&gt; &lt;summary&gt;Click to expand instructions for &lt;strong&gt;updating segment targeting rules&lt;/strong&gt;&lt;/summary&gt; #### addClauses Adds the given clauses to the rule indicated by &#x60;ruleId&#x60;. ##### Parameters - &#x60;clauses&#x60;: Array of clause objects, with &#x60;contextKind&#x60; (string), &#x60;attribute&#x60; (string), &#x60;op&#x60; (string), &#x60;negate&#x60; (boolean), and &#x60;values&#x60; (array of strings, numbers, or dates) properties. The &#x60;contextKind&#x60;, if not provided, defaults to &#x60;user&#x60;. The &#x60;contextKind&#x60;, &#x60;attribute&#x60;, and &#x60;values&#x60; are case sensitive. The &#x60;op&#x60; must be lower-case. - &#x60;ruleId&#x60;: ID of a rule in the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addClauses\&quot;, \&quot;clauses\&quot;: [ { \&quot;attribute\&quot;: \&quot;email\&quot;, \&quot;negate\&quot;: false, \&quot;op\&quot;: \&quot;contains\&quot;, \&quot;values\&quot;: [\&quot;value1\&quot;] } ], \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, }] } &#x60;&#x60;&#x60; #### addRule Adds a new targeting rule to the segment. The rule may contain &#x60;clauses&#x60;. ##### Parameters - &#x60;clauses&#x60;: Array of clause objects, with &#x60;contextKind&#x60; (string), &#x60;attribute&#x60; (string), &#x60;op&#x60; (string), &#x60;negate&#x60; (boolean), and &#x60;values&#x60; (array of strings, numbers, or dates) properties. The &#x60;contextKind&#x60;, if not provided, defaults to &#x60;user&#x60;. The &#x60;contextKind&#x60;, &#x60;attribute&#x60;, and &#x60;values&#x60; are case sensitive. The &#x60;op&#x60; must be lower-case. - &#x60;description&#x60;: A description of the rule. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addRule\&quot;, \&quot;clauses\&quot;: [ { \&quot;attribute\&quot;: \&quot;email\&quot;, \&quot;op\&quot;: \&quot;contains\&quot;, \&quot;negate\&quot;: false, \&quot;values\&quot;: [\&quot;@launchdarkly.com\&quot;] } ], \&quot;description\&quot;: \&quot;Targeting rule for LaunchDarkly employees\&quot;, }] } &#x60;&#x60;&#x60; #### addValuesToClause Adds &#x60;values&#x60; to the values of the clause that &#x60;ruleId&#x60; and &#x60;clauseId&#x60; indicate. Does not update the context kind, attribute, or operator. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. - &#x60;clauseId&#x60;: ID of a clause in that rule. - &#x60;values&#x60;: Array of strings, case sensitive. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addValuesToClause\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;clauseId\&quot;: \&quot;10a58772-3121-400f-846b-b8a04e8944ed\&quot;, \&quot;values\&quot;: [\&quot;beta_testers\&quot;] }] } &#x60;&#x60;&#x60; #### removeClauses Removes the clauses specified by &#x60;clauseIds&#x60; from the rule indicated by &#x60;ruleId&#x60;. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. - &#x60;clauseIds&#x60;: Array of IDs of clauses in the rule. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeClauses\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;clauseIds\&quot;: [\&quot;10a58772-3121-400f-846b-b8a04e8944ed\&quot;, \&quot;36a461dc-235e-4b08-97b9-73ce9365873e\&quot;] }] } &#x60;&#x60;&#x60; #### removeRule Removes the targeting rule specified by &#x60;ruleId&#x60;. Does nothing if the rule does not exist. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeRule\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot; }] } &#x60;&#x60;&#x60; #### removeValuesFromClause Removes &#x60;values&#x60; from the values of the clause indicated by &#x60;ruleId&#x60; and &#x60;clauseId&#x60;. Does not update the context kind, attribute, or operator. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. - &#x60;clauseId&#x60;: ID of a clause in that rule. - &#x60;values&#x60;: Array of strings, case sensitive. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeValuesFromClause\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;clauseId\&quot;: \&quot;10a58772-3121-400f-846b-b8a04e8944ed\&quot;, \&quot;values\&quot;: [\&quot;beta_testers\&quot;] }] } &#x60;&#x60;&#x60; #### reorderRules Rearranges the rules to match the order given in &#x60;ruleIds&#x60;. Returns an error if &#x60;ruleIds&#x60; does not match the current set of rules in the segment. ##### Parameters - &#x60;ruleIds&#x60;: Array of IDs of all targeting rules in the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;reorderRules\&quot;, \&quot;ruleIds\&quot;: [\&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;63c238d1-835d-435e-8f21-c8d5e40b2a3d\&quot;] }] } &#x60;&#x60;&#x60; #### updateClause Replaces the clause indicated by &#x60;ruleId&#x60; and &#x60;clauseId&#x60; with &#x60;clause&#x60;. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. - &#x60;clauseId&#x60;: ID of a clause in that rule. - &#x60;clause&#x60;: New &#x60;clause&#x60; object, with &#x60;contextKind&#x60; (string), &#x60;attribute&#x60; (string), &#x60;op&#x60; (string), &#x60;negate&#x60; (boolean), and &#x60;values&#x60; (array of strings, numbers, or dates) properties. The &#x60;contextKind&#x60;, if not provided, defaults to &#x60;user&#x60;. The &#x60;contextKind&#x60;, &#x60;attribute&#x60;, and &#x60;values&#x60; are case sensitive. The &#x60;op&#x60; must be lower-case. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;updateClause\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;clauseId\&quot;: \&quot;10c7462a-2062-45ba-a8bb-dfb3de0f8af5\&quot;, \&quot;clause\&quot;: { \&quot;contextKind\&quot;: \&quot;user\&quot;, \&quot;attribute\&quot;: \&quot;country\&quot;, \&quot;op\&quot;: \&quot;in\&quot;, \&quot;negate\&quot;: false, \&quot;values\&quot;: [\&quot;Mexico\&quot;, \&quot;Canada\&quot;] } }] } &#x60;&#x60;&#x60; #### updateRuleDescription Updates the description of the segment targeting rule. ##### Parameters - &#x60;description&#x60;: The new human-readable description for this rule. - &#x60;ruleId&#x60;: The ID of the rule. You can retrieve this by making a GET request for the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;updateRuleDescription\&quot;, \&quot;description\&quot;: \&quot;New rule description\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot; }] } &#x60;&#x60;&#x60; #### updateRuleRolloutAndContextKind For a rule that includes a percentage of targets, updates the percentage and the context kind of the targets to include. ##### Parameters - &#x60;ruleId&#x60;: The ID of a targeting rule in the segment that includes a percentage of targets. - &#x60;weight&#x60;: The weight, in thousandths of a percent (0-100000). - &#x60;contextKind&#x60;: The context kind. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;reorderRules\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;weight\&quot;: \&quot;20000\&quot;, \&quot;contextKind\&quot;: \&quot;device\&quot; }] } &#x60;&#x60;&#x60; &lt;/details&gt; &lt;details&gt; &lt;summary&gt;Click to expand instructions for &lt;strong&gt;working with Big Segments&lt;/strong&gt;&lt;/summary&gt; A \&quot;big segment\&quot; is a segment that is either a synced segment, or a list-based segment with more than 15,000 entries that includes only one targeted context kind. LaunchDarkly uses different implementations for different types of segments so that all of your segments have good performance. The following semantic patch instructions apply only to these [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments). #### addBigSegmentExcludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Adds context keys to the context targets excluded from the segment. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - &#x60;values&#x60;: List of context keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addBigSegmentExcludedTargets\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### addBigSegmentIncludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Adds context keys to the context targets included in the segment. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - &#x60;values&#x60;: List of context keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addBigSegmentIncludedTargets\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### processBigSegmentImport For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Processes a segment import. ##### Parameters - &#x60;importId&#x60;: The ID of the import. The import ID is returned in the &#x60;Location&#x60; header as part of the [Create big segment import](https://launchdarkly.com/docs/api/segments/create-big-segment-import) request. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;processBigSegmentImport\&quot;, \&quot;importId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot; }] } &#x60;&#x60;&#x60; #### removeBigSegmentExcludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Removes context keys from the context targets excluded from the segment. ##### Parameters - &#x60;values&#x60;: List of context keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeBigSegmentExcludedTargets\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeBigSegmentIncludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Removes context keys from the context targets included in the segment. ##### Parameters - &#x60;values&#x60;: List of context keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeBigSegmentIncludedTargets\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; &lt;/details&gt; ### Using JSON patches on a segment If you do not include the header described above, you can use a [JSON patch](https://launchdarkly.com/docs/api#updates-using-json-patch) or [JSON merge patch](https://datatracker.ietf.org/doc/html/rfc7386) representation of the desired changes. For example, to update the description for a segment with a JSON patch, use the following request body: &#x60;&#x60;&#x60;json { \&quot;patch\&quot;: [ { \&quot;op\&quot;: \&quot;replace\&quot;, \&quot;path\&quot;: \&quot;/description\&quot;, \&quot;value\&quot;: \&quot;new description\&quot; } ] } &#x60;&#x60;&#x60; To update fields in the segment that are arrays, set the &#x60;path&#x60; to the name of the field and then append &#x60;/&lt;array index&gt;&#x60;. Use &#x60;/0&#x60; to add the new entry to the beginning of the array. Use &#x60;/-&#x60; to add the new entry to the end of the array. For example, to add a rule to a segment, use the following request body: &#x60;&#x60;&#x60;json { \&quot;patch\&quot;:[ { \&quot;op\&quot;: \&quot;add\&quot;, \&quot;path\&quot;: \&quot;/rules/0\&quot;, \&quot;value\&quot;: { \&quot;clauses\&quot;: [{ \&quot;contextKind\&quot;: \&quot;user\&quot;, \&quot;attribute\&quot;: \&quot;email\&quot;, \&quot;op\&quot;: \&quot;endsWith\&quot;, \&quot;values\&quot;: [\&quot;.edu\&quot;], \&quot;negate\&quot;: false }] } } ] } &#x60;&#x60;&#x60; To add or remove targets from segments, we recommend using semantic patch. Semantic patch for segments includes specific instructions for adding and removing both included and excluded targets.
1158
+ # Update a segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. To learn more the different formats, read [Updates](https://launchdarkly.com/docs/api#updates). ### Using semantic patches on a segment To make a semantic patch request, you must append &#x60;domain-model&#x3D;launchdarkly.semanticpatch&#x60; to your &#x60;Content-Type&#x60; header. To learn more, read [Updates using semantic patch](https://launchdarkly.com/docs/api#updates-using-semantic-patch). The body of a semantic patch request for updating segments requires an &#x60;environmentKey&#x60; in addition to &#x60;instructions&#x60; and an optional &#x60;comment&#x60;. The body of the request takes the following properties: * &#x60;comment&#x60; (string): (Optional) A description of the update. * &#x60;environmentKey&#x60; (string): (Required) The key of the LaunchDarkly environment. * &#x60;instructions&#x60; (array): (Required) A list of actions the update should perform. Each action in the list must be an object with a &#x60;kind&#x60; property that indicates the instruction. If the action requires parameters, you must include those parameters as additional fields in the object. ### Instructions Semantic patch requests support the following &#x60;kind&#x60; instructions for updating segments. &lt;details&gt; &lt;summary&gt;Click to expand instructions for &lt;strong&gt;updating segment details and settings&lt;/strong&gt;&lt;/summary&gt; #### addTags Adds tags to the segment. ##### Parameters - &#x60;values&#x60;: A list of tags to add. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addTags\&quot;, \&quot;values\&quot;: [\&quot;tag1\&quot;, \&quot;tag2\&quot;] }] } &#x60;&#x60;&#x60; #### removeTags Removes tags from the segment. ##### Parameters - &#x60;values&#x60;: A list of tags to remove. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeTags\&quot;, \&quot;values\&quot;: [\&quot;tag1\&quot;, \&quot;tag2\&quot;] }] } &#x60;&#x60;&#x60; #### updateName Updates the name of the segment. ##### Parameters - &#x60;value&#x60;: Name of the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;updateName\&quot;, \&quot;value\&quot;: \&quot;Updated segment name\&quot; }] } &#x60;&#x60;&#x60; &lt;/details&gt; &lt;details&gt; &lt;summary&gt;Click to expand instructions for &lt;strong&gt;updating segment individual targets&lt;/strong&gt;&lt;/summary&gt; #### addExcludedTargets Adds context keys to the individual context targets excluded from the segment for the specified &#x60;contextKind&#x60;. Returns an error if this causes the same context key to be both included and excluded, or if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - &#x60;contextKind&#x60;: The context kind the targets should be added to. - &#x60;values&#x60;: List of keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addExcludedTargets\&quot;, \&quot;contextKind\&quot;: \&quot;org\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### addExcludedUsers Adds user keys to the individual user targets excluded from the segment. Returns an error if this causes the same user key to be both included and excluded, or if the number of operations on targets exceeds the batch limit of 1,500. If you are working with contexts, use &#x60;addExcludedTargets&#x60; instead of this instruction. ##### Parameters - &#x60;values&#x60;: List of user keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addExcludedUsers\&quot;, \&quot;values\&quot;: [ \&quot;user-key-123abc\&quot;, \&quot;user-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### addIncludedTargets Adds context keys to the individual context targets included in the segment for the specified &#x60;contextKind&#x60;. Returns an error if this causes the same context key to be both included and excluded, or if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - &#x60;contextKind&#x60;: The context kind the targets should be added to. - &#x60;values&#x60;: List of keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addIncludedTargets\&quot;, \&quot;contextKind\&quot;: \&quot;org\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### addIncludedUsers Adds user keys to the individual user targets included in the segment. Returns an error if this causes the same user key to be both included and excluded, or if the number of operations on targets exceeds the batch limit of 1,500. If you are working with contexts, use &#x60;addIncludedTargets&#x60; instead of this instruction. ##### Parameters - &#x60;values&#x60;: List of user keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addIncludedUsers\&quot;, \&quot;values\&quot;: [ \&quot;user-key-123abc\&quot;, \&quot;user-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeExcludedTargets Removes context keys from the individual context targets excluded from the segment for the specified &#x60;contextKind&#x60;. Returns an error if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - &#x60;contextKind&#x60;: The context kind the targets should be removed from. - &#x60;values&#x60;: List of keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeExcludedTargets\&quot;, \&quot;contextKind\&quot;: \&quot;org\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeExcludedUsers Removes user keys from the individual user targets excluded from the segment. If you are working with contexts, use &#x60;removeExcludedTargets&#x60; instead of this instruction. Returns an error if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - &#x60;values&#x60;: List of user keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeExcludedUsers\&quot;, \&quot;values\&quot;: [ \&quot;user-key-123abc\&quot;, \&quot;user-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeIncludedTargets Removes context keys from the individual context targets included in the segment for the specified &#x60;contextKind&#x60;. Returns an error if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - &#x60;contextKind&#x60;: The context kind the targets should be removed from. - &#x60;values&#x60;: List of keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeIncludedTargets\&quot;, \&quot;contextKind\&quot;: \&quot;org\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeIncludedUsers Removes user keys from the individual user targets included in the segment. If you are working with contexts, use &#x60;removeIncludedTargets&#x60; instead of this instruction. Returns an error if the number of operations on targets exceeds the batch limit of 1,500. ##### Parameters - &#x60;values&#x60;: List of user keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeIncludedUsers\&quot;, \&quot;values\&quot;: [ \&quot;user-key-123abc\&quot;, \&quot;user-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; &lt;/details&gt; &lt;details&gt; &lt;summary&gt;Click to expand instructions for &lt;strong&gt;updating segment targeting rules&lt;/strong&gt;&lt;/summary&gt; #### addClauses Adds the given clauses to the rule indicated by &#x60;ruleId&#x60;. ##### Parameters - &#x60;clauses&#x60;: Array of clause objects, with &#x60;contextKind&#x60; (string), &#x60;attribute&#x60; (string), &#x60;op&#x60; (string), &#x60;negate&#x60; (boolean), and &#x60;values&#x60; (array of strings, numbers, or dates) properties. The &#x60;contextKind&#x60;, if not provided, defaults to &#x60;user&#x60;. The &#x60;contextKind&#x60;, &#x60;attribute&#x60;, and &#x60;values&#x60; are case sensitive. The &#x60;op&#x60; must be lower-case. - &#x60;ruleId&#x60;: ID of a rule in the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addClauses\&quot;, \&quot;clauses\&quot;: [ { \&quot;attribute\&quot;: \&quot;email\&quot;, \&quot;negate\&quot;: false, \&quot;op\&quot;: \&quot;contains\&quot;, \&quot;values\&quot;: [\&quot;value1\&quot;] } ], \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, }] } &#x60;&#x60;&#x60; #### addRule Adds a new targeting rule to the segment. The rule may contain &#x60;clauses&#x60;. ##### Parameters - &#x60;clauses&#x60;: Array of clause objects, with &#x60;contextKind&#x60; (string), &#x60;attribute&#x60; (string), &#x60;op&#x60; (string), &#x60;negate&#x60; (boolean), and &#x60;values&#x60; (array of strings, numbers, or dates) properties. The &#x60;contextKind&#x60;, if not provided, defaults to &#x60;user&#x60;. The &#x60;contextKind&#x60;, &#x60;attribute&#x60;, and &#x60;values&#x60; are case sensitive. The &#x60;op&#x60; must be lower-case. - &#x60;description&#x60;: A description of the rule. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addRule\&quot;, \&quot;clauses\&quot;: [ { \&quot;attribute\&quot;: \&quot;email\&quot;, \&quot;op\&quot;: \&quot;contains\&quot;, \&quot;negate\&quot;: false, \&quot;values\&quot;: [\&quot;@launchdarkly.com\&quot;] } ], \&quot;description\&quot;: \&quot;Targeting rule for LaunchDarkly employees\&quot;, }] } &#x60;&#x60;&#x60; #### addValuesToClause Adds &#x60;values&#x60; to the values of the clause that &#x60;ruleId&#x60; and &#x60;clauseId&#x60; indicate. Does not update the context kind, attribute, or operator. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. - &#x60;clauseId&#x60;: ID of a clause in that rule. - &#x60;values&#x60;: Array of strings, case sensitive. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addValuesToClause\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;clauseId\&quot;: \&quot;10a58772-3121-400f-846b-b8a04e8944ed\&quot;, \&quot;values\&quot;: [\&quot;beta_testers\&quot;] }] } &#x60;&#x60;&#x60; #### removeClauses Removes the clauses specified by &#x60;clauseIds&#x60; from the rule indicated by &#x60;ruleId&#x60;. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. - &#x60;clauseIds&#x60;: Array of IDs of clauses in the rule. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeClauses\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;clauseIds\&quot;: [\&quot;10a58772-3121-400f-846b-b8a04e8944ed\&quot;, \&quot;36a461dc-235e-4b08-97b9-73ce9365873e\&quot;] }] } &#x60;&#x60;&#x60; #### removeRule Removes the targeting rule specified by &#x60;ruleId&#x60;. Does nothing if the rule does not exist. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeRule\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot; }] } &#x60;&#x60;&#x60; #### removeValuesFromClause Removes &#x60;values&#x60; from the values of the clause indicated by &#x60;ruleId&#x60; and &#x60;clauseId&#x60;. Does not update the context kind, attribute, or operator. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. - &#x60;clauseId&#x60;: ID of a clause in that rule. - &#x60;values&#x60;: Array of strings, case sensitive. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeValuesFromClause\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;clauseId\&quot;: \&quot;10a58772-3121-400f-846b-b8a04e8944ed\&quot;, \&quot;values\&quot;: [\&quot;beta_testers\&quot;] }] } &#x60;&#x60;&#x60; #### reorderRules Rearranges the rules to match the order given in &#x60;ruleIds&#x60;. Returns an error if &#x60;ruleIds&#x60; does not match the current set of rules in the segment. ##### Parameters - &#x60;ruleIds&#x60;: Array of IDs of all targeting rules in the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;reorderRules\&quot;, \&quot;ruleIds\&quot;: [\&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;63c238d1-835d-435e-8f21-c8d5e40b2a3d\&quot;] }] } &#x60;&#x60;&#x60; #### updateClause Replaces the clause indicated by &#x60;ruleId&#x60; and &#x60;clauseId&#x60; with &#x60;clause&#x60;. ##### Parameters - &#x60;ruleId&#x60;: ID of a rule in the segment. - &#x60;clauseId&#x60;: ID of a clause in that rule. - &#x60;clause&#x60;: New &#x60;clause&#x60; object, with &#x60;contextKind&#x60; (string), &#x60;attribute&#x60; (string), &#x60;op&#x60; (string), &#x60;negate&#x60; (boolean), and &#x60;values&#x60; (array of strings, numbers, or dates) properties. The &#x60;contextKind&#x60;, if not provided, defaults to &#x60;user&#x60;. The &#x60;contextKind&#x60;, &#x60;attribute&#x60;, and &#x60;values&#x60; are case sensitive. The &#x60;op&#x60; must be lower-case. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;updateClause\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;clauseId\&quot;: \&quot;10c7462a-2062-45ba-a8bb-dfb3de0f8af5\&quot;, \&quot;clause\&quot;: { \&quot;contextKind\&quot;: \&quot;user\&quot;, \&quot;attribute\&quot;: \&quot;country\&quot;, \&quot;op\&quot;: \&quot;in\&quot;, \&quot;negate\&quot;: false, \&quot;values\&quot;: [\&quot;Mexico\&quot;, \&quot;Canada\&quot;] } }] } &#x60;&#x60;&#x60; #### updateRuleDescription Updates the description of the segment targeting rule. ##### Parameters - &#x60;description&#x60;: The new human-readable description for this rule. - &#x60;ruleId&#x60;: The ID of the rule. You can retrieve this by making a GET request for the segment. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;updateRuleDescription\&quot;, \&quot;description\&quot;: \&quot;New rule description\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot; }] } &#x60;&#x60;&#x60; #### updateRuleRolloutAndContextKind For a rule that includes a percentage of targets, updates the percentage and the context kind of the targets to include. ##### Parameters - &#x60;ruleId&#x60;: The ID of a targeting rule in the segment that includes a percentage of targets. - &#x60;weight&#x60;: The weight, in thousandths of a percent (0-100000). - &#x60;contextKind&#x60;: The context kind. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;reorderRules\&quot;, \&quot;ruleId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot;, \&quot;weight\&quot;: \&quot;20000\&quot;, \&quot;contextKind\&quot;: \&quot;device\&quot; }] } &#x60;&#x60;&#x60; &lt;/details&gt; &lt;details&gt; &lt;summary&gt;Click to expand instructions for &lt;strong&gt;working with Big Segments&lt;/strong&gt;&lt;/summary&gt; A \&quot;big segment\&quot; is a segment that is either a synced segment, or a list-based segment with more than 15,000 entries that includes only one targeted context kind. LaunchDarkly uses different implementations for different types of segments so that all of your segments have good performance. The following semantic patch instructions apply only to these [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments). #### addBigSegmentExcludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Adds context keys to the context targets excluded from the segment. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - &#x60;values&#x60;: List of context keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addBigSegmentExcludedTargets\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### addBigSegmentIncludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Adds context keys to the context targets included in the segment. Returns an error if this causes the same context key to be both included and excluded. ##### Parameters - &#x60;values&#x60;: List of context keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;addBigSegmentIncludedTargets\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### processBigSegmentImport For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Processes a segment import. ##### Parameters - &#x60;importId&#x60;: The ID of the import. The import ID is returned in the &#x60;Location&#x60; header as part of the [Create big segment import](https://launchdarkly.com/docs/api/segments/create-big-segment-import) request. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;processBigSegmentImport\&quot;, \&quot;importId\&quot;: \&quot;a902ef4a-2faf-4eaf-88e1-ecc356708a29\&quot; }] } &#x60;&#x60;&#x60; #### removeBigSegmentExcludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Removes context keys from the context targets excluded from the segment. ##### Parameters - &#x60;values&#x60;: List of context keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeBigSegmentExcludedTargets\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; #### removeBigSegmentIncludedTargets For use with [larger list-based segments](https://launchdarkly.com/docs/home/flags/segments-create#create-larger-list-based-segments) ONLY. Removes context keys from the context targets included in the segment. ##### Parameters - &#x60;values&#x60;: List of context keys. Here&#39;s an example: &#x60;&#x60;&#x60;json { \&quot;instructions\&quot;: [{ \&quot;kind\&quot;: \&quot;removeBigSegmentIncludedTargets\&quot;, \&quot;values\&quot;: [ \&quot;org-key-123abc\&quot;, \&quot;org-key-456def\&quot; ] }] } &#x60;&#x60;&#x60; &lt;/details&gt; ### Using JSON patches on a segment If you do not include the header described above, you can use a [JSON patch](https://launchdarkly.com/docs/api#updates-using-json-patch) or [JSON merge patch](https://datatracker.ietf.org/doc/html/rfc7386) representation of the desired changes. For example, to update the description for a segment with a JSON patch, use the following request body: &#x60;&#x60;&#x60;json { \&quot;patch\&quot;: [ { \&quot;op\&quot;: \&quot;replace\&quot;, \&quot;path\&quot;: \&quot;/description\&quot;, \&quot;value\&quot;: \&quot;new description\&quot; } ] } &#x60;&#x60;&#x60; To update fields in the segment that are arrays, set the &#x60;path&#x60; to the name of the field and then append &#x60;/&lt;array index&gt;&#x60;. Use &#x60;/0&#x60; to add the new entry to the beginning of the array. Use &#x60;/-&#x60; to add the new entry to the end of the array. For example, to add a rule to a segment, use the following request body: &#x60;&#x60;&#x60;json { \&quot;patch\&quot;:[ { \&quot;op\&quot;: \&quot;add\&quot;, \&quot;path\&quot;: \&quot;/rules/0\&quot;, \&quot;value\&quot;: { \&quot;clauses\&quot;: [{ \&quot;contextKind\&quot;: \&quot;user\&quot;, \&quot;attribute\&quot;: \&quot;email\&quot;, \&quot;op\&quot;: \&quot;endsWith\&quot;, \&quot;values\&quot;: [\&quot;.edu\&quot;], \&quot;negate\&quot;: false }] } } ] } &#x60;&#x60;&#x60; To add or remove targets from segments, we recommend using semantic patch. Semantic patch for segments includes specific instructions for adding and removing both included and excluded targets.
1158
1159
  # @param project_key [String] The project key
1159
1160
  # @param environment_key [String] The environment key
1160
1161
  # @param segment_key [String] The segment key
1161
1162
  # @param patch_with_comment [PatchWithComment]
1162
1163
  # @param [Hash] opts the optional parameters
1164
+ # @option opts [Boolean] :dry_run If true, the patch will be validated but not persisted. Returns a preview of the segment after the patch is applied.
1163
1165
  # @return [Array<(UserSegment, Integer, Hash)>] UserSegment data, response status code and response headers
1164
1166
  def patch_segment_with_http_info(project_key, environment_key, segment_key, patch_with_comment, opts = {})
1165
1167
  if @api_client.config.debugging
@@ -1186,6 +1188,7 @@ module LaunchDarklyApi
1186
1188
 
1187
1189
  # query parameters
1188
1190
  query_params = opts[:query_params] || {}
1191
+ query_params[:'dryRun'] = opts[:'dry_run'] if !opts[:'dry_run'].nil?
1189
1192
 
1190
1193
  # header parameters
1191
1194
  header_params = opts[:header_params] || {}
@@ -22,7 +22,7 @@ module LaunchDarklyApi
22
22
  # List tags
23
23
  # Get a list of tags.
24
24
  # @param [Hash] opts the optional parameters
25
- # @option opts [Array<String>] :kind Fetch tags associated with the specified resource type. Options are &#x60;flag&#x60;, &#x60;project&#x60;, &#x60;environment&#x60;, &#x60;segment&#x60;, &#x60;metric&#x60;, &#x60;aiconfig&#x60;, and &#x60;view&#x60;. Returns all types by default.
25
+ # @option opts [Array<String>] :kind Fetch tags associated with the specified resource type. Options are &#x60;flag&#x60;, &#x60;project&#x60;, &#x60;environment&#x60;, &#x60;segment&#x60;, &#x60;metric&#x60;, &#x60;metric-data-source&#x60;, &#x60;aiconfig&#x60;, and &#x60;view&#x60;. Returns all types by default.
26
26
  # @option opts [String] :pre Return tags with the specified prefix
27
27
  # @option opts [Boolean] :archived Whether or not to return archived flags
28
28
  # @option opts [Integer] :limit The number of tags to return. Maximum is 1000.
@@ -37,7 +37,7 @@ module LaunchDarklyApi
37
37
  # List tags
38
38
  # Get a list of tags.
39
39
  # @param [Hash] opts the optional parameters
40
- # @option opts [Array<String>] :kind Fetch tags associated with the specified resource type. Options are &#x60;flag&#x60;, &#x60;project&#x60;, &#x60;environment&#x60;, &#x60;segment&#x60;, &#x60;metric&#x60;, &#x60;aiconfig&#x60;, and &#x60;view&#x60;. Returns all types by default.
40
+ # @option opts [Array<String>] :kind Fetch tags associated with the specified resource type. Options are &#x60;flag&#x60;, &#x60;project&#x60;, &#x60;environment&#x60;, &#x60;segment&#x60;, &#x60;metric&#x60;, &#x60;metric-data-source&#x60;, &#x60;aiconfig&#x60;, and &#x60;view&#x60;. Returns all types by default.
41
41
  # @option opts [String] :pre Return tags with the specified prefix
42
42
  # @option opts [Boolean] :archived Whether or not to return archived flags
43
43
  # @option opts [Integer] :limit The number of tags to return. Maximum is 1000.