Skip to content

Latest commit

 

History

History
614 lines (490 loc) · 30.1 KB

README.md

File metadata and controls

614 lines (490 loc) · 30.1 KB

Organizations

(organizations())

Available Operations

  • list - Get a list of organizations for an instance
  • create - Create an organization
  • get - Retrieve an organization by ID or slug
  • update - Update an organization
  • delete - Delete an organization
  • mergeMetadata - Merge and update metadata for an organization
  • uploadLogo - Upload a logo for the organization
  • deleteLogo - Delete the organization's logo.

list

This request returns the list of organizations for an instance. Results can be paginated using the optional limit and offset query parameters. The organizations are ordered by descending creation date. Most recent organizations will be returned first.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
                .build();

            ListOrganizationsRequest req = ListOrganizationsRequest.builder()
                .build();

            ListOrganizationsResponse res = sdk.organizations().list()
                .request(req)
                .call();

            while (true) {
                if (res.organizations().isPresent()) {
                    // handle response
                    Optional<ListOrganizationsResponse> nextRes = res.next();
                    if (nextRes.isPresent()) {
                        res = nextRes.get();
                    } else {
                        break;
                    }
                }
            }
        } catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
            // handle exception
            throw e;
        } catch (com.clerk.backend_api.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
request com.clerk.backend_api.models.operations.ListOrganizationsRequest ✔️ The request object to use for the request.

Response

Optional<? extends com.clerk.backend_api.models.operations.ListOrganizationsResponse>

Errors

Error Object Status Code Content Type
models/errors/ClerkErrors 400,403,422 application/json
models/errors/SDKError 4xx-5xx /

create

Creates a new organization with the given name for an instance. In order to successfully create an organization you need to provide the ID of the User who will become the organization administrator. You can specify an optional slug for the new organization. If provided, the organization slug can contain only lowercase alphanumeric characters (letters and digits) and the dash "-". Organization slugs must be unique for the instance. You can provide additional metadata for the organization and set any custom attribute you want. Organizations support private and public metadata. Private metadata can only be accessed from the Backend API. Public metadata can be accessed from the Backend API, and are read-only from the Frontend API.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
                .build();

            CreateOrganizationRequestBody req = CreateOrganizationRequestBody.builder()
                .name("<value>")
                .createdBy("<value>")
                .build();

            CreateOrganizationResponse res = sdk.organizations().create()
                .request(req)
                .call();

            if (res.organization().isPresent()) {
                // handle response
            }
        } catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
            // handle exception
            throw e;
        } catch (com.clerk.backend_api.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
request com.clerk.backend_api.models.operations.CreateOrganizationRequestBody ✔️ The request object to use for the request.

Response

Optional<? extends com.clerk.backend_api.models.operations.CreateOrganizationResponse>

Errors

Error Object Status Code Content Type
models/errors/ClerkErrors 400,403,422 application/json
models/errors/SDKError 4xx-5xx /

get

Fetches the organization whose ID or slug matches the provided id_or_slug URL query parameter.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
                .build();

            GetOrganizationResponse res = sdk.organizations().get()
                .organizationId("<value>")
                .call();

            if (res.organization().isPresent()) {
                // handle response
            }
        } catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
            // handle exception
            throw e;
        } catch (com.clerk.backend_api.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
organizationId String ✔️ The ID or slug of the organization

Response

Optional<? extends com.clerk.backend_api.models.operations.GetOrganizationResponse>

Errors

Error Object Status Code Content Type
models/errors/ClerkErrors 403,404 application/json
models/errors/SDKError 4xx-5xx /

update

Updates an existing organization

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
                .build();

            UpdateOrganizationResponse res = sdk.organizations().update()
                .organizationId("<value>")
                .requestBody(UpdateOrganizationRequestBody.builder()
                    .build())
                .call();

            if (res.organization().isPresent()) {
                // handle response
            }
        } catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
            // handle exception
            throw e;
        } catch (com.clerk.backend_api.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
organizationId String ✔️ The ID of the organization to update
requestBody com.clerk.backend_api.models.operations.UpdateOrganizationRequestBody ✔️ N/A

Response

Optional<? extends com.clerk.backend_api.models.operations.UpdateOrganizationResponse>

Errors

Error Object Status Code Content Type
models/errors/ClerkErrors 402,404,422 application/json
models/errors/SDKError 4xx-5xx /

delete

Deletes the given organization. Please note that deleting an organization will also delete all memberships and invitations. This is not reversible.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
                .build();

            DeleteOrganizationResponse res = sdk.organizations().delete()
                .organizationId("<value>")
                .call();

            if (res.deletedObject().isPresent()) {
                // handle response
            }
        } catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
            // handle exception
            throw e;
        } catch (com.clerk.backend_api.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
organizationId String ✔️ The ID of the organization to delete

Response

Optional<? extends com.clerk.backend_api.models.operations.DeleteOrganizationResponse>

Errors

Error Object Status Code Content Type
models/errors/ClerkErrors 404 application/json
models/errors/SDKError 4xx-5xx /

mergeMetadata

Update organization metadata attributes by merging existing values with the provided parameters. Metadata values will be updated via a deep merge. Deep meaning that any nested JSON objects will be merged as well. You can remove metadata keys at any level by setting their value to null.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
                .build();

            MergeOrganizationMetadataResponse res = sdk.organizations().mergeMetadata()
                .organizationId("<value>")
                .requestBody(MergeOrganizationMetadataRequestBody.builder()
                    .build())
                .call();

            if (res.organization().isPresent()) {
                // handle response
            }
        } catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
            // handle exception
            throw e;
        } catch (com.clerk.backend_api.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
organizationId String ✔️ The ID of the organization for which metadata will be merged or updated
requestBody com.clerk.backend_api.models.operations.MergeOrganizationMetadataRequestBody ✔️ N/A

Response

Optional<? extends com.clerk.backend_api.models.operations.MergeOrganizationMetadataResponse>

Errors

Error Object Status Code Content Type
models/errors/ClerkErrors 400,401,404,422 application/json
models/errors/SDKError 4xx-5xx /

uploadLogo

Set or replace an organization's logo, by uploading an image file. This endpoint uses the multipart/form-data request content type and accepts a file of image type. The file size cannot exceed 10MB. Only the following file content types are supported: image/jpeg, image/png, image/gif, image/webp, image/x-icon, image/vnd.microsoft.icon.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
                .build();

            UploadOrganizationLogoResponse res = sdk.organizations().uploadLogo()
                .organizationId("<value>")
                .requestBody(UploadOrganizationLogoRequestBody.builder()
                    .uploaderUserId("<value>")
                    .file(UploadOrganizationLogoFile.builder()
                            .fileName("<value>")
                            .content("0x07D3D6E1EC".getBytes())
                            .build())
                    .build())
                .call();

            if (res.organizationWithLogo().isPresent()) {
                // handle response
            }
        } catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
            // handle exception
            throw e;
        } catch (com.clerk.backend_api.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
organizationId String ✔️ The ID of the organization for which to upload a logo
requestBody Optional<? extends com.clerk.backend_api.models.operations.UploadOrganizationLogoRequestBody> N/A

Response

Optional<? extends com.clerk.backend_api.models.operations.UploadOrganizationLogoResponse>

Errors

Error Object Status Code Content Type
models/errors/ClerkErrors 400,403,404,413 application/json
models/errors/SDKError 4xx-5xx /

deleteLogo

Delete the organization's logo.

Example Usage

package hello.world;

import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Clerk sdk = Clerk.builder()
                .bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
                .build();

            DeleteOrganizationLogoResponse res = sdk.organizations().deleteLogo()
                .organizationId("<value>")
                .call();

            if (res.organization().isPresent()) {
                // handle response
            }
        } catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
            // handle exception
            throw e;
        } catch (com.clerk.backend_api.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
organizationId String ✔️ The ID of the organization for which the logo will be deleted.

Response

Optional<? extends com.clerk.backend_api.models.operations.DeleteOrganizationLogoResponse>

Errors

Error Object Status Code Content Type
models/errors/ClerkErrors 404 application/json
models/errors/SDKError 4xx-5xx /