Interface DataStore

  • All Known Subinterfaces:
    Client

    public interface DataStore
    A DataStore is the liaison between client SDK components and the raw Okta REST API. It is responsible for converting SDK objects (Account, Directory, Group instances, etc) into REST HTTP requests, executing those requests, and converting REST HTTP responses back into SDK objects.
    Since:
    0.5.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T extends Resource>
      T
      create​(java.lang.String parentHref, T resource)
      Creates a new resource and returns the instance as represented by the server.
      <T extends Resource>
      void
      delete​(java.lang.String href, T resource)
      Deleted a resource on the remote server.
      CacheManager getCacheManager()
      Returns the CacheManager used to improve data store performance.
      ClientCredentials getClientCredentials()
      Returns the ClientCredentials used to authenticate HTTPS requests sent to the Okta API server.
      <T extends Resource>
      T
      getResource​(java.lang.String href, java.lang.Class<T> clazz)
      Looks up (retrieves) the resource at the specified href URL and returns the resource as an instance of the specified class.
      RequestBuilder http()
      Returns an http request builder to help make requests to Okta endpoints that are NOT implemented by this SDK.
      <T extends Resource>
      T
      instantiate​(java.lang.Class<T> clazz)
      Instantiates and returns a new instance of the specified Resource type.
      boolean isReady​(java.util.function.Supplier<? extends Resource> methodReference)
      Check if Datastore is configured correctly and able to execute requests.
      <T extends Resource>
      void
      save​(java.lang.String href, T resource)
      Saves an exiting resource to the remote server.
    • Method Detail

      • instantiate

        <T extends Resource> T instantiate​(java.lang.Class<T> clazz)
        Instantiates and returns a new instance of the specified Resource type. The instance is merely instantiated and is not saved/synchronized with the server in any way.

        This method effectively replaces the new keyword that would have been used otherwise if the concrete implementation was known (Resource implementation classes are intentionally not exposed to SDK end-users).

        Type Parameters:
        T - the Resource sub-type
        Parameters:
        clazz - the Resource class to instantiate.
        Returns:
        a new instance of the specified Resource.
      • getResource

        <T extends Resource> T getResource​(java.lang.String href,
                                           java.lang.Class<T> clazz)
        Looks up (retrieves) the resource at the specified href URL and returns the resource as an instance of the specified class.

        The Class argument must represent an interface that is a sub-interface of Resource.

        Type Parameters:
        T - type parameter indicating the returned value is a Resource instance.
        Parameters:
        href - the resource URL of the resource to retrieve
        clazz - the Resource sub-interface to instantiate
        Returns:
        an instance of the specified class based on the data returned from the specified href URL.
      • create

        <T extends Resource> T create​(java.lang.String parentHref,
                                      T resource)
        Creates a new resource and returns the instance as represented by the server. This could mean default values have been set, modification dates changed, etc.
        Type Parameters:
        T - type parameter indicating the returned value is a Resource instance.
        Parameters:
        parentHref - the resource URL of the resource to retrieve
        resource - the object payload to to send to the server
        Returns:
        an updated resource as represented by the server.
        Since:
        1.1.0
      • save

        <T extends Resource> void save​(java.lang.String href,
                                       T resource)
        Saves an exiting resource to the remote server.

        NOTE: this is typically done by using resource.save() instead of this method.

        Type Parameters:
        T - type parameter indicating the type of Resource instance.
        Parameters:
        href - the resource URL of the resource to updated
        resource - the object payload to to send to the server
        Since:
        1.1.0
      • delete

        <T extends Resource> void delete​(java.lang.String href,
                                         T resource)
        Deleted a resource on the remote server.

        NOTE: this is typically done by using resource.delete() instead of this method.

        Type Parameters:
        T - type parameter indicating the type of Resource instance.
        Parameters:
        href - the resource URL of the resource to deleted
        resource - the object payload to to send to the server
        Since:
        1.1.0
      • getClientCredentials

        ClientCredentials getClientCredentials()
        Returns the ClientCredentials used to authenticate HTTPS requests sent to the Okta API server.
        Returns:
        the ClientCredentials used to authenticate HTTPS requests sent to the Okta API server.
      • getCacheManager

        CacheManager getCacheManager()
        Returns the CacheManager used to improve data store performance.
        Returns:
        the CacheManager used to improve data store performance.
      • http

        RequestBuilder http()
        Returns an http request builder to help make requests to Okta endpoints that are NOT implemented by this SDK.
        Returns:
        an http request builder to help make requests to Okta endpoints that are NOT implemented by this SDK.
        Since:
        1.2.0
      • isReady

        boolean isReady​(java.util.function.Supplier<? extends Resource> methodReference)
        Check if Datastore is configured correctly and able to execute requests.
        Parameters:
        methodReference - a reference to the method based on which the ready state will be checked
        Returns:
        true if orgUrl and token are correct and Okta Core is available, otherwise false.