All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.algolia.search.models.apikeys.DeleteApiKeyResponse Maven / Gradle / Ivy

The newest version!
package com.algolia.search.models.apikeys;

import com.algolia.search.exceptions.AlgoliaApiException;
import com.algolia.search.models.WaitableResponse;
import java.io.Serializable;
import java.time.OffsetDateTime;
import java.util.function.Function;

public class DeleteApiKeyResponse implements WaitableResponse, Serializable {

  @SuppressWarnings("WeakerAccess")
  public String getKey() {
    return key;
  }

  public void setKey(String key) {
    this.key = key;
  }

  public OffsetDateTime getDeletedAt() {
    return deletedAt;
  }

  public void setDeletedAt(OffsetDateTime deletedAt) {
    this.deletedAt = deletedAt;
  }

  public void setGetApiKeyFunction(Function getApiKeyConsumer) {
    this.getApiKeyFunction = getApiKeyConsumer;
  }

  private Function getApiKeyFunction;
  private String key;
  private OffsetDateTime deletedAt;

  @Override
  public void waitTask() {
    while (true) {
      try {
        getApiKeyFunction.apply(getKey());
      } catch (AlgoliaApiException ex) {
        if (ex.getHttpErrorCode() == 404) {
          break;
        }

        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          // Restore interrupted state...
          Thread.currentThread().interrupt();
        }
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy