com.azure.resourcemanager.security.models.Authorization 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.security.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;
/**
* Authorization payload.
*/
@Fluent
public final class Authorization implements JsonSerializable {
/*
* Gets or sets one-time OAuth code to exchange for refresh and access tokens.
*
* Only used during PUT/PATCH operations. The secret is cleared during GET.
*/
private String code;
/**
* Creates an instance of Authorization class.
*/
public Authorization() {
}
/**
* Get the code property: Gets or sets one-time OAuth code to exchange for refresh and access tokens.
*
* Only used during PUT/PATCH operations. The secret is cleared during GET.
*
* @return the code value.
*/
public String code() {
return this.code;
}
/**
* Set the code property: Gets or sets one-time OAuth code to exchange for refresh and access tokens.
*
* Only used during PUT/PATCH operations. The secret is cleared during GET.
*
* @param code the code value to set.
* @return the Authorization object itself.
*/
public Authorization withCode(String code) {
this.code = code;
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("code", this.code);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of Authorization from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of Authorization 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 Authorization.
*/
public static Authorization fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
Authorization deserializedAuthorization = new Authorization();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("code".equals(fieldName)) {
deserializedAuthorization.code = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedAuthorization;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy