
com.azure.resourcemanager.billing.models.SubscriptionPolicyProperties 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;
import java.util.List;
/**
* A policy at subscription scope.
*/
@Fluent
public final class SubscriptionPolicyProperties implements JsonSerializable {
/*
* The provisioning state of the resource during a long-running operation.
*/
private ProvisioningState provisioningState;
/*
* List of all policies defined at the billing scope.
*/
private List policies;
/**
* Creates an instance of SubscriptionPolicyProperties class.
*/
public SubscriptionPolicyProperties() {
}
/**
* Get the provisioningState property: The provisioning state of the resource during a long-running operation.
*
* @return the provisioningState value.
*/
public ProvisioningState provisioningState() {
return this.provisioningState;
}
/**
* Get the policies property: List of all policies defined at the billing scope.
*
* @return the policies value.
*/
public List policies() {
return this.policies;
}
/**
* Set the policies property: List of all policies defined at the billing scope.
*
* @param policies the policies value to set.
* @return the SubscriptionPolicyProperties object itself.
*/
public SubscriptionPolicyProperties withPolicies(List policies) {
this.policies = policies;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (policies() != null) {
policies().forEach(e -> e.validate());
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeArrayField("policies", this.policies, (writer, element) -> writer.writeJson(element));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of SubscriptionPolicyProperties from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of SubscriptionPolicyProperties 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 SubscriptionPolicyProperties.
*/
public static SubscriptionPolicyProperties fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
SubscriptionPolicyProperties deserializedSubscriptionPolicyProperties = new SubscriptionPolicyProperties();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("provisioningState".equals(fieldName)) {
deserializedSubscriptionPolicyProperties.provisioningState
= ProvisioningState.fromString(reader.getString());
} else if ("policies".equals(fieldName)) {
List policies = reader.readArray(reader1 -> PolicySummary.fromJson(reader1));
deserializedSubscriptionPolicyProperties.policies = policies;
} else {
reader.skipChildren();
}
}
return deserializedSubscriptionPolicyProperties;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy