
com.azure.resourcemanager.databricks.models.WorkspaceProviderAuthorization 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.databricks.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
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.Objects;
import java.util.UUID;
/**
* The workspace provider authorization.
*/
@Fluent
public final class WorkspaceProviderAuthorization implements JsonSerializable {
/*
* The provider's principal identifier. This is the identity that the provider will use to call ARM to manage the
* workspace resources.
*/
private UUID principalId;
/*
* The provider's role definition identifier. This role will define all the permissions that the provider must have
* on the workspace's container resource group. This role definition cannot have permission to delete the resource
* group.
*/
private UUID roleDefinitionId;
/**
* Creates an instance of WorkspaceProviderAuthorization class.
*/
public WorkspaceProviderAuthorization() {
}
/**
* Get the principalId property: The provider's principal identifier. This is the identity that the provider will
* use to call ARM to manage the workspace resources.
*
* @return the principalId value.
*/
public UUID principalId() {
return this.principalId;
}
/**
* Set the principalId property: The provider's principal identifier. This is the identity that the provider will
* use to call ARM to manage the workspace resources.
*
* @param principalId the principalId value to set.
* @return the WorkspaceProviderAuthorization object itself.
*/
public WorkspaceProviderAuthorization withPrincipalId(UUID principalId) {
this.principalId = principalId;
return this;
}
/**
* Get the roleDefinitionId property: The provider's role definition identifier. This role will define all the
* permissions that the provider must have on the workspace's container resource group. This role definition cannot
* have permission to delete the resource group.
*
* @return the roleDefinitionId value.
*/
public UUID roleDefinitionId() {
return this.roleDefinitionId;
}
/**
* Set the roleDefinitionId property: The provider's role definition identifier. This role will define all the
* permissions that the provider must have on the workspace's container resource group. This role definition cannot
* have permission to delete the resource group.
*
* @param roleDefinitionId the roleDefinitionId value to set.
* @return the WorkspaceProviderAuthorization object itself.
*/
public WorkspaceProviderAuthorization withRoleDefinitionId(UUID roleDefinitionId) {
this.roleDefinitionId = roleDefinitionId;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (principalId() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property principalId in model WorkspaceProviderAuthorization"));
}
if (roleDefinitionId() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property roleDefinitionId in model WorkspaceProviderAuthorization"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(WorkspaceProviderAuthorization.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("principalId", Objects.toString(this.principalId, null));
jsonWriter.writeStringField("roleDefinitionId", Objects.toString(this.roleDefinitionId, null));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of WorkspaceProviderAuthorization from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of WorkspaceProviderAuthorization if the JsonReader was pointing to an instance of it, or
* null if it was pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the WorkspaceProviderAuthorization.
*/
public static WorkspaceProviderAuthorization fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
WorkspaceProviderAuthorization deserializedWorkspaceProviderAuthorization
= new WorkspaceProviderAuthorization();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("principalId".equals(fieldName)) {
deserializedWorkspaceProviderAuthorization.principalId
= reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()));
} else if ("roleDefinitionId".equals(fieldName)) {
deserializedWorkspaceProviderAuthorization.roleDefinitionId
= reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString()));
} else {
reader.skipChildren();
}
}
return deserializedWorkspaceProviderAuthorization;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy