
com.segment.publicapi.models.UsersPerSourceSnapshotV1 Maven / Gradle / Ivy
/*
* 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 for a given Source within the given usage period.
*/
@ApiModel(description = "A snapshot of MTU metrics for a given Source within the given usage period.")
public class UsersPerSourceSnapshotV1 {
public static final String SERIALIZED_NAME_SOURCE_ID = "sourceId";
@SerializedName(SERIALIZED_NAME_SOURCE_ID)
private String sourceId;
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 UsersPerSourceSnapshotV1() {
}
public UsersPerSourceSnapshotV1 sourceId(String sourceId) {
this.sourceId = sourceId;
return this;
}
/**
* The Source id.
* @return sourceId
**/
@javax.annotation.Nonnull
@ApiModelProperty(required = true, value = "The Source id.")
public String getSourceId() {
return sourceId;
}
public void setSourceId(String sourceId) {
this.sourceId = sourceId;
}
public UsersPerSourceSnapshotV1 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 UsersPerSourceSnapshotV1 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 UsersPerSourceSnapshotV1 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 UsersPerSourceSnapshotV1 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 UsersPerSourceSnapshotV1 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 UsersPerSourceSnapshotV1 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 UsersPerSourceSnapshotV1 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;
}
UsersPerSourceSnapshotV1 usersPerSourceSnapshotV1 = (UsersPerSourceSnapshotV1) o;
return Objects.equals(this.sourceId, usersPerSourceSnapshotV1.sourceId) &&
Objects.equals(this.periodStart, usersPerSourceSnapshotV1.periodStart) &&
Objects.equals(this.periodEnd, usersPerSourceSnapshotV1.periodEnd) &&
Objects.equals(this.anonymous, usersPerSourceSnapshotV1.anonymous) &&
Objects.equals(this.anonymousIdentified, usersPerSourceSnapshotV1.anonymousIdentified) &&
Objects.equals(this.identified, usersPerSourceSnapshotV1.identified) &&
Objects.equals(this.neverIdentified, usersPerSourceSnapshotV1.neverIdentified) &&
Objects.equals(this.timestamp, usersPerSourceSnapshotV1.timestamp);
}
@Override
public int hashCode() {
return Objects.hash(sourceId, periodStart, periodEnd, anonymous, anonymousIdentified, identified, neverIdentified, timestamp);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UsersPerSourceSnapshotV1 {\n");
sb.append(" sourceId: ").append(toIndentedString(sourceId)).append("\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("sourceId");
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("sourceId");
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 UsersPerSourceSnapshotV1
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!UsersPerSourceSnapshotV1.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
throw new IllegalArgumentException(String.format("The required field(s) %s in UsersPerSourceSnapshotV1 is not found in the empty JSON string", UsersPerSourceSnapshotV1.openapiRequiredFields.toString()));
}
}
Set> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!UsersPerSourceSnapshotV1.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UsersPerSourceSnapshotV1` properties. JSON: %s", entry.getKey(), jsonObj.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : UsersPerSourceSnapshotV1.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("sourceId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `sourceId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sourceId").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 (!UsersPerSourceSnapshotV1.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'UsersPerSourceSnapshotV1' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(UsersPerSourceSnapshotV1.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, UsersPerSourceSnapshotV1 value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public UsersPerSourceSnapshotV1 read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of UsersPerSourceSnapshotV1 given an JSON string
*
* @param jsonString JSON string
* @return An instance of UsersPerSourceSnapshotV1
* @throws IOException if the JSON string is invalid with respect to UsersPerSourceSnapshotV1
*/
public static UsersPerSourceSnapshotV1 fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, UsersPerSourceSnapshotV1.class);
}
/**
* Convert an instance of UsersPerSourceSnapshotV1 to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy