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

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

/**
 * Factory's git repo information.
 */
@Fluent
public class FactoryRepoConfiguration implements JsonSerializable {
    /*
     * Type of repo configuration.
     */
    private String type = "FactoryRepoConfiguration";

    /*
     * Account name.
     */
    private String accountName;

    /*
     * Repository name.
     */
    private String repositoryName;

    /*
     * Collaboration branch.
     */
    private String collaborationBranch;

    /*
     * Root folder.
     */
    private String rootFolder;

    /*
     * Last commit id.
     */
    private String lastCommitId;

    /*
     * Disable manual publish operation in ADF studio to favor automated publish.
     */
    private Boolean disablePublish;

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

    /**
     * Get the type property: Type of repo configuration.
     * 
     * @return the type value.
     */
    public String type() {
        return this.type;
    }

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

    /**
     * Set the accountName property: Account name.
     * 
     * @param accountName the accountName value to set.
     * @return the FactoryRepoConfiguration object itself.
     */
    public FactoryRepoConfiguration withAccountName(String accountName) {
        this.accountName = accountName;
        return this;
    }

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

    /**
     * Set the repositoryName property: Repository name.
     * 
     * @param repositoryName the repositoryName value to set.
     * @return the FactoryRepoConfiguration object itself.
     */
    public FactoryRepoConfiguration withRepositoryName(String repositoryName) {
        this.repositoryName = repositoryName;
        return this;
    }

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

    /**
     * Set the collaborationBranch property: Collaboration branch.
     * 
     * @param collaborationBranch the collaborationBranch value to set.
     * @return the FactoryRepoConfiguration object itself.
     */
    public FactoryRepoConfiguration withCollaborationBranch(String collaborationBranch) {
        this.collaborationBranch = collaborationBranch;
        return this;
    }

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

    /**
     * Set the rootFolder property: Root folder.
     * 
     * @param rootFolder the rootFolder value to set.
     * @return the FactoryRepoConfiguration object itself.
     */
    public FactoryRepoConfiguration withRootFolder(String rootFolder) {
        this.rootFolder = rootFolder;
        return this;
    }

    /**
     * Get the lastCommitId property: Last commit id.
     * 
     * @return the lastCommitId value.
     */
    public String lastCommitId() {
        return this.lastCommitId;
    }

    /**
     * Set the lastCommitId property: Last commit id.
     * 
     * @param lastCommitId the lastCommitId value to set.
     * @return the FactoryRepoConfiguration object itself.
     */
    public FactoryRepoConfiguration withLastCommitId(String lastCommitId) {
        this.lastCommitId = lastCommitId;
        return this;
    }

    /**
     * Get the disablePublish property: Disable manual publish operation in ADF studio to favor automated publish.
     * 
     * @return the disablePublish value.
     */
    public Boolean disablePublish() {
        return this.disablePublish;
    }

    /**
     * Set the disablePublish property: Disable manual publish operation in ADF studio to favor automated publish.
     * 
     * @param disablePublish the disablePublish value to set.
     * @return the FactoryRepoConfiguration object itself.
     */
    public FactoryRepoConfiguration withDisablePublish(Boolean disablePublish) {
        this.disablePublish = disablePublish;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (accountName() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property accountName in model FactoryRepoConfiguration"));
        }
        if (repositoryName() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property repositoryName in model FactoryRepoConfiguration"));
        }
        if (collaborationBranch() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property collaborationBranch in model FactoryRepoConfiguration"));
        }
        if (rootFolder() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property rootFolder in model FactoryRepoConfiguration"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(FactoryRepoConfiguration.class);

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("accountName", this.accountName);
        jsonWriter.writeStringField("repositoryName", this.repositoryName);
        jsonWriter.writeStringField("collaborationBranch", this.collaborationBranch);
        jsonWriter.writeStringField("rootFolder", this.rootFolder);
        jsonWriter.writeStringField("type", this.type);
        jsonWriter.writeStringField("lastCommitId", this.lastCommitId);
        jsonWriter.writeBooleanField("disablePublish", this.disablePublish);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of FactoryRepoConfiguration from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of FactoryRepoConfiguration 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 FactoryRepoConfiguration.
     */
    public static FactoryRepoConfiguration fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            String discriminatorValue = null;
            try (JsonReader readerToUse = reader.bufferObject()) {
                readerToUse.nextToken(); // Prepare for reading
                while (readerToUse.nextToken() != JsonToken.END_OBJECT) {
                    String fieldName = readerToUse.getFieldName();
                    readerToUse.nextToken();
                    if ("type".equals(fieldName)) {
                        discriminatorValue = readerToUse.getString();
                        break;
                    } else {
                        readerToUse.skipChildren();
                    }
                }
                // Use the discriminator value to determine which subtype should be deserialized.
                if ("FactoryVSTSConfiguration".equals(discriminatorValue)) {
                    return FactoryVstsConfiguration.fromJson(readerToUse.reset());
                } else if ("FactoryGitHubConfiguration".equals(discriminatorValue)) {
                    return FactoryGitHubConfiguration.fromJson(readerToUse.reset());
                } else {
                    return fromJsonKnownDiscriminator(readerToUse.reset());
                }
            }
        });
    }

    static FactoryRepoConfiguration fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            FactoryRepoConfiguration deserializedFactoryRepoConfiguration = new FactoryRepoConfiguration();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("accountName".equals(fieldName)) {
                    deserializedFactoryRepoConfiguration.accountName = reader.getString();
                } else if ("repositoryName".equals(fieldName)) {
                    deserializedFactoryRepoConfiguration.repositoryName = reader.getString();
                } else if ("collaborationBranch".equals(fieldName)) {
                    deserializedFactoryRepoConfiguration.collaborationBranch = reader.getString();
                } else if ("rootFolder".equals(fieldName)) {
                    deserializedFactoryRepoConfiguration.rootFolder = reader.getString();
                } else if ("type".equals(fieldName)) {
                    deserializedFactoryRepoConfiguration.type = reader.getString();
                } else if ("lastCommitId".equals(fieldName)) {
                    deserializedFactoryRepoConfiguration.lastCommitId = reader.getString();
                } else if ("disablePublish".equals(fieldName)) {
                    deserializedFactoryRepoConfiguration.disablePublish = reader.getNullable(JsonReader::getBoolean);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedFactoryRepoConfiguration;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy