com.azure.resourcemanager.servicelinker.models.AccessKeyInfoBase 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.servicelinker.models;
import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;
/**
* The access key directly from target resource properties, which target service is Azure Resource, such as
* Microsoft.Storage.
*/
@Fluent
public final class AccessKeyInfoBase extends AuthInfoBase {
/*
* The authentication type.
*/
private AuthType authType = AuthType.ACCESS_KEY;
/*
* Permissions of the accessKey. `Read` and `Write` are for Azure Cosmos DB and Azure App Configuration, `Listen`,
* `Send` and `Manage` are for Azure Event Hub and Azure Service Bus.
*/
private List permissions;
/**
* Creates an instance of AccessKeyInfoBase class.
*/
public AccessKeyInfoBase() {
}
/**
* Get the authType property: The authentication type.
*
* @return the authType value.
*/
@Override
public AuthType authType() {
return this.authType;
}
/**
* Get the permissions property: Permissions of the accessKey. `Read` and `Write` are for Azure Cosmos DB and Azure
* App Configuration, `Listen`, `Send` and `Manage` are for Azure Event Hub and Azure Service Bus.
*
* @return the permissions value.
*/
public List permissions() {
return this.permissions;
}
/**
* Set the permissions property: Permissions of the accessKey. `Read` and `Write` are for Azure Cosmos DB and Azure
* App Configuration, `Listen`, `Send` and `Manage` are for Azure Event Hub and Azure Service Bus.
*
* @param permissions the permissions value to set.
* @return the AccessKeyInfoBase object itself.
*/
public AccessKeyInfoBase withPermissions(List permissions) {
this.permissions = permissions;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public AccessKeyInfoBase withAuthMode(AuthMode authMode) {
super.withAuthMode(authMode);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("authMode", authMode() == null ? null : authMode().toString());
jsonWriter.writeStringField("authType", this.authType == null ? null : this.authType.toString());
jsonWriter.writeArrayField("permissions", this.permissions,
(writer, element) -> writer.writeString(element == null ? null : element.toString()));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of AccessKeyInfoBase from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of AccessKeyInfoBase 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 AccessKeyInfoBase.
*/
public static AccessKeyInfoBase fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
AccessKeyInfoBase deserializedAccessKeyInfoBase = new AccessKeyInfoBase();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("authMode".equals(fieldName)) {
deserializedAccessKeyInfoBase.withAuthMode(AuthMode.fromString(reader.getString()));
} else if ("authType".equals(fieldName)) {
deserializedAccessKeyInfoBase.authType = AuthType.fromString(reader.getString());
} else if ("permissions".equals(fieldName)) {
List permissions
= reader.readArray(reader1 -> AccessKeyPermissions.fromString(reader1.getString()));
deserializedAccessKeyInfoBase.permissions = permissions;
} else {
reader.skipChildren();
}
}
return deserializedAccessKeyInfoBase;
});
}
}