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

package com.azure.resourcemanager.storage.generated;

import com.azure.core.util.Context;
import com.azure.resourcemanager.storage.fluent.models.BlobServicePropertiesInner;
import com.azure.resourcemanager.storage.models.ChangeFeed;
import com.azure.resourcemanager.storage.models.CorsRule;
import com.azure.resourcemanager.storage.models.CorsRuleAllowedMethodsItem;
import com.azure.resourcemanager.storage.models.CorsRules;
import com.azure.resourcemanager.storage.models.DeleteRetentionPolicy;
import com.azure.resourcemanager.storage.models.LastAccessTimeTrackingPolicy;
import com.azure.resourcemanager.storage.models.Name;
import java.util.Arrays;

/** Samples for BlobServices SetServiceProperties. */
public final class BlobServicesSetServicePropertiesSamples {
    /*
     * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2022-09-01/examples/BlobServicesPut.json
     */
    /**
     * Sample code: PutBlobServices.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void putBlobServices(com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .storageAccounts()
            .manager()
            .serviceClient()
            .getBlobServices()
            .setServicePropertiesWithResponse(
                "res4410",
                "sto8607",
                new BlobServicePropertiesInner()
                    .withCors(
                        new CorsRules()
                            .withCorsRules(
                                Arrays
                                    .asList(
                                        new CorsRule()
                                            .withAllowedOrigins(
                                                Arrays.asList("http://www.contoso.com", "http://www.fabrikam.com"))
                                            .withAllowedMethods(
                                                Arrays
                                                    .asList(
                                                        CorsRuleAllowedMethodsItem.GET,
                                                        CorsRuleAllowedMethodsItem.HEAD,
                                                        CorsRuleAllowedMethodsItem.POST,
                                                        CorsRuleAllowedMethodsItem.OPTIONS,
                                                        CorsRuleAllowedMethodsItem.MERGE,
                                                        CorsRuleAllowedMethodsItem.PUT))
                                            .withMaxAgeInSeconds(100)
                                            .withExposedHeaders(Arrays.asList("x-ms-meta-*"))
                                            .withAllowedHeaders(
                                                Arrays.asList("x-ms-meta-abc", "x-ms-meta-data*", "x-ms-meta-target*")),
                                        new CorsRule()
                                            .withAllowedOrigins(Arrays.asList("*"))
                                            .withAllowedMethods(Arrays.asList(CorsRuleAllowedMethodsItem.GET))
                                            .withMaxAgeInSeconds(2)
                                            .withExposedHeaders(Arrays.asList("*"))
                                            .withAllowedHeaders(Arrays.asList("*")),
                                        new CorsRule()
                                            .withAllowedOrigins(
                                                Arrays.asList("http://www.abc23.com", "https://www.fabrikam.com/*"))
                                            .withAllowedMethods(
                                                Arrays
                                                    .asList(
                                                        CorsRuleAllowedMethodsItem.GET, CorsRuleAllowedMethodsItem.PUT))
                                            .withMaxAgeInSeconds(2000)
                                            .withExposedHeaders(
                                                Arrays.asList("x-ms-meta-abc", "x-ms-meta-data*", "x -ms-meta-target*"))
                                            .withAllowedHeaders(Arrays.asList("x-ms-meta-12345675754564*")))))
                    .withDefaultServiceVersion("2017-07-29")
                    .withDeleteRetentionPolicy(new DeleteRetentionPolicy().withEnabled(true).withDays(300))
                    .withIsVersioningEnabled(true)
                    .withChangeFeed(new ChangeFeed().withEnabled(true).withRetentionInDays(7)),
                Context.NONE);
    }

    /*
     * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2022-09-01/examples/BlobServicesPutAllowPermanentDelete.json
     */
    /**
     * Sample code: BlobServicesPutAllowPermanentDelete.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void blobServicesPutAllowPermanentDelete(com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .storageAccounts()
            .manager()
            .serviceClient()
            .getBlobServices()
            .setServicePropertiesWithResponse(
                "res4410",
                "sto8607",
                new BlobServicePropertiesInner()
                    .withDeleteRetentionPolicy(
                        new DeleteRetentionPolicy().withEnabled(true).withDays(300).withAllowPermanentDelete(true))
                    .withIsVersioningEnabled(true),
                Context.NONE);
    }

    /*
     * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2022-09-01/examples/BlobServicesPutLastAccessTimeBasedTracking.json
     */
    /**
     * Sample code: BlobServicesPutLastAccessTimeBasedTracking.
     *
     * @param azure The entry point for accessing resource management APIs in Azure.
     */
    public static void blobServicesPutLastAccessTimeBasedTracking(
        com.azure.resourcemanager.AzureResourceManager azure) {
        azure
            .storageAccounts()
            .manager()
            .serviceClient()
            .getBlobServices()
            .setServicePropertiesWithResponse(
                "res4410",
                "sto8607",
                new BlobServicePropertiesInner()
                    .withLastAccessTimeTrackingPolicy(
                        new LastAccessTimeTrackingPolicy()
                            .withEnable(true)
                            .withName(Name.ACCESS_TIME_TRACKING)
                            .withTrackingGranularityInDays(1)
                            .withBlobType(Arrays.asList("blockBlob"))),
                Context.NONE);
    }
}
