All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.monitor.models.SenderAuthorization Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure Monitor SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt

The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.monitor.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;

/**
 * the authorization used by the user who has performed the operation that led to this event. This captures the RBAC
 * properties of the event. These usually include the 'action', 'role' and the 'scope'.
 */
@Fluent
public final class SenderAuthorization implements JsonSerializable {
    /*
     * the permissible actions. For instance: microsoft.support/supporttickets/write
     */
    private String action;

    /*
     * the role of the user. For instance: Subscription Admin
     */
    private String role;

    /*
     * the scope.
     */
    private String scope;

    /**
     * Creates an instance of SenderAuthorization class.
     */
    public SenderAuthorization() {
    }

    /**
     * Get the action property: the permissible actions. For instance: microsoft.support/supporttickets/write.
     * 
     * @return the action value.
     */
    public String action() {
        return this.action;
    }

    /**
     * Set the action property: the permissible actions. For instance: microsoft.support/supporttickets/write.
     * 
     * @param action the action value to set.
     * @return the SenderAuthorization object itself.
     */
    public SenderAuthorization withAction(String action) {
        this.action = action;
        return this;
    }

    /**
     * Get the role property: the role of the user. For instance: Subscription Admin.
     * 
     * @return the role value.
     */
    public String role() {
        return this.role;
    }

    /**
     * Set the role property: the role of the user. For instance: Subscription Admin.
     * 
     * @param role the role value to set.
     * @return the SenderAuthorization object itself.
     */
    public SenderAuthorization withRole(String role) {
        this.role = role;
        return this;
    }

    /**
     * Get the scope property: the scope.
     * 
     * @return the scope value.
     */
    public String scope() {
        return this.scope;
    }

    /**
     * Set the scope property: the scope.
     * 
     * @param scope the scope value to set.
     * @return the SenderAuthorization object itself.
     */
    public SenderAuthorization withScope(String scope) {
        this.scope = scope;
        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("action", this.action);
        jsonWriter.writeStringField("role", this.role);
        jsonWriter.writeStringField("scope", this.scope);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of SenderAuthorization from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of SenderAuthorization 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 SenderAuthorization.
     */
    public static SenderAuthorization fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            SenderAuthorization deserializedSenderAuthorization = new SenderAuthorization();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("action".equals(fieldName)) {
                    deserializedSenderAuthorization.action = reader.getString();
                } else if ("role".equals(fieldName)) {
                    deserializedSenderAuthorization.role = reader.getString();
                } else if ("scope".equals(fieldName)) {
                    deserializedSenderAuthorization.scope = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSenderAuthorization;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy