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

package com.azure.resourcemanager.automation.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.automation.fluent.models.SourceControlCreateOrUpdateProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/** The parameters supplied to the create or update source control operation. */
@Fluent
public final class SourceControlCreateOrUpdateParameters {
    /*
     * The properties of the source control.
     */
    @JsonProperty(value = "properties", required = true)
    private SourceControlCreateOrUpdateProperties innerProperties = new SourceControlCreateOrUpdateProperties();

    /**
     * Get the innerProperties property: The properties of the source control.
     *
     * @return the innerProperties value.
     */
    private SourceControlCreateOrUpdateProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the repoUrl property: The repo url of the source control.
     *
     * @return the repoUrl value.
     */
    public String repoUrl() {
        return this.innerProperties() == null ? null : this.innerProperties().repoUrl();
    }

    /**
     * Set the repoUrl property: The repo url of the source control.
     *
     * @param repoUrl the repoUrl value to set.
     * @return the SourceControlCreateOrUpdateParameters object itself.
     */
    public SourceControlCreateOrUpdateParameters withRepoUrl(String repoUrl) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SourceControlCreateOrUpdateProperties();
        }
        this.innerProperties().withRepoUrl(repoUrl);
        return this;
    }

    /**
     * Get the branch property: The repo branch of the source control. Include branch as empty string for VsoTfvc.
     *
     * @return the branch value.
     */
    public String branch() {
        return this.innerProperties() == null ? null : this.innerProperties().branch();
    }

    /**
     * Set the branch property: The repo branch of the source control. Include branch as empty string for VsoTfvc.
     *
     * @param branch the branch value to set.
     * @return the SourceControlCreateOrUpdateParameters object itself.
     */
    public SourceControlCreateOrUpdateParameters withBranch(String branch) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SourceControlCreateOrUpdateProperties();
        }
        this.innerProperties().withBranch(branch);
        return this;
    }

    /**
     * Get the folderPath property: The folder path of the source control. Path must be relative.
     *
     * @return the folderPath value.
     */
    public String folderPath() {
        return this.innerProperties() == null ? null : this.innerProperties().folderPath();
    }

    /**
     * Set the folderPath property: The folder path of the source control. Path must be relative.
     *
     * @param folderPath the folderPath value to set.
     * @return the SourceControlCreateOrUpdateParameters object itself.
     */
    public SourceControlCreateOrUpdateParameters withFolderPath(String folderPath) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SourceControlCreateOrUpdateProperties();
        }
        this.innerProperties().withFolderPath(folderPath);
        return this;
    }

    /**
     * Get the autoSync property: The auto async of the source control. Default is false.
     *
     * @return the autoSync value.
     */
    public Boolean autoSync() {
        return this.innerProperties() == null ? null : this.innerProperties().autoSync();
    }

    /**
     * Set the autoSync property: The auto async of the source control. Default is false.
     *
     * @param autoSync the autoSync value to set.
     * @return the SourceControlCreateOrUpdateParameters object itself.
     */
    public SourceControlCreateOrUpdateParameters withAutoSync(Boolean autoSync) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SourceControlCreateOrUpdateProperties();
        }
        this.innerProperties().withAutoSync(autoSync);
        return this;
    }

    /**
     * Get the publishRunbook property: The auto publish of the source control. Default is true.
     *
     * @return the publishRunbook value.
     */
    public Boolean publishRunbook() {
        return this.innerProperties() == null ? null : this.innerProperties().publishRunbook();
    }

    /**
     * Set the publishRunbook property: The auto publish of the source control. Default is true.
     *
     * @param publishRunbook the publishRunbook value to set.
     * @return the SourceControlCreateOrUpdateParameters object itself.
     */
    public SourceControlCreateOrUpdateParameters withPublishRunbook(Boolean publishRunbook) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SourceControlCreateOrUpdateProperties();
        }
        this.innerProperties().withPublishRunbook(publishRunbook);
        return this;
    }

    /**
     * Get the sourceType property: The source type. Must be one of VsoGit, VsoTfvc, GitHub, case sensitive.
     *
     * @return the sourceType value.
     */
    public SourceType sourceType() {
        return this.innerProperties() == null ? null : this.innerProperties().sourceType();
    }

    /**
     * Set the sourceType property: The source type. Must be one of VsoGit, VsoTfvc, GitHub, case sensitive.
     *
     * @param sourceType the sourceType value to set.
     * @return the SourceControlCreateOrUpdateParameters object itself.
     */
    public SourceControlCreateOrUpdateParameters withSourceType(SourceType sourceType) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SourceControlCreateOrUpdateProperties();
        }
        this.innerProperties().withSourceType(sourceType);
        return this;
    }

    /**
     * Get the securityToken property: The authorization token for the repo of the source control.
     *
     * @return the securityToken value.
     */
    public SourceControlSecurityTokenProperties securityToken() {
        return this.innerProperties() == null ? null : this.innerProperties().securityToken();
    }

    /**
     * Set the securityToken property: The authorization token for the repo of the source control.
     *
     * @param securityToken the securityToken value to set.
     * @return the SourceControlCreateOrUpdateParameters object itself.
     */
    public SourceControlCreateOrUpdateParameters withSecurityToken(SourceControlSecurityTokenProperties securityToken) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SourceControlCreateOrUpdateProperties();
        }
        this.innerProperties().withSecurityToken(securityToken);
        return this;
    }

    /**
     * Get the description property: The user description of the source control.
     *
     * @return the description value.
     */
    public String description() {
        return this.innerProperties() == null ? null : this.innerProperties().description();
    }

    /**
     * Set the description property: The user description of the source control.
     *
     * @param description the description value to set.
     * @return the SourceControlCreateOrUpdateParameters object itself.
     */
    public SourceControlCreateOrUpdateParameters withDescription(String description) {
        if (this.innerProperties() == null) {
            this.innerProperties = new SourceControlCreateOrUpdateProperties();
        }
        this.innerProperties().withDescription(description);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (innerProperties() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property innerProperties in model SourceControlCreateOrUpdateParameters"));
        } else {
            innerProperties().validate();
        }
    }

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