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)
      • 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 Returns the membership status (included/excluded) for a given user in this segment. This operation does not support basic 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 Returns the membership status (included/excluded) for a given user in this segment. This operation does not support basic 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) Returns the membership status (included/excluded) for a given user in this segment. This operation does not support basic 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 the list of a segment's user targets that are scheduled for removal<br /><br />Requires a semantic patch representation of the desired changes to the resource. To learn more about semantic patches, read [Updates](/reference#updates-via-semantic-patches).<br /><br />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.
        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 the list of a segment's user targets that are scheduled for removal<br /><br />Requires a semantic patch representation of the desired changes to the resource. To learn more about semantic patches, read [Updates](/reference#updates-via-semantic-patches).<br /><br />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.
        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 the list of a segment's user targets that are scheduled for removal<br /><br />Requires a semantic patch representation of the desired changes to the resource. To learn more about semantic patches, read [Updates](/reference#updates-via-semantic-patches).<br /><br />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.
        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 JSON patch, JSON merge patch, or semantic patch. ## Using semantic patches on a segment To use a [semantic patch](/reference#updates-via-semantic-patches) on a segment resource, you must include a header in the request. If you call a semantic patch resource without this header, you will receive a `400` response because your semantic patch will be interpreted as a JSON patch. Use this header: ``` Content-Type: application/json; domain-model=launchdarkly.semanticpatch ``` The body of a semantic patch request takes the following three properties: 1. `comment` (string): (Optional) A description of the update. 1. `environmentKey` (string): (Required) The key of the LaunchDarkly environment. 1. `instructions` (array): (Required) The list of actions to be performed by the update. Each action in the list must be an object/hash table with a `kind` property that indicates the instruction. Depending on the `kind`, the API may require other parameters. When this is the case, add the parameters as additional fields to the instruction object. Read below for more information on the specific supported semantic patch instructions. If any instruction in the patch encounters an error, the error will be returned and the segment will not be changed. In general, instructions will silently do nothing if the segment is already in the state requested by the patch instruction. For example, `addIncludedUsers` does nothing when the targets have already been included. Specific error conditions are noted in the instruction descriptions. ### Instructions #### `addIncludedUsers` Adds the user keys in `values` 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 the user keys in `values` 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 the user keys in `values` from the individual user targets included in the segment. ##### Parameters - `values`: list of user keys #### `removeExcludedUsers` Removes the user keys in `values` from the individual user targets excluded from the segment. ##### Parameters - `values`: list of user keys #### `updateName` Updates the name of the segment to the string provided in `value`. ##### Parameters - `value`: string ## Using JSON patches on a segment If you do not include the header described above, you can use [JSON patch](/reference#updates-via-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 JSON patch, JSON merge patch, or semantic patch. ## Using semantic patches on a segment To use a [semantic patch](/reference#updates-via-semantic-patches) on a segment resource, you must include a header in the request. If you call a semantic patch resource without this header, you will receive a `400` response because your semantic patch will be interpreted as a JSON patch. Use this header: ``` Content-Type: application/json; domain-model=launchdarkly.semanticpatch ``` The body of a semantic patch request takes the following three properties: 1. `comment` (string): (Optional) A description of the update. 1. `environmentKey` (string): (Required) The key of the LaunchDarkly environment. 1. `instructions` (array): (Required) The list of actions to be performed by the update. Each action in the list must be an object/hash table with a `kind` property that indicates the instruction. Depending on the `kind`, the API may require other parameters. When this is the case, add the parameters as additional fields to the instruction object. Read below for more information on the specific supported semantic patch instructions. If any instruction in the patch encounters an error, the error will be returned and the segment will not be changed. In general, instructions will silently do nothing if the segment is already in the state requested by the patch instruction. For example, `addIncludedUsers` does nothing when the targets have already been included. Specific error conditions are noted in the instruction descriptions. ### Instructions #### `addIncludedUsers` Adds the user keys in `values` 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 the user keys in `values` 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 the user keys in `values` from the individual user targets included in the segment. ##### Parameters - `values`: list of user keys #### `removeExcludedUsers` Removes the user keys in `values` from the individual user targets excluded from the segment. ##### Parameters - `values`: list of user keys #### `updateName` Updates the name of the segment to the string provided in `value`. ##### Parameters - `value`: string ## Using JSON patches on a segment If you do not include the header described above, you can use [JSON patch](/reference#updates-via-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 JSON patch, JSON merge patch, or semantic patch. ## Using semantic patches on a segment To use a [semantic patch](/reference#updates-via-semantic-patches) on a segment resource, you must include a header in the request. If you call a semantic patch resource without this header, you will receive a `400` response because your semantic patch will be interpreted as a JSON patch. Use this header: ``` Content-Type: application/json; domain-model=launchdarkly.semanticpatch ``` The body of a semantic patch request takes the following three properties: 1. `comment` (string): (Optional) A description of the update. 1. `environmentKey` (string): (Required) The key of the LaunchDarkly environment. 1. `instructions` (array): (Required) The list of actions to be performed by the update. Each action in the list must be an object/hash table with a `kind` property that indicates the instruction. Depending on the `kind`, the API may require other parameters. When this is the case, add the parameters as additional fields to the instruction object. Read below for more information on the specific supported semantic patch instructions. If any instruction in the patch encounters an error, the error will be returned and the segment will not be changed. In general, instructions will silently do nothing if the segment is already in the state requested by the patch instruction. For example, `addIncludedUsers` does nothing when the targets have already been included. Specific error conditions are noted in the instruction descriptions. ### Instructions #### `addIncludedUsers` Adds the user keys in `values` 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 the user keys in `values` 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 the user keys in `values` from the individual user targets included in the segment. ##### Parameters - `values`: list of user keys #### `removeExcludedUsers` Removes the user keys in `values` from the individual user targets excluded from the segment. ##### Parameters - `values`: list of user keys #### `updateName` Updates the name of the segment to the string provided in `value`. ##### Parameters - `value`: string ## Using JSON patches on a segment If you do not include the header described above, you can use [JSON patch](/reference#updates-via-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