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

package com.azure.resourcemanager.deploymentmanager.generated;

import com.azure.resourcemanager.deploymentmanager.models.SasAuthentication;
import java.util.HashMap;
import java.util.Map;

/** Samples for ArtifactSources CreateOrUpdate. */
public final class ArtifactSourcesCreateOrUpdateSamples {
    /*
     * x-ms-original-file: specification/deploymentmanager/resource-manager/Microsoft.DeploymentManager/preview/2019-11-01-preview/examples/artifactsource_createorupdate.json
     */
    /**
     * Sample code: Create artifact source.
     *
     * @param manager Entry point to DeploymentManager.
     */
    public static void createArtifactSource(com.azure.resourcemanager.deploymentmanager.DeploymentManager manager) {
        manager
            .artifactSources()
            .define("myArtifactSource")
            .withRegion("centralus")
            .withExistingResourceGroup("myResourceGroup")
            .withTags(mapOf())
            .withSourceType("AzureStorage")
            .withAuthentication(
                new SasAuthentication()
                    .withSasUri(
                        "https://mystorageaccount.blob.core.windows.net/myartifactsource?st=2018-07-07T14%3A10%3A00Z&se=2019-12-31T15%3A10%3A00Z&sp=rl&sv=2017-04-17&sr=c&sig=Yh2SoJ1NhhLRwCLln7de%2Fkabcdefghijklmno5sWEIk%3D"))
            .create();
    }

    /*
     * x-ms-original-file: specification/deploymentmanager/resource-manager/Microsoft.DeploymentManager/preview/2019-11-01-preview/examples/artifactsource_createorupdate_artifactroot.json
     */
    /**
     * Sample code: Create artifact source with artifact root, an offset into the storage container.
     *
     * @param manager Entry point to DeploymentManager.
     */
    public static void createArtifactSourceWithArtifactRootAnOffsetIntoTheStorageContainer(
        com.azure.resourcemanager.deploymentmanager.DeploymentManager manager) {
        manager
            .artifactSources()
            .define("myArtifactSource")
            .withRegion("centralus")
            .withExistingResourceGroup("myResourceGroup")
            .withTags(mapOf())
            .withSourceType("AzureStorage")
            .withArtifactRoot("1.0.0.0")
            .withAuthentication(
                new SasAuthentication()
                    .withSasUri(
                        "https://mystorageaccount.blob.core.windows.net/myartifactsource?st=2018-07-07T14%3A10%3A00Z&se=2019-12-31T15%3A10%3A00Z&sp=rl&sv=2017-04-17&sr=c&sig=Yh2SoJ1NhhLRwCLln7de%2Fkabcdefghijklmno5sWEIk%3D"))
            .create();
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
