Class SegmentsApi


  • public class SegmentsApi
    extends java.lang.Object
    • Constructor Detail

      • SegmentsApi

        public SegmentsApi()
      • SegmentsApi

        public SegmentsApi​(ApiClient apiClient)
    • Method Detail

      • getApiClient

        public ApiClient getApiClient()
      • setApiClient

        public void setApiClient​(ApiClient apiClient)
      • getHostIndex

        public int getHostIndex()
      • setHostIndex

        public void setHostIndex​(int hostIndex)
      • getCustomBaseUrl

        public java.lang.String getCustomBaseUrl()
      • setCustomBaseUrl

        public void setCustomBaseUrl​(java.lang.String customBaseUrl)
      • deleteSegmentCall

        public okhttp3.Call deleteSegmentCall​(java.lang.String projectKey,
                                              java.lang.String environmentKey,
                                              java.lang.String segmentKey,
                                              ApiCallback _callback)
                                       throws ApiException
        Build call for deleteSegment
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        _callback - Callback for upload/download progress
        Returns:
        Call to execute
        Throws:
        ApiException - If fail to serialize the request body object
      • deleteSegment

        public void deleteSegment​(java.lang.String projectKey,
                                  java.lang.String environmentKey,
                                  java.lang.String segmentKey)
                           throws ApiException
        Delete segment Delete a user segment.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • deleteSegmentWithHttpInfo

        public ApiResponse<java.lang.Void> deleteSegmentWithHttpInfo​(java.lang.String projectKey,
                                                                     java.lang.String environmentKey,
                                                                     java.lang.String segmentKey)
                                                              throws ApiException
        Delete segment Delete a user segment.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        Returns:
        ApiResponse<Void>
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • deleteSegmentAsync

        public okhttp3.Call deleteSegmentAsync​(java.lang.String projectKey,
                                               java.lang.String environmentKey,
                                               java.lang.String segmentKey,
                                               ApiCallback<java.lang.Void> _callback)
                                        throws ApiException
        Delete segment (asynchronously) Delete a user segment.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        _callback - The callback to be executed when the API call finishes
        Returns:
        The request call
        Throws:
        ApiException - If fail to process the API call, e.g. serializing the request body object
      • getExpiringUserTargetsForSegmentCall

        public okhttp3.Call getExpiringUserTargetsForSegmentCall​(java.lang.String projectKey,
                                                                 java.lang.String environmentKey,
                                                                 java.lang.String segmentKey,
                                                                 ApiCallback _callback)
                                                          throws ApiException
        Build call for getExpiringUserTargetsForSegment
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        _callback - Callback for upload/download progress
        Returns:
        Call to execute
        Throws:
        ApiException - If fail to serialize the request body object
      • getExpiringUserTargetsForSegment

        public ExpiringUserTargetGetResponse getExpiringUserTargetsForSegment​(java.lang.String projectKey,
                                                                              java.lang.String environmentKey,
                                                                              java.lang.String segmentKey)
                                                                       throws ApiException
        Get expiring user targets for segment Get a list of a segment's user targets that are scheduled for removal.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        Returns:
        ExpiringUserTargetGetResponse
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • getExpiringUserTargetsForSegmentWithHttpInfo

        public ApiResponse<ExpiringUserTargetGetResponse> getExpiringUserTargetsForSegmentWithHttpInfo​(java.lang.String projectKey,
                                                                                                       java.lang.String environmentKey,
                                                                                                       java.lang.String segmentKey)
                                                                                                throws ApiException
        Get expiring user targets for segment Get a list of a segment's user targets that are scheduled for removal.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        Returns:
        ApiResponse<ExpiringUserTargetGetResponse>
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • getExpiringUserTargetsForSegmentAsync

        public okhttp3.Call getExpiringUserTargetsForSegmentAsync​(java.lang.String projectKey,
                                                                  java.lang.String environmentKey,
                                                                  java.lang.String segmentKey,
                                                                  ApiCallback<ExpiringUserTargetGetResponse> _callback)
                                                           throws ApiException
        Get expiring user targets for segment (asynchronously) Get a list of a segment's user targets that are scheduled for removal.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        _callback - The callback to be executed when the API call finishes
        Returns:
        The request call
        Throws:
        ApiException - If fail to process the API call, e.g. serializing the request body object
      • getSegmentCall

        public okhttp3.Call getSegmentCall​(java.lang.String projectKey,
                                           java.lang.String environmentKey,
                                           java.lang.String segmentKey,
                                           ApiCallback _callback)
                                    throws ApiException
        Build call for getSegment
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        _callback - Callback for upload/download progress
        Returns:
        Call to execute
        Throws:
        ApiException - If fail to serialize the request body object
      • getSegment

        public UserSegment getSegment​(java.lang.String projectKey,
                                      java.lang.String environmentKey,
                                      java.lang.String segmentKey)
                               throws ApiException
        Get segment Get a single user segment by key.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        Returns:
        UserSegment
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • getSegmentWithHttpInfo

        public ApiResponse<UserSegment> getSegmentWithHttpInfo​(java.lang.String projectKey,
                                                               java.lang.String environmentKey,
                                                               java.lang.String segmentKey)
                                                        throws ApiException
        Get segment Get a single user segment by key.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        Returns:
        ApiResponse<UserSegment>
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • getSegmentAsync

        public okhttp3.Call getSegmentAsync​(java.lang.String projectKey,
                                            java.lang.String environmentKey,
                                            java.lang.String segmentKey,
                                            ApiCallback<UserSegment> _callback)
                                     throws ApiException
        Get segment (asynchronously) Get a single user segment by key.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        _callback - The callback to be executed when the API call finishes
        Returns:
        The request call
        Throws:
        ApiException - If fail to process the API call, e.g. serializing the request body object
      • getSegmentMembershipForUserCall

        public okhttp3.Call getSegmentMembershipForUserCall​(java.lang.String projectKey,
                                                            java.lang.String environmentKey,
                                                            java.lang.String segmentKey,
                                                            java.lang.String userKey,
                                                            ApiCallback _callback)
                                                     throws ApiException
        Build call for getSegmentMembershipForUser
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        userKey - The user key (required)
        _callback - Callback for upload/download progress
        Returns:
        Call to execute
        Throws:
        ApiException - If fail to serialize the request body object
      • getSegmentMembershipForUser

        public BigSegmentTarget getSegmentMembershipForUser​(java.lang.String projectKey,
                                                            java.lang.String environmentKey,
                                                            java.lang.String segmentKey,
                                                            java.lang.String userKey)
                                                     throws ApiException
        Get Big Segment membership for user Get the membership status (included/excluded) for a given user in this Big Segment. This operation does not support standard segments.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        userKey - The user key (required)
        Returns:
        BigSegmentTarget
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • getSegmentMembershipForUserWithHttpInfo

        public ApiResponse<BigSegmentTarget> getSegmentMembershipForUserWithHttpInfo​(java.lang.String projectKey,
                                                                                     java.lang.String environmentKey,
                                                                                     java.lang.String segmentKey,
                                                                                     java.lang.String userKey)
                                                                              throws ApiException
        Get Big Segment membership for user Get the membership status (included/excluded) for a given user in this Big Segment. This operation does not support standard segments.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        userKey - The user key (required)
        Returns:
        ApiResponse<BigSegmentTarget>
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • getSegmentMembershipForUserAsync

        public okhttp3.Call getSegmentMembershipForUserAsync​(java.lang.String projectKey,
                                                             java.lang.String environmentKey,
                                                             java.lang.String segmentKey,
                                                             java.lang.String userKey,
                                                             ApiCallback<BigSegmentTarget> _callback)
                                                      throws ApiException
        Get Big Segment membership for user (asynchronously) Get the membership status (included/excluded) for a given user in this Big Segment. This operation does not support standard segments.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        userKey - The user key (required)
        _callback - The callback to be executed when the API call finishes
        Returns:
        The request call
        Throws:
        ApiException - If fail to process the API call, e.g. serializing the request body object
      • getSegmentsCall

        public okhttp3.Call getSegmentsCall​(java.lang.String projectKey,
                                            java.lang.String environmentKey,
                                            ApiCallback _callback)
                                     throws ApiException
        Build call for getSegments
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        _callback - Callback for upload/download progress
        Returns:
        Call to execute
        Throws:
        ApiException - If fail to serialize the request body object
      • getSegments

        public UserSegments getSegments​(java.lang.String projectKey,
                                        java.lang.String environmentKey)
                                 throws ApiException
        List segments Get a list of all user segments in the given project.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        Returns:
        UserSegments
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • getSegmentsWithHttpInfo

        public ApiResponse<UserSegments> getSegmentsWithHttpInfo​(java.lang.String projectKey,
                                                                 java.lang.String environmentKey)
                                                          throws ApiException
        List segments Get a list of all user segments in the given project.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        Returns:
        ApiResponse<UserSegments>
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • getSegmentsAsync

        public okhttp3.Call getSegmentsAsync​(java.lang.String projectKey,
                                             java.lang.String environmentKey,
                                             ApiCallback<UserSegments> _callback)
                                      throws ApiException
        List segments (asynchronously) Get a list of all user segments in the given project.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        _callback - The callback to be executed when the API call finishes
        Returns:
        The request call
        Throws:
        ApiException - If fail to process the API call, e.g. serializing the request body object
      • patchExpiringUserTargetsForSegmentCall

        public okhttp3.Call patchExpiringUserTargetsForSegmentCall​(java.lang.String projectKey,
                                                                   java.lang.String environmentKey,
                                                                   java.lang.String segmentKey,
                                                                   PatchSegmentRequest patchSegmentRequest,
                                                                   ApiCallback _callback)
                                                            throws ApiException
        Build call for patchExpiringUserTargetsForSegment
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        patchSegmentRequest - (required)
        _callback - Callback for upload/download progress
        Returns:
        Call to execute
        Throws:
        ApiException - If fail to serialize the request body object
      • patchExpiringUserTargetsForSegment

        public ExpiringUserTargetPatchResponse patchExpiringUserTargetsForSegment​(java.lang.String projectKey,
                                                                                  java.lang.String environmentKey,
                                                                                  java.lang.String segmentKey,
                                                                                  PatchSegmentRequest patchSegmentRequest)
                                                                           throws ApiException
        Update expiring user targets for segment Update expiring user targets for a segment. Updating a user target expiration uses the semantic patch format. 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](/reference#updates-using-semantic-patch). If the request is well-formed but any of its instructions failed to process, this operation returns status code `200`. In this case, the response `errors` array will be non-empty. ### Instructions Semantic patch requests support the following `kind` instructions for updating user targets. #### addExpireUserTargetDate Schedules a date and time when LaunchDarkly will remove a user from segment targeting. ##### Parameters - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key. - `value`: The date when the user should expire from the segment targeting, in Unix milliseconds. #### updateExpireUserTargetDate Updates the date and time when LaunchDarkly will remove a user from segment targeting. ##### Parameters - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key. - `value`: The new date when the user should expire from the segment targeting, in Unix milliseconds. - `version`: The segment version. #### removeExpireUserTargetDate Removes the scheduled expiration for the user in the segment. ##### Parameters - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        patchSegmentRequest - (required)
        Returns:
        ExpiringUserTargetPatchResponse
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • patchExpiringUserTargetsForSegmentWithHttpInfo

        public ApiResponse<ExpiringUserTargetPatchResponse> patchExpiringUserTargetsForSegmentWithHttpInfo​(java.lang.String projectKey,
                                                                                                           java.lang.String environmentKey,
                                                                                                           java.lang.String segmentKey,
                                                                                                           PatchSegmentRequest patchSegmentRequest)
                                                                                                    throws ApiException
        Update expiring user targets for segment Update expiring user targets for a segment. Updating a user target expiration uses the semantic patch format. 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](/reference#updates-using-semantic-patch). If the request is well-formed but any of its instructions failed to process, this operation returns status code `200`. In this case, the response `errors` array will be non-empty. ### Instructions Semantic patch requests support the following `kind` instructions for updating user targets. #### addExpireUserTargetDate Schedules a date and time when LaunchDarkly will remove a user from segment targeting. ##### Parameters - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key. - `value`: The date when the user should expire from the segment targeting, in Unix milliseconds. #### updateExpireUserTargetDate Updates the date and time when LaunchDarkly will remove a user from segment targeting. ##### Parameters - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key. - `value`: The new date when the user should expire from the segment targeting, in Unix milliseconds. - `version`: The segment version. #### removeExpireUserTargetDate Removes the scheduled expiration for the user in the segment. ##### Parameters - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        patchSegmentRequest - (required)
        Returns:
        ApiResponse<ExpiringUserTargetPatchResponse>
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • patchExpiringUserTargetsForSegmentAsync

        public okhttp3.Call patchExpiringUserTargetsForSegmentAsync​(java.lang.String projectKey,
                                                                    java.lang.String environmentKey,
                                                                    java.lang.String segmentKey,
                                                                    PatchSegmentRequest patchSegmentRequest,
                                                                    ApiCallback<ExpiringUserTargetPatchResponse> _callback)
                                                             throws ApiException
        Update expiring user targets for segment (asynchronously) Update expiring user targets for a segment. Updating a user target expiration uses the semantic patch format. 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](/reference#updates-using-semantic-patch). If the request is well-formed but any of its instructions failed to process, this operation returns status code `200`. In this case, the response `errors` array will be non-empty. ### Instructions Semantic patch requests support the following `kind` instructions for updating user targets. #### addExpireUserTargetDate Schedules a date and time when LaunchDarkly will remove a user from segment targeting. ##### Parameters - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key. - `value`: The date when the user should expire from the segment targeting, in Unix milliseconds. #### updateExpireUserTargetDate Updates the date and time when LaunchDarkly will remove a user from segment targeting. ##### Parameters - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key. - `value`: The new date when the user should expire from the segment targeting, in Unix milliseconds. - `version`: The segment version. #### removeExpireUserTargetDate Removes the scheduled expiration for the user in the segment. ##### Parameters - `targetType`: A segment's target type, must be either `included` or `excluded`. - `userKey`: The user key.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        patchSegmentRequest - (required)
        _callback - The callback to be executed when the API call finishes
        Returns:
        The request call
        Throws:
        ApiException - If fail to process the API call, e.g. serializing the request body object
      • patchSegmentCall

        public okhttp3.Call patchSegmentCall​(java.lang.String projectKey,
                                             java.lang.String environmentKey,
                                             java.lang.String segmentKey,
                                             PatchWithComment patchWithComment,
                                             ApiCallback _callback)
                                      throws ApiException
        Build call for patchSegment
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        patchWithComment - (required)
        _callback - Callback for upload/download progress
        Returns:
        Call to execute
        Throws:
        ApiException - If fail to serialize the request body object
      • patchSegment

        public UserSegment patchSegment​(java.lang.String projectKey,
                                        java.lang.String environmentKey,
                                        java.lang.String segmentKey,
                                        PatchWithComment patchWithComment)
                                 throws ApiException
        Patch segment Update a user segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. ## 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](/reference#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. #### 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. ##### Parameters - `values`: List of user keys. #### 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. ##### Parameters - `values`: List of user keys. #### removeIncludedUsers Removes user keys from the individual user targets included in the segment. ##### Parameters - `values`: List of user keys. #### removeExcludedUsers Removes user keys from the individual user targets excluded from the segment. ##### Parameters - `values`: List of user keys. #### updateName Updates the name of the segment. ##### Parameters - `value`: Name of the segment. ## Using JSON patches on a segment You can also use JSON patch. To learn more, read [Updates using JSON patches](/reference#updates-using-json-patch). For example, to update the description for a segment, 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>`. Using `/0` adds the new entry to the beginning 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\": [{ \"attribute\": \"email\", \"op\": \"endsWith\", \"values\": [\".edu\"], \"negate\": false }] } } ] } ``` To add or remove users from segments, we recommend using semantic patch. Semantic patch for segments includes specific `instructions` for adding and removing both included and excluded users.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        patchWithComment - (required)
        Returns:
        UserSegment
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • patchSegmentWithHttpInfo

        public ApiResponse<UserSegment> patchSegmentWithHttpInfo​(java.lang.String projectKey,
                                                                 java.lang.String environmentKey,
                                                                 java.lang.String segmentKey,
                                                                 PatchWithComment patchWithComment)
                                                          throws ApiException
        Patch segment Update a user segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. ## 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](/reference#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. #### 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. ##### Parameters - `values`: List of user keys. #### 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. ##### Parameters - `values`: List of user keys. #### removeIncludedUsers Removes user keys from the individual user targets included in the segment. ##### Parameters - `values`: List of user keys. #### removeExcludedUsers Removes user keys from the individual user targets excluded from the segment. ##### Parameters - `values`: List of user keys. #### updateName Updates the name of the segment. ##### Parameters - `value`: Name of the segment. ## Using JSON patches on a segment You can also use JSON patch. To learn more, read [Updates using JSON patches](/reference#updates-using-json-patch). For example, to update the description for a segment, 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>`. Using `/0` adds the new entry to the beginning 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\": [{ \"attribute\": \"email\", \"op\": \"endsWith\", \"values\": [\".edu\"], \"negate\": false }] } } ] } ``` To add or remove users from segments, we recommend using semantic patch. Semantic patch for segments includes specific `instructions` for adding and removing both included and excluded users.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        patchWithComment - (required)
        Returns:
        ApiResponse<UserSegment>
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • patchSegmentAsync

        public okhttp3.Call patchSegmentAsync​(java.lang.String projectKey,
                                              java.lang.String environmentKey,
                                              java.lang.String segmentKey,
                                              PatchWithComment patchWithComment,
                                              ApiCallback<UserSegment> _callback)
                                       throws ApiException
        Patch segment (asynchronously) Update a user segment. The request body must be a valid semantic patch, JSON patch, or JSON merge patch. ## 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](/reference#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. #### 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. ##### Parameters - `values`: List of user keys. #### 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. ##### Parameters - `values`: List of user keys. #### removeIncludedUsers Removes user keys from the individual user targets included in the segment. ##### Parameters - `values`: List of user keys. #### removeExcludedUsers Removes user keys from the individual user targets excluded from the segment. ##### Parameters - `values`: List of user keys. #### updateName Updates the name of the segment. ##### Parameters - `value`: Name of the segment. ## Using JSON patches on a segment You can also use JSON patch. To learn more, read [Updates using JSON patches](/reference#updates-using-json-patch). For example, to update the description for a segment, 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>`. Using `/0` adds the new entry to the beginning 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\": [{ \"attribute\": \"email\", \"op\": \"endsWith\", \"values\": [\".edu\"], \"negate\": false }] } } ] } ``` To add or remove users from segments, we recommend using semantic patch. Semantic patch for segments includes specific `instructions` for adding and removing both included and excluded users.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        patchWithComment - (required)
        _callback - The callback to be executed when the API call finishes
        Returns:
        The request call
        Throws:
        ApiException - If fail to process the API call, e.g. serializing the request body object
      • postSegmentCall

        public okhttp3.Call postSegmentCall​(java.lang.String projectKey,
                                            java.lang.String environmentKey,
                                            SegmentBody segmentBody,
                                            ApiCallback _callback)
                                     throws ApiException
        Build call for postSegment
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentBody - (required)
        _callback - Callback for upload/download progress
        Returns:
        Call to execute
        Throws:
        ApiException - If fail to serialize the request body object
      • postSegment

        public UserSegment postSegment​(java.lang.String projectKey,
                                       java.lang.String environmentKey,
                                       SegmentBody segmentBody)
                                throws ApiException
        Create segment Create a new user segment.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentBody - (required)
        Returns:
        UserSegment
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • postSegmentWithHttpInfo

        public ApiResponse<UserSegment> postSegmentWithHttpInfo​(java.lang.String projectKey,
                                                                java.lang.String environmentKey,
                                                                SegmentBody segmentBody)
                                                         throws ApiException
        Create segment Create a new user segment.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentBody - (required)
        Returns:
        ApiResponse<UserSegment>
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • postSegmentAsync

        public okhttp3.Call postSegmentAsync​(java.lang.String projectKey,
                                             java.lang.String environmentKey,
                                             SegmentBody segmentBody,
                                             ApiCallback<UserSegment> _callback)
                                      throws ApiException
        Create segment (asynchronously) Create a new user segment.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentBody - (required)
        _callback - The callback to be executed when the API call finishes
        Returns:
        The request call
        Throws:
        ApiException - If fail to process the API call, e.g. serializing the request body object
      • updateBigSegmentTargetsCall

        public okhttp3.Call updateBigSegmentTargetsCall​(java.lang.String projectKey,
                                                        java.lang.String environmentKey,
                                                        java.lang.String segmentKey,
                                                        SegmentUserState segmentUserState,
                                                        ApiCallback _callback)
                                                 throws ApiException
        Build call for updateBigSegmentTargets
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        segmentUserState - (required)
        _callback - Callback for upload/download progress
        Returns:
        Call to execute
        Throws:
        ApiException - If fail to serialize the request body object
      • updateBigSegmentTargets

        public void updateBigSegmentTargets​(java.lang.String projectKey,
                                            java.lang.String environmentKey,
                                            java.lang.String segmentKey,
                                            SegmentUserState segmentUserState)
                                     throws ApiException
        Update targets on a Big Segment Update targets included or excluded in a Big Segment.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        segmentUserState - (required)
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • updateBigSegmentTargetsWithHttpInfo

        public ApiResponse<java.lang.Void> updateBigSegmentTargetsWithHttpInfo​(java.lang.String projectKey,
                                                                               java.lang.String environmentKey,
                                                                               java.lang.String segmentKey,
                                                                               SegmentUserState segmentUserState)
                                                                        throws ApiException
        Update targets on a Big Segment Update targets included or excluded in a Big Segment.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        segmentUserState - (required)
        Returns:
        ApiResponse<Void>
        Throws:
        ApiException - If fail to call the API, e.g. server error or cannot deserialize the response body
      • updateBigSegmentTargetsAsync

        public okhttp3.Call updateBigSegmentTargetsAsync​(java.lang.String projectKey,
                                                         java.lang.String environmentKey,
                                                         java.lang.String segmentKey,
                                                         SegmentUserState segmentUserState,
                                                         ApiCallback<java.lang.Void> _callback)
                                                  throws ApiException
        Update targets on a Big Segment (asynchronously) Update targets included or excluded in a Big Segment.
        Parameters:
        projectKey - The project key (required)
        environmentKey - The environment key (required)
        segmentKey - The segment key (required)
        segmentUserState - (required)
        _callback - The callback to be executed when the API call finishes
        Returns:
        The request call
        Throws:
        ApiException - If fail to process the API call, e.g. serializing the request body object