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

com.azure.resourcemanager.datafactory.models.UserAccessPolicy 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.datafactory.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;

/**
 * Get Data Plane read only token request definition.
 */
@Fluent
public final class UserAccessPolicy implements JsonSerializable {
    /*
     * The string with permissions for Data Plane access. Currently only 'r' is supported which grants read only access.
     */
    private String permissions;

    /*
     * The resource path to get access relative to factory. Currently only empty string is supported which corresponds
     * to the factory resource.
     */
    private String accessResourcePath;

    /*
     * The name of the profile. Currently only the default is supported. The default value is DefaultProfile.
     */
    private String profileName;

    /*
     * Start time for the token. If not specified the current time will be used.
     */
    private String startTime;

    /*
     * Expiration time for the token. Maximum duration for the token is eight hours and by default the token will expire
     * in eight hours.
     */
    private String expireTime;

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

    /**
     * Get the permissions property: The string with permissions for Data Plane access. Currently only 'r' is supported
     * which grants read only access.
     * 
     * @return the permissions value.
     */
    public String permissions() {
        return this.permissions;
    }

    /**
     * Set the permissions property: The string with permissions for Data Plane access. Currently only 'r' is supported
     * which grants read only access.
     * 
     * @param permissions the permissions value to set.
     * @return the UserAccessPolicy object itself.
     */
    public UserAccessPolicy withPermissions(String permissions) {
        this.permissions = permissions;
        return this;
    }

    /**
     * Get the accessResourcePath property: The resource path to get access relative to factory. Currently only empty
     * string is supported which corresponds to the factory resource.
     * 
     * @return the accessResourcePath value.
     */
    public String accessResourcePath() {
        return this.accessResourcePath;
    }

    /**
     * Set the accessResourcePath property: The resource path to get access relative to factory. Currently only empty
     * string is supported which corresponds to the factory resource.
     * 
     * @param accessResourcePath the accessResourcePath value to set.
     * @return the UserAccessPolicy object itself.
     */
    public UserAccessPolicy withAccessResourcePath(String accessResourcePath) {
        this.accessResourcePath = accessResourcePath;
        return this;
    }

    /**
     * Get the profileName property: The name of the profile. Currently only the default is supported. The default value
     * is DefaultProfile.
     * 
     * @return the profileName value.
     */
    public String profileName() {
        return this.profileName;
    }

    /**
     * Set the profileName property: The name of the profile. Currently only the default is supported. The default value
     * is DefaultProfile.
     * 
     * @param profileName the profileName value to set.
     * @return the UserAccessPolicy object itself.
     */
    public UserAccessPolicy withProfileName(String profileName) {
        this.profileName = profileName;
        return this;
    }

    /**
     * Get the startTime property: Start time for the token. If not specified the current time will be used.
     * 
     * @return the startTime value.
     */
    public String startTime() {
        return this.startTime;
    }

    /**
     * Set the startTime property: Start time for the token. If not specified the current time will be used.
     * 
     * @param startTime the startTime value to set.
     * @return the UserAccessPolicy object itself.
     */
    public UserAccessPolicy withStartTime(String startTime) {
        this.startTime = startTime;
        return this;
    }

    /**
     * Get the expireTime property: Expiration time for the token. Maximum duration for the token is eight hours and by
     * default the token will expire in eight hours.
     * 
     * @return the expireTime value.
     */
    public String expireTime() {
        return this.expireTime;
    }

    /**
     * Set the expireTime property: Expiration time for the token. Maximum duration for the token is eight hours and by
     * default the token will expire in eight hours.
     * 
     * @param expireTime the expireTime value to set.
     * @return the UserAccessPolicy object itself.
     */
    public UserAccessPolicy withExpireTime(String expireTime) {
        this.expireTime = expireTime;
        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("permissions", this.permissions);
        jsonWriter.writeStringField("accessResourcePath", this.accessResourcePath);
        jsonWriter.writeStringField("profileName", this.profileName);
        jsonWriter.writeStringField("startTime", this.startTime);
        jsonWriter.writeStringField("expireTime", this.expireTime);
        return jsonWriter.writeEndObject();
    }

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

                if ("permissions".equals(fieldName)) {
                    deserializedUserAccessPolicy.permissions = reader.getString();
                } else if ("accessResourcePath".equals(fieldName)) {
                    deserializedUserAccessPolicy.accessResourcePath = reader.getString();
                } else if ("profileName".equals(fieldName)) {
                    deserializedUserAccessPolicy.profileName = reader.getString();
                } else if ("startTime".equals(fieldName)) {
                    deserializedUserAccessPolicy.startTime = reader.getString();
                } else if ("expireTime".equals(fieldName)) {
                    deserializedUserAccessPolicy.expireTime = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedUserAccessPolicy;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy