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

package com.azure.resourcemanager.securityinsights.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.securityinsights.models.ContentType;
import com.azure.resourcemanager.securityinsights.models.DeploymentInfo;
import com.azure.resourcemanager.securityinsights.models.RepoType;
import com.azure.resourcemanager.securityinsights.models.Repository;
import com.azure.resourcemanager.securityinsights.models.RepositoryResourceInfo;
import com.azure.resourcemanager.securityinsights.models.Version;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Describes source control properties. */
@Fluent
public final class SourceControlProperties {
    /*
     * The id (a Guid) of the source control
     */
    @JsonProperty(value = "id")
    private String id;

    /*
     * The version number associated with the source control
     */
    @JsonProperty(value = "version")
    private Version version;

    /*
     * The display name of the source control
     */
    @JsonProperty(value = "displayName", required = true)
    private String displayName;

    /*
     * A description of the source control
     */
    @JsonProperty(value = "description")
    private String description;

    /*
     * The repository type of the source control
     */
    @JsonProperty(value = "repoType", required = true)
    private RepoType repoType;

    /*
     * Array of source control content types.
     */
    @JsonProperty(value = "contentTypes", required = true)
    private List<ContentType> contentTypes;

    /*
     * Repository metadata.
     */
    @JsonProperty(value = "repository", required = true)
    private Repository repository;

    /*
     * Information regarding the resources created in user's repository.
     */
    @JsonProperty(value = "repositoryResourceInfo")
    private RepositoryResourceInfo repositoryResourceInfo;

    /*
     * Information regarding the latest deployment for the source control.
     */
    @JsonProperty(value = "lastDeploymentInfo")
    private DeploymentInfo lastDeploymentInfo;

    /**
     * Get the id property: The id (a Guid) of the source control.
     *
     * @return the id value.
     */
    public String id() {
        return this.id;
    }

    /**
     * Set the id property: The id (a Guid) of the source control.
     *
     * @param id the id value to set.
     * @return the SourceControlProperties object itself.
     */
    public SourceControlProperties withId(String id) {
        this.id = id;
        return this;
    }

    /**
     * Get the version property: The version number associated with the source control.
     *
     * @return the version value.
     */
    public Version version() {
        return this.version;
    }

    /**
     * Set the version property: The version number associated with the source control.
     *
     * @param version the version value to set.
     * @return the SourceControlProperties object itself.
     */
    public SourceControlProperties withVersion(Version version) {
        this.version = version;
        return this;
    }

    /**
     * Get the displayName property: The display name of the source control.
     *
     * @return the displayName value.
     */
    public String displayName() {
        return this.displayName;
    }

    /**
     * Set the displayName property: The display name of the source control.
     *
     * @param displayName the displayName value to set.
     * @return the SourceControlProperties object itself.
     */
    public SourceControlProperties withDisplayName(String displayName) {
        this.displayName = displayName;
        return this;
    }

    /**
     * Get the description property: A description of the source control.
     *
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: A description of the source control.
     *
     * @param description the description value to set.
     * @return the SourceControlProperties object itself.
     */
    public SourceControlProperties withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * Get the repoType property: The repository type of the source control.
     *
     * @return the repoType value.
     */
    public RepoType repoType() {
        return this.repoType;
    }

    /**
     * Set the repoType property: The repository type of the source control.
     *
     * @param repoType the repoType value to set.
     * @return the SourceControlProperties object itself.
     */
    public SourceControlProperties withRepoType(RepoType repoType) {
        this.repoType = repoType;
        return this;
    }

    /**
     * Get the contentTypes property: Array of source control content types.
     *
     * @return the contentTypes value.
     */
    public List<ContentType> contentTypes() {
        return this.contentTypes;
    }

    /**
     * Set the contentTypes property: Array of source control content types.
     *
     * @param contentTypes the contentTypes value to set.
     * @return the SourceControlProperties object itself.
     */
    public SourceControlProperties withContentTypes(List<ContentType> contentTypes) {
        this.contentTypes = contentTypes;
        return this;
    }

    /**
     * Get the repository property: Repository metadata.
     *
     * @return the repository value.
     */
    public Repository repository() {
        return this.repository;
    }

    /**
     * Set the repository property: Repository metadata.
     *
     * @param repository the repository value to set.
     * @return the SourceControlProperties object itself.
     */
    public SourceControlProperties withRepository(Repository repository) {
        this.repository = repository;
        return this;
    }

    /**
     * Get the repositoryResourceInfo property: Information regarding the resources created in user's repository.
     *
     * @return the repositoryResourceInfo value.
     */
    public RepositoryResourceInfo repositoryResourceInfo() {
        return this.repositoryResourceInfo;
    }

    /**
     * Set the repositoryResourceInfo property: Information regarding the resources created in user's repository.
     *
     * @param repositoryResourceInfo the repositoryResourceInfo value to set.
     * @return the SourceControlProperties object itself.
     */
    public SourceControlProperties withRepositoryResourceInfo(RepositoryResourceInfo repositoryResourceInfo) {
        this.repositoryResourceInfo = repositoryResourceInfo;
        return this;
    }

    /**
     * Get the lastDeploymentInfo property: Information regarding the latest deployment for the source control.
     *
     * @return the lastDeploymentInfo value.
     */
    public DeploymentInfo lastDeploymentInfo() {
        return this.lastDeploymentInfo;
    }

    /**
     * Set the lastDeploymentInfo property: Information regarding the latest deployment for the source control.
     *
     * @param lastDeploymentInfo the lastDeploymentInfo value to set.
     * @return the SourceControlProperties object itself.
     */
    public SourceControlProperties withLastDeploymentInfo(DeploymentInfo lastDeploymentInfo) {
        this.lastDeploymentInfo = lastDeploymentInfo;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (displayName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property displayName in model SourceControlProperties"));
        }
        if (repoType() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property repoType in model SourceControlProperties"));
        }
        if (contentTypes() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property contentTypes in model SourceControlProperties"));
        }
        if (repository() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property repository in model SourceControlProperties"));
        } else {
            repository().validate();
        }
        if (repositoryResourceInfo() != null) {
            repositoryResourceInfo().validate();
        }
        if (lastDeploymentInfo() != null) {
            lastDeploymentInfo().validate();
        }
    }

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