
com.azure.resourcemanager.billing.models.Principal Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.billing.models;
import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* A principal who has interacted with a billing entity.
*/
@Fluent
public class Principal implements JsonSerializable {
/*
* The tenant id of the principal who has interacted with a billing entity.
*/
private String tenantId;
/*
* The object id of the principal who has interacted with a billing entity.
*/
private String objectId;
/*
* The user principal name of the principal who has interacted with a billing entity.
*/
private String upn;
/**
* Creates an instance of Principal class.
*/
public Principal() {
}
/**
* Get the tenantId property: The tenant id of the principal who has interacted with a billing entity.
*
* @return the tenantId value.
*/
public String tenantId() {
return this.tenantId;
}
/**
* Set the tenantId property: The tenant id of the principal who has interacted with a billing entity.
*
* @param tenantId the tenantId value to set.
* @return the Principal object itself.
*/
public Principal withTenantId(String tenantId) {
this.tenantId = tenantId;
return this;
}
/**
* Get the objectId property: The object id of the principal who has interacted with a billing entity.
*
* @return the objectId value.
*/
public String objectId() {
return this.objectId;
}
/**
* Set the objectId property: The object id of the principal who has interacted with a billing entity.
*
* @param objectId the objectId value to set.
* @return the Principal object itself.
*/
public Principal withObjectId(String objectId) {
this.objectId = objectId;
return this;
}
/**
* Get the upn property: The user principal name of the principal who has interacted with a billing entity.
*
* @return the upn value.
*/
public String upn() {
return this.upn;
}
/**
* Set the upn property: The user principal name of the principal who has interacted with a billing entity.
*
* @param upn the upn value to set.
* @return the Principal object itself.
*/
public Principal withUpn(String upn) {
this.upn = upn;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("tenantId", this.tenantId);
jsonWriter.writeStringField("objectId", this.objectId);
jsonWriter.writeStringField("upn", this.upn);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of Principal from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of Principal if the JsonReader was pointing to an instance of it, or null if it was pointing
* to JSON null.
* @throws IOException If an error occurs while reading the Principal.
*/
public static Principal fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
Principal deserializedPrincipal = new Principal();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("tenantId".equals(fieldName)) {
deserializedPrincipal.tenantId = reader.getString();
} else if ("objectId".equals(fieldName)) {
deserializedPrincipal.objectId = reader.getString();
} else if ("upn".equals(fieldName)) {
deserializedPrincipal.upn = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedPrincipal;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy