Class AdminClient

java.lang.Object
com.mxraven.admin.AdminClient
All Implemented Interfaces:
AutoCloseable

public final class AdminClient extends Object implements AutoCloseable
Client for the mxRaven control-plane v2 REST API.

Construct one with the control-plane base URL and a ZITADEL-issued bearer access token, then reach resource families through the typed accessors:


 AdminClient admin = new AdminClient("https://api.mxraven.com", token);
 for (Domain domain : admin.workspace("my-workspace").domains().list()) {
     System.out.println(domain.domainName() + " " + domain.status());
 }
 

All response timestamps are returned as ISO-8601 strings. Pagination is cursor-based: pass Page.nextPageToken() back into the same list call.

  • Field Details

    • DEFAULT_API_VERSION

      public static final String DEFAULT_API_VERSION
      Default control-plane API version. Every request path is prefixed with "/" + apiVersion in a single place, so clients never hardcode it.
      See Also:
    • DEFAULT_BASE_URL

      public static final String DEFAULT_BASE_URL
      Default mxRaven control-plane base URL. Used by the constructors that omit a base URL; pass an explicit URL to target another environment.
      See Also:
  • Constructor Details

    • AdminClient

      public AdminClient(String token)
      Construct a client against DEFAULT_BASE_URL.
      Parameters:
      token - ZITADEL-issued bearer access token
    • AdminClient

      public AdminClient(String token, RateLimitConfig rateLimitConfig)
      Construct a client against DEFAULT_BASE_URL with explicit rate-limit behaviour.
      Parameters:
      token - ZITADEL-issued bearer access token
      rateLimitConfig - client-wide rate-limit behaviour
    • AdminClient

      public AdminClient(String token, HttpClient http, com.fasterxml.jackson.databind.ObjectMapper json)
      Construct a client against DEFAULT_BASE_URL with a custom HTTP client and mapper.
      Parameters:
      token - ZITADEL-issued bearer access token
      http - HTTP client used to send requests
      json - mapper used to encode and decode JSON
    • AdminClient

      public AdminClient(String baseUrl, String token)
      Construct a client against an explicit control-plane base URL.
      Parameters:
      baseUrl - control-plane base URL; trailing slashes are stripped
      token - ZITADEL-issued bearer access token
    • AdminClient

      public AdminClient(String baseUrl, String token, RateLimitConfig rateLimitConfig)
      Construct a client with explicit rate-limit behaviour.
      Parameters:
      baseUrl - control-plane base URL; trailing slashes are stripped
      token - ZITADEL-issued bearer access token
      rateLimitConfig - client-wide rate-limit behaviour
    • AdminClient

      public AdminClient(String baseUrl, String token, String apiVersion)
      Construct a client targeting a specific control-plane API version. The version is prepended to every request path (for example "v2" yields /v2/...). Pass DEFAULT_API_VERSION for the default.
      Parameters:
      baseUrl - control-plane base URL; trailing slashes are stripped
      token - ZITADEL-issued bearer access token
      apiVersion - API version prefix applied to every request path
    • AdminClient

      public AdminClient(String baseUrl, String token, RateLimitConfig rateLimitConfig, String apiVersion)
      Construct a client with explicit rate-limit behaviour and API version.
      Parameters:
      baseUrl - control-plane base URL; trailing slashes are stripped
      token - ZITADEL-issued bearer access token
      rateLimitConfig - client-wide rate-limit behaviour
      apiVersion - API version prefix applied to every request path
    • AdminClient

      public AdminClient(String baseUrl, String token, HttpClient http, com.fasterxml.jackson.databind.ObjectMapper json)
      Construct a client with a custom HTTP client and mapper against an explicit base URL.
      Parameters:
      baseUrl - control-plane base URL; trailing slashes are stripped
      token - ZITADEL-issued bearer access token
      http - HTTP client used to send requests
      json - mapper used to encode and decode JSON
  • Method Details

    • baseUrl

      public String baseUrl()
      Returns the control-plane base URL, without a trailing slash.
      Returns:
      the normalized base URL
    • apiVersion

      public String apiVersion()
      The control-plane API version prefix applied to every request path.
      Returns:
      the API version prefix, for example "v2"
    • json

      public com.fasterxml.jackson.databind.ObjectMapper json()
      Returns the mapper used to encode request bodies and decode response bodies.
      Returns:
      the JSON mapper
    • rateLimitConfig

      public RateLimitConfig rateLimitConfig()
      The client-wide rate-limit behaviour.
      Returns:
      the rate-limit configuration
    • workspace

      public Workspace workspace(String tenantSlug)
      Bind a tenant. The returned Workspace exposes every tenant-scoped resource family without repeating the slug.
      Parameters:
      tenantSlug - tenant slug to bind
      Returns:
      a workspace bound to the given tenant
    • auth

      public AuthClient auth()
      Public tenant login context; works with a blank token.
      Returns:
      a client for the public authentication family
    • get

      public Response get(String path) throws IOException
      Issues a GET request.
      Parameters:
      path - client-relative path; the configured API version is prepended
      Returns:
      the decoded response
      Throws:
      IOException - if the request fails or is interrupted
    • get

      public Response get(String path, Map<String,String> query) throws IOException
      Issues a GET request with query parameters.
      Parameters:
      path - client-relative path; the configured API version is prepended
      query - query parameters, or null for none
      Returns:
      the decoded response
      Throws:
      IOException - if the request fails or is interrupted
    • post

      public Response post(String path, Object body) throws IOException
      Issues a POST request with a JSON body.
      Parameters:
      path - client-relative path; the configured API version is prepended
      body - object serialized as the JSON request body
      Returns:
      the decoded response
      Throws:
      IOException - if the request fails or is interrupted
    • post

      public Response post(String path, Map<String,String> query, Object body) throws IOException
      Issues a POST request with query parameters and a JSON body.
      Parameters:
      path - client-relative path; the configured API version is prepended
      query - query parameters, or null for none
      body - object serialized as the JSON request body
      Returns:
      the decoded response
      Throws:
      IOException - if the request fails or is interrupted
    • put

      public Response put(String path, Object body) throws IOException
      Issues a PUT request with a JSON body.
      Parameters:
      path - client-relative path; the configured API version is prepended
      body - object serialized as the JSON request body
      Returns:
      the decoded response
      Throws:
      IOException - if the request fails or is interrupted
    • delete

      public Response delete(String path) throws IOException
      Issues a DELETE request.
      Parameters:
      path - client-relative path; the configured API version is prepended
      Returns:
      the decoded response
      Throws:
      IOException - if the request fails or is interrupted
    • paged

      public <T> Paged<T> paged(String path, Map<String,String> query, Class<T> elementType) throws IOException
      Issue a GET and wrap the response in a lazily auto-paginating Paged. Subsequent pages are fetched by re-issuing the same request with the next page_token, only as the returned iterator advances.
      Type Parameters:
      T - element type
      Parameters:
      path - client-relative path; the configured API version is prepended
      query - query parameters, or null for none
      elementType - type of each item in the collection
      Returns:
      a lazily paginating collection over the response items
      Throws:
      IOException - if the first page request fails or is interrupted
    • request

      public Response request(String method, String path, Map<String,String> query, Object body) throws IOException
      Send a request to the control plane. A non-success status is decoded as an RFC 9457 problem and thrown as ApiException.
      Parameters:
      method - HTTP method to use
      path - client-relative path; the configured API version is prepended
      query - query parameters, or null for none
      body - request body serialized as JSON, or null for no body
      Returns:
      the decoded successful response
      Throws:
      IOException - if the request fails or is interrupted
      ApiException - if the control plane returns a non-success status
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable