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

com.segment.publicapi.models.MtuSnapshotV1 Maven / Gradle / Ivy

There is a newer version: 58.0.0
Show newest version
/*
 * Segment Public API
 * The Segment Public API helps you manage your Segment Workspaces and its resources. You can use the API to perform CRUD (create, read, update, delete) operations at no extra charge. This includes working with resources such as Sources, Destinations, Warehouses, Tracking Plans, and the Segment Destinations and Sources Catalogs.  All CRUD endpoints in the API follow REST conventions and use standard HTTP methods. Different URL endpoints represent different resources in a Workspace.  See the next sections for more information on how to use the Segment Public API. 
 *
 * The version of the OpenAPI document: 32.0.3
 * Contact: [email protected]
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package com.segment.publicapi.models;

import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.math.BigDecimal;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.segment.publicapi.JSON;

/**
 * A snapshot of MTU metrics within the given usage period.
 */
@ApiModel(description = "A snapshot of MTU metrics within the given usage period.")

public class MtuSnapshotV1 {
  public static final String SERIALIZED_NAME_PERIOD_START = "periodStart";
  @SerializedName(SERIALIZED_NAME_PERIOD_START)
  private BigDecimal periodStart;

  public static final String SERIALIZED_NAME_PERIOD_END = "periodEnd";
  @SerializedName(SERIALIZED_NAME_PERIOD_END)
  private BigDecimal periodEnd;

  public static final String SERIALIZED_NAME_ANONYMOUS = "anonymous";
  @SerializedName(SERIALIZED_NAME_ANONYMOUS)
  private String anonymous;

  public static final String SERIALIZED_NAME_ANONYMOUS_IDENTIFIED = "anonymousIdentified";
  @SerializedName(SERIALIZED_NAME_ANONYMOUS_IDENTIFIED)
  private String anonymousIdentified;

  public static final String SERIALIZED_NAME_IDENTIFIED = "identified";
  @SerializedName(SERIALIZED_NAME_IDENTIFIED)
  private String identified;

  public static final String SERIALIZED_NAME_NEVER_IDENTIFIED = "neverIdentified";
  @SerializedName(SERIALIZED_NAME_NEVER_IDENTIFIED)
  private String neverIdentified;

  public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp";
  @SerializedName(SERIALIZED_NAME_TIMESTAMP)
  private String timestamp;

  public MtuSnapshotV1() {
  }

  public MtuSnapshotV1 periodStart(BigDecimal periodStart) {
    
    this.periodStart = periodStart;
    return this;
  }

   /**
   * The start of the usage period, in unix time (seconds since epoch).
   * @return periodStart
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "The start of the usage period, in unix time (seconds since epoch).")

  public BigDecimal getPeriodStart() {
    return periodStart;
  }


  public void setPeriodStart(BigDecimal periodStart) {
    this.periodStart = periodStart;
  }


  public MtuSnapshotV1 periodEnd(BigDecimal periodEnd) {
    
    this.periodEnd = periodEnd;
    return this;
  }

   /**
   * The end of the usage period, in unix time (seconds since epoch).
   * @return periodEnd
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "The end of the usage period, in unix time (seconds since epoch).")

  public BigDecimal getPeriodEnd() {
    return periodEnd;
  }


  public void setPeriodEnd(BigDecimal periodEnd) {
    this.periodEnd = periodEnd;
  }


  public MtuSnapshotV1 anonymous(String anonymous) {
    
    this.anonymous = anonymous;
    return this;
  }

   /**
   * A bigint of the number of anonymous users in this snapshot.
   * @return anonymous
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "A bigint of the number of anonymous users in this snapshot.")

  public String getAnonymous() {
    return anonymous;
  }


  public void setAnonymous(String anonymous) {
    this.anonymous = anonymous;
  }


  public MtuSnapshotV1 anonymousIdentified(String anonymousIdentified) {
    
    this.anonymousIdentified = anonymousIdentified;
    return this;
  }

   /**
   * A bigint of the number of anonymous identified users in this snapshot.
   * @return anonymousIdentified
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "A bigint of the number of anonymous identified users in this snapshot.")

  public String getAnonymousIdentified() {
    return anonymousIdentified;
  }


  public void setAnonymousIdentified(String anonymousIdentified) {
    this.anonymousIdentified = anonymousIdentified;
  }


  public MtuSnapshotV1 identified(String identified) {
    
    this.identified = identified;
    return this;
  }

   /**
   * A bigint of the number of identified users in this snapshot.
   * @return identified
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "A bigint of the number of identified users in this snapshot.")

  public String getIdentified() {
    return identified;
  }


  public void setIdentified(String identified) {
    this.identified = identified;
  }


  public MtuSnapshotV1 neverIdentified(String neverIdentified) {
    
    this.neverIdentified = neverIdentified;
    return this;
  }

   /**
   * A bigint of the number of never identified users in this snapshot.
   * @return neverIdentified
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "A bigint of the number of never identified users in this snapshot.")

  public String getNeverIdentified() {
    return neverIdentified;
  }


  public void setNeverIdentified(String neverIdentified) {
    this.neverIdentified = neverIdentified;
  }


  public MtuSnapshotV1 timestamp(String timestamp) {
    
    this.timestamp = timestamp;
    return this;
  }

   /**
   * The timestamp of this snapshot within the billing cycle, in the ISO-8601 format.
   * @return timestamp
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "The timestamp of this snapshot within the billing cycle, in the ISO-8601 format.")

  public String getTimestamp() {
    return timestamp;
  }


  public void setTimestamp(String timestamp) {
    this.timestamp = timestamp;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    MtuSnapshotV1 mtuSnapshotV1 = (MtuSnapshotV1) o;
    return Objects.equals(this.periodStart, mtuSnapshotV1.periodStart) &&
        Objects.equals(this.periodEnd, mtuSnapshotV1.periodEnd) &&
        Objects.equals(this.anonymous, mtuSnapshotV1.anonymous) &&
        Objects.equals(this.anonymousIdentified, mtuSnapshotV1.anonymousIdentified) &&
        Objects.equals(this.identified, mtuSnapshotV1.identified) &&
        Objects.equals(this.neverIdentified, mtuSnapshotV1.neverIdentified) &&
        Objects.equals(this.timestamp, mtuSnapshotV1.timestamp);
  }

  @Override
  public int hashCode() {
    return Objects.hash(periodStart, periodEnd, anonymous, anonymousIdentified, identified, neverIdentified, timestamp);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class MtuSnapshotV1 {\n");
    sb.append("    periodStart: ").append(toIndentedString(periodStart)).append("\n");
    sb.append("    periodEnd: ").append(toIndentedString(periodEnd)).append("\n");
    sb.append("    anonymous: ").append(toIndentedString(anonymous)).append("\n");
    sb.append("    anonymousIdentified: ").append(toIndentedString(anonymousIdentified)).append("\n");
    sb.append("    identified: ").append(toIndentedString(identified)).append("\n");
    sb.append("    neverIdentified: ").append(toIndentedString(neverIdentified)).append("\n");
    sb.append("    timestamp: ").append(toIndentedString(timestamp)).append("\n");
    sb.append("}");
    return sb.toString();
  }

  /**
   * Convert the given object to string with each line indented by 4 spaces
   * (except the first line).
   */
  private String toIndentedString(Object o) {
    if (o == null) {
      return "null";
    }
    return o.toString().replace("\n", "\n    ");
  }


  public static HashSet openapiFields;
  public static HashSet openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet();
    openapiFields.add("periodStart");
    openapiFields.add("periodEnd");
    openapiFields.add("anonymous");
    openapiFields.add("anonymousIdentified");
    openapiFields.add("identified");
    openapiFields.add("neverIdentified");
    openapiFields.add("timestamp");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
    openapiRequiredFields.add("periodStart");
    openapiRequiredFields.add("periodEnd");
    openapiRequiredFields.add("anonymous");
    openapiRequiredFields.add("anonymousIdentified");
    openapiRequiredFields.add("identified");
    openapiRequiredFields.add("neverIdentified");
    openapiRequiredFields.add("timestamp");
  }

 /**
  * Validates the JSON Object and throws an exception if issues found
  *
  * @param jsonObj JSON Object
  * @throws IOException if the JSON Object is invalid with respect to MtuSnapshotV1
  */
  public static void validateJsonObject(JsonObject jsonObj) throws IOException {
      if (jsonObj == null) {
        if (!MtuSnapshotV1.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in MtuSnapshotV1 is not found in the empty JSON string", MtuSnapshotV1.openapiRequiredFields.toString()));
        }
      }

      Set> entries = jsonObj.entrySet();
      // check to see if the JSON string contains additional fields
      for (Entry entry : entries) {
        if (!MtuSnapshotV1.openapiFields.contains(entry.getKey())) {
          throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `MtuSnapshotV1` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : MtuSnapshotV1.openapiRequiredFields) {
        if (jsonObj.get(requiredField) == null) {
          throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
        }
      }
      if (!jsonObj.get("anonymous").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `anonymous` to be a primitive type in the JSON string but got `%s`", jsonObj.get("anonymous").toString()));
      }
      if (!jsonObj.get("anonymousIdentified").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `anonymousIdentified` to be a primitive type in the JSON string but got `%s`", jsonObj.get("anonymousIdentified").toString()));
      }
      if (!jsonObj.get("identified").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `identified` to be a primitive type in the JSON string but got `%s`", jsonObj.get("identified").toString()));
      }
      if (!jsonObj.get("neverIdentified").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `neverIdentified` to be a primitive type in the JSON string but got `%s`", jsonObj.get("neverIdentified").toString()));
      }
      if (!jsonObj.get("timestamp").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `timestamp` to be a primitive type in the JSON string but got `%s`", jsonObj.get("timestamp").toString()));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!MtuSnapshotV1.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'MtuSnapshotV1' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(MtuSnapshotV1.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, MtuSnapshotV1 value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             elementAdapter.write(out, obj);
           }

           @Override
           public MtuSnapshotV1 read(JsonReader in) throws IOException {
             JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
             validateJsonObject(jsonObj);
             return thisAdapter.fromJsonTree(jsonObj);
           }

       }.nullSafe();
    }
  }

 /**
  * Create an instance of MtuSnapshotV1 given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of MtuSnapshotV1
  * @throws IOException if the JSON string is invalid with respect to MtuSnapshotV1
  */
  public static MtuSnapshotV1 fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, MtuSnapshotV1.class);
  }

 /**
  * Convert an instance of MtuSnapshotV1 to an JSON string
  *
  * @return JSON string
  */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy