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

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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.managedapplications.models.ApplicationArtifact;
import com.azure.resourcemanager.managedapplications.models.ApplicationLockLevel;
import com.azure.resourcemanager.managedapplications.models.ApplicationProviderAuthorization;
import com.azure.resourcemanager.managedapplications.models.GenericResource;
import com.azure.resourcemanager.managedapplications.models.Identity;
import com.azure.resourcemanager.managedapplications.models.Sku;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** Information about managed application definition. */
@Fluent
public final class ApplicationDefinitionInner extends GenericResource {
    /*
     * The managed application definition properties.
     */
    @JsonProperty(value = "properties", required = true)
    private ApplicationDefinitionProperties innerProperties = new ApplicationDefinitionProperties();

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

    /**
     * Get the innerProperties property: The managed application definition properties.
     *
     * @return the innerProperties value.
     */
    private ApplicationDefinitionProperties innerProperties() {
        return this.innerProperties;
    }

    /** {@inheritDoc} */
    @Override
    public ApplicationDefinitionInner withManagedBy(String managedBy) {
        super.withManagedBy(managedBy);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public ApplicationDefinitionInner withSku(Sku sku) {
        super.withSku(sku);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public ApplicationDefinitionInner withIdentity(Identity identity) {
        super.withIdentity(identity);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public ApplicationDefinitionInner withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public ApplicationDefinitionInner withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

    /**
     * Get the lockLevel property: The managed application lock level.
     *
     * @return the lockLevel value.
     */
    public ApplicationLockLevel lockLevel() {
        return this.innerProperties() == null ? null : this.innerProperties().lockLevel();
    }

    /**
     * Set the lockLevel property: The managed application lock level.
     *
     * @param lockLevel the lockLevel value to set.
     * @return the ApplicationDefinitionInner object itself.
     */
    public ApplicationDefinitionInner withLockLevel(ApplicationLockLevel lockLevel) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ApplicationDefinitionProperties();
        }
        this.innerProperties().withLockLevel(lockLevel);
        return this;
    }

    /**
     * Get the displayName property: The managed application definition display name.
     *
     * @return the displayName value.
     */
    public String displayName() {
        return this.innerProperties() == null ? null : this.innerProperties().displayName();
    }

    /**
     * Set the displayName property: The managed application definition display name.
     *
     * @param displayName the displayName value to set.
     * @return the ApplicationDefinitionInner object itself.
     */
    public ApplicationDefinitionInner withDisplayName(String displayName) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ApplicationDefinitionProperties();
        }
        this.innerProperties().withDisplayName(displayName);
        return this;
    }

    /**
     * Get the isEnabled property: A value indicating whether the package is enabled or not.
     *
     * @return the isEnabled value.
     */
    public String isEnabled() {
        return this.innerProperties() == null ? null : this.innerProperties().isEnabled();
    }

    /**
     * Set the isEnabled property: A value indicating whether the package is enabled or not.
     *
     * @param isEnabled the isEnabled value to set.
     * @return the ApplicationDefinitionInner object itself.
     */
    public ApplicationDefinitionInner withIsEnabled(String isEnabled) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ApplicationDefinitionProperties();
        }
        this.innerProperties().withIsEnabled(isEnabled);
        return this;
    }

    /**
     * Get the authorizations property: The managed application provider authorizations.
     *
     * @return the authorizations value.
     */
    public List<ApplicationProviderAuthorization> authorizations() {
        return this.innerProperties() == null ? null : this.innerProperties().authorizations();
    }

    /**
     * Set the authorizations property: The managed application provider authorizations.
     *
     * @param authorizations the authorizations value to set.
     * @return the ApplicationDefinitionInner object itself.
     */
    public ApplicationDefinitionInner withAuthorizations(List<ApplicationProviderAuthorization> authorizations) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ApplicationDefinitionProperties();
        }
        this.innerProperties().withAuthorizations(authorizations);
        return this;
    }

    /**
     * Get the artifacts property: The collection of managed application artifacts. The portal will use the files
     * specified as artifacts to construct the user experience of creating a managed application from a managed
     * application definition.
     *
     * @return the artifacts value.
     */
    public List<ApplicationArtifact> artifacts() {
        return this.innerProperties() == null ? null : this.innerProperties().artifacts();
    }

    /**
     * Set the artifacts property: The collection of managed application artifacts. The portal will use the files
     * specified as artifacts to construct the user experience of creating a managed application from a managed
     * application definition.
     *
     * @param artifacts the artifacts value to set.
     * @return the ApplicationDefinitionInner object itself.
     */
    public ApplicationDefinitionInner withArtifacts(List<ApplicationArtifact> artifacts) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ApplicationDefinitionProperties();
        }
        this.innerProperties().withArtifacts(artifacts);
        return this;
    }

    /**
     * Get the description property: The managed application definition description.
     *
     * @return the description value.
     */
    public String description() {
        return this.innerProperties() == null ? null : this.innerProperties().description();
    }

    /**
     * Set the description property: The managed application definition description.
     *
     * @param description the description value to set.
     * @return the ApplicationDefinitionInner object itself.
     */
    public ApplicationDefinitionInner withDescription(String description) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ApplicationDefinitionProperties();
        }
        this.innerProperties().withDescription(description);
        return this;
    }

    /**
     * Get the packageFileUri property: The managed application definition package file Uri. Use this element.
     *
     * @return the packageFileUri value.
     */
    public String packageFileUri() {
        return this.innerProperties() == null ? null : this.innerProperties().packageFileUri();
    }

    /**
     * Set the packageFileUri property: The managed application definition package file Uri. Use this element.
     *
     * @param packageFileUri the packageFileUri value to set.
     * @return the ApplicationDefinitionInner object itself.
     */
    public ApplicationDefinitionInner withPackageFileUri(String packageFileUri) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ApplicationDefinitionProperties();
        }
        this.innerProperties().withPackageFileUri(packageFileUri);
        return this;
    }

    /**
     * Get the mainTemplate property: The inline main template json which has resources to be provisioned. It can be a
     * JObject or well-formed JSON string.
     *
     * @return the mainTemplate value.
     */
    public Object mainTemplate() {
        return this.innerProperties() == null ? null : this.innerProperties().mainTemplate();
    }

    /**
     * Set the mainTemplate property: The inline main template json which has resources to be provisioned. It can be a
     * JObject or well-formed JSON string.
     *
     * @param mainTemplate the mainTemplate value to set.
     * @return the ApplicationDefinitionInner object itself.
     */
    public ApplicationDefinitionInner withMainTemplate(Object mainTemplate) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ApplicationDefinitionProperties();
        }
        this.innerProperties().withMainTemplate(mainTemplate);
        return this;
    }

    /**
     * Get the createUiDefinition property: The createUiDefinition json for the backing template with
     * Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string.
     *
     * @return the createUiDefinition value.
     */
    public Object createUiDefinition() {
        return this.innerProperties() == null ? null : this.innerProperties().createUiDefinition();
    }

    /**
     * Set the createUiDefinition property: The createUiDefinition json for the backing template with
     * Microsoft.Solutions/applications resource. It can be a JObject or well-formed JSON string.
     *
     * @param createUiDefinition the createUiDefinition value to set.
     * @return the ApplicationDefinitionInner object itself.
     */
    public ApplicationDefinitionInner withCreateUiDefinition(Object createUiDefinition) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ApplicationDefinitionProperties();
        }
        this.innerProperties().withCreateUiDefinition(createUiDefinition);
        return this;
    }

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

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