Class ServiceCreateResult

java.lang.Object
eu.cloudnetservice.driver.service.ServiceCreateResult

public final class ServiceCreateResult extends Object
Represents the result of a service creation. A result can have three states:
  1. CREATED: the service was created successfully, the service info is available via serviceInfo().
  2. DEFERRED: this state can only happen when a retry configuration was specified during the creation of the service. In that case, the creation id of the result can be used to listen to the CloudServiceDeferredStateEvent to catch updates of the retries.
  3. FAILED: indicates that the service couldn't be created.
Since:
4.0
  • Field Details

  • Constructor Details

  • Method Details

    • deferred

      @NonNull public static @NonNull ServiceCreateResult deferred(@NonNull @NonNull UUID creationId)
      Creates a new result with the state set to deferred and using the given creation id.
      Parameters:
      creationId - the creation id for deferred service event updates.
      Returns:
      a new result instance.
      Throws:
      NullPointerException - if the given creation id is null.
    • created

      Creates a new result with the state set to created and using the given service info.
      Parameters:
      serviceInfo - the service info of the created service.
      Returns:
      a new result instance.
      Throws:
      NullPointerException - if the given service info is null.
    • creationId

      @NonNull public @NonNull UUID creationId()
      Get the creation id of this create result. If the service was created successfully, this id is set to the unique id of the service. If the creation was deferred the id is set to a unique notification id which can be used to identify the final creation result.
      Returns:
      the creation id of this service.
      Throws:
      IllegalStateException - if called when the state of this result is FAILED.
    • serviceInfo

      @NonNull public @NonNull ServiceInfoSnapshot serviceInfo()
      Get the service info of the service which was created. This is only present if the state of this result is CREATED.
      Returns:
      the service info of the created service.
      Throws:
      IllegalStateException - if called when the state of this result is not CREATED.
    • state

      Get the state of this service creation. Use this to ensure that the service creation was successful when accessing creationId() or serviceInfo().
      Returns:
      the state of this service creation.