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

com.spotinst.sdkjava.model.SpotinstSpectrumClient Maven / Gradle / Ivy

There is a newer version: 1.0.121
Show newest version
package com.spotinst.sdkjava.model;

import com.spotinst.sdkjava.exception.HttpError;
import com.spotinst.sdkjava.exception.SpotinstHttpException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public class SpotinstSpectrumClient {

  private static final Logger LOGGER = LoggerFactory.getLogger(SpotinstSpectrumClient.class);

  //region Members
  private String authToken;
  private String account;
  private ISpotinstSpectrumRepo spotinstSpectrumRepo;

  public SpotinstSpectrumClient(String authToken,String account) {
    this.authToken = authToken;
    this.account = account;
    this.spotinstSpectrumRepo = SpotinstRepoManager.getInstance().getSpotinstSpectrumRepo();
  }

  public void publishMetricData(SpectrumMetricDataRequest spectrumMetricDataRequest) {
    RepoGenericResponse creationResponse = spotinstSpectrumRepo.create(spectrumMetricDataRequest, authToken, account);
    if (!creationResponse.isRequestSucceed()) {
      List httpExceptions = creationResponse.getHttpExceptions();
      HttpError httpException = httpExceptions.get(0);
      LOGGER.error(String.format("Error encountered while attempting to publish metric data. Code: %s. Message: %s.", httpException.getCode(), httpException.getMessage()));
      throw new SpotinstHttpException(httpException.getMessage());
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy