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

package com.azure.resourcemanager.costmanagement.generated;

import com.azure.resourcemanager.costmanagement.models.ExportDataset;
import com.azure.resourcemanager.costmanagement.models.ExportDatasetConfiguration;
import com.azure.resourcemanager.costmanagement.models.ExportDefinition;
import com.azure.resourcemanager.costmanagement.models.ExportDeliveryDestination;
import com.azure.resourcemanager.costmanagement.models.ExportDeliveryInfo;
import com.azure.resourcemanager.costmanagement.models.ExportRecurrencePeriod;
import com.azure.resourcemanager.costmanagement.models.ExportSchedule;
import com.azure.resourcemanager.costmanagement.models.ExportType;
import com.azure.resourcemanager.costmanagement.models.FormatType;
import com.azure.resourcemanager.costmanagement.models.GranularityType;
import com.azure.resourcemanager.costmanagement.models.RecurrenceType;
import com.azure.resourcemanager.costmanagement.models.StatusType;
import com.azure.resourcemanager.costmanagement.models.TimeframeType;
import java.time.OffsetDateTime;
import java.util.Arrays;

/** Samples for Exports CreateOrUpdate. */
public final class ExportsCreateOrUpdateSamples {
    /*
     * x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByManagementGroup.json
     */
    /**
     * Sample code: ExportCreateOrUpdateByManagementGroup.
     *
     * @param manager Entry point to CostManagementManager.
     */
    public static void exportCreateOrUpdateByManagementGroup(
        com.azure.resourcemanager.costmanagement.CostManagementManager manager) {
        manager
            .exports()
            .define("TestExport")
            .withExistingScope("providers/Microsoft.Management/managementGroups/TestMG")
            .withSchedule(
                new ExportSchedule()
                    .withStatus(StatusType.ACTIVE)
                    .withRecurrence(RecurrenceType.WEEKLY)
                    .withRecurrencePeriod(
                        new ExportRecurrencePeriod()
                            .withFrom(OffsetDateTime.parse("2020-06-01T00:00:00Z"))
                            .withTo(OffsetDateTime.parse("2020-10-31T00:00:00Z"))))
            .withFormat(FormatType.CSV)
            .withDeliveryInfo(
                new ExportDeliveryInfo()
                    .withDestination(
                        new ExportDeliveryDestination()
                            .withResourceId(
                                "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182")
                            .withContainer("exports")
                            .withRootFolderPath("ad-hoc")))
            .withDefinition(
                new ExportDefinition()
                    .withType(ExportType.ACTUAL_COST)
                    .withTimeframe(TimeframeType.MONTH_TO_DATE)
                    .withDataSet(
                        new ExportDataset()
                            .withGranularity(GranularityType.DAILY)
                            .withConfiguration(
                                new ExportDatasetConfiguration()
                                    .withColumns(
                                        Arrays
                                            .asList("Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity")))))
            .create();
    }

    /*
     * x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByBillingAccount.json
     */
    /**
     * Sample code: ExportCreateOrUpdateByBillingAccount.
     *
     * @param manager Entry point to CostManagementManager.
     */
    public static void exportCreateOrUpdateByBillingAccount(
        com.azure.resourcemanager.costmanagement.CostManagementManager manager) {
        manager
            .exports()
            .define("TestExport")
            .withExistingScope("providers/Microsoft.Billing/billingAccounts/123456")
            .withSchedule(
                new ExportSchedule()
                    .withStatus(StatusType.ACTIVE)
                    .withRecurrence(RecurrenceType.WEEKLY)
                    .withRecurrencePeriod(
                        new ExportRecurrencePeriod()
                            .withFrom(OffsetDateTime.parse("2020-06-01T00:00:00Z"))
                            .withTo(OffsetDateTime.parse("2020-10-31T00:00:00Z"))))
            .withFormat(FormatType.CSV)
            .withDeliveryInfo(
                new ExportDeliveryInfo()
                    .withDestination(
                        new ExportDeliveryDestination()
                            .withResourceId(
                                "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182")
                            .withContainer("exports")
                            .withRootFolderPath("ad-hoc")))
            .withDefinition(
                new ExportDefinition()
                    .withType(ExportType.ACTUAL_COST)
                    .withTimeframe(TimeframeType.MONTH_TO_DATE)
                    .withDataSet(
                        new ExportDataset()
                            .withGranularity(GranularityType.DAILY)
                            .withConfiguration(
                                new ExportDatasetConfiguration()
                                    .withColumns(
                                        Arrays
                                            .asList("Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity")))))
            .create();
    }

    /*
     * x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByDepartment.json
     */
    /**
     * Sample code: ExportCreateOrUpdateByDepartment.
     *
     * @param manager Entry point to CostManagementManager.
     */
    public static void exportCreateOrUpdateByDepartment(
        com.azure.resourcemanager.costmanagement.CostManagementManager manager) {
        manager
            .exports()
            .define("TestExport")
            .withExistingScope("providers/Microsoft.Billing/billingAccounts/12/departments/1234")
            .withSchedule(
                new ExportSchedule()
                    .withStatus(StatusType.ACTIVE)
                    .withRecurrence(RecurrenceType.WEEKLY)
                    .withRecurrencePeriod(
                        new ExportRecurrencePeriod()
                            .withFrom(OffsetDateTime.parse("2020-06-01T00:00:00Z"))
                            .withTo(OffsetDateTime.parse("2020-10-31T00:00:00Z"))))
            .withFormat(FormatType.CSV)
            .withDeliveryInfo(
                new ExportDeliveryInfo()
                    .withDestination(
                        new ExportDeliveryDestination()
                            .withResourceId(
                                "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182")
                            .withContainer("exports")
                            .withRootFolderPath("ad-hoc")))
            .withDefinition(
                new ExportDefinition()
                    .withType(ExportType.ACTUAL_COST)
                    .withTimeframe(TimeframeType.MONTH_TO_DATE)
                    .withDataSet(
                        new ExportDataset()
                            .withGranularity(GranularityType.DAILY)
                            .withConfiguration(
                                new ExportDatasetConfiguration()
                                    .withColumns(
                                        Arrays
                                            .asList("Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity")))))
            .create();
    }

    /*
     * x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByResourceGroup.json
     */
    /**
     * Sample code: ExportCreateOrUpdateByResourceGroup.
     *
     * @param manager Entry point to CostManagementManager.
     */
    public static void exportCreateOrUpdateByResourceGroup(
        com.azure.resourcemanager.costmanagement.CostManagementManager manager) {
        manager
            .exports()
            .define("TestExport")
            .withExistingScope("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG")
            .withSchedule(
                new ExportSchedule()
                    .withStatus(StatusType.ACTIVE)
                    .withRecurrence(RecurrenceType.WEEKLY)
                    .withRecurrencePeriod(
                        new ExportRecurrencePeriod()
                            .withFrom(OffsetDateTime.parse("2020-06-01T00:00:00Z"))
                            .withTo(OffsetDateTime.parse("2020-10-31T00:00:00Z"))))
            .withFormat(FormatType.CSV)
            .withDeliveryInfo(
                new ExportDeliveryInfo()
                    .withDestination(
                        new ExportDeliveryDestination()
                            .withResourceId(
                                "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182")
                            .withContainer("exports")
                            .withRootFolderPath("ad-hoc")))
            .withDefinition(
                new ExportDefinition()
                    .withType(ExportType.ACTUAL_COST)
                    .withTimeframe(TimeframeType.MONTH_TO_DATE)
                    .withDataSet(
                        new ExportDataset()
                            .withGranularity(GranularityType.DAILY)
                            .withConfiguration(
                                new ExportDatasetConfiguration()
                                    .withColumns(
                                        Arrays
                                            .asList("Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity")))))
            .create();
    }

    /*
     * x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateBySubscription.json
     */
    /**
     * Sample code: ExportCreateOrUpdateBySubscription.
     *
     * @param manager Entry point to CostManagementManager.
     */
    public static void exportCreateOrUpdateBySubscription(
        com.azure.resourcemanager.costmanagement.CostManagementManager manager) {
        manager
            .exports()
            .define("TestExport")
            .withExistingScope("subscriptions/00000000-0000-0000-0000-000000000000")
            .withSchedule(
                new ExportSchedule()
                    .withStatus(StatusType.ACTIVE)
                    .withRecurrence(RecurrenceType.WEEKLY)
                    .withRecurrencePeriod(
                        new ExportRecurrencePeriod()
                            .withFrom(OffsetDateTime.parse("2020-06-01T00:00:00Z"))
                            .withTo(OffsetDateTime.parse("2020-10-31T00:00:00Z"))))
            .withFormat(FormatType.CSV)
            .withDeliveryInfo(
                new ExportDeliveryInfo()
                    .withDestination(
                        new ExportDeliveryDestination()
                            .withResourceId(
                                "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182")
                            .withContainer("exports")
                            .withRootFolderPath("ad-hoc")))
            .withDefinition(
                new ExportDefinition()
                    .withType(ExportType.ACTUAL_COST)
                    .withTimeframe(TimeframeType.MONTH_TO_DATE)
                    .withDataSet(
                        new ExportDataset()
                            .withGranularity(GranularityType.DAILY)
                            .withConfiguration(
                                new ExportDatasetConfiguration()
                                    .withColumns(
                                        Arrays
                                            .asList("Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity")))))
            .create();
    }

    /*
     * x-ms-original-file: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByEnrollmentAccount.json
     */
    /**
     * Sample code: ExportCreateOrUpdateByEnrollmentAccount.
     *
     * @param manager Entry point to CostManagementManager.
     */
    public static void exportCreateOrUpdateByEnrollmentAccount(
        com.azure.resourcemanager.costmanagement.CostManagementManager manager) {
        manager
            .exports()
            .define("TestExport")
            .withExistingScope("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456")
            .withSchedule(
                new ExportSchedule()
                    .withStatus(StatusType.ACTIVE)
                    .withRecurrence(RecurrenceType.WEEKLY)
                    .withRecurrencePeriod(
                        new ExportRecurrencePeriod()
                            .withFrom(OffsetDateTime.parse("2020-06-01T00:00:00Z"))
                            .withTo(OffsetDateTime.parse("2020-10-31T00:00:00Z"))))
            .withFormat(FormatType.CSV)
            .withDeliveryInfo(
                new ExportDeliveryInfo()
                    .withDestination(
                        new ExportDeliveryDestination()
                            .withResourceId(
                                "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182")
                            .withContainer("exports")
                            .withRootFolderPath("ad-hoc")))
            .withDefinition(
                new ExportDefinition()
                    .withType(ExportType.ACTUAL_COST)
                    .withTimeframe(TimeframeType.MONTH_TO_DATE)
                    .withDataSet(
                        new ExportDataset()
                            .withGranularity(GranularityType.DAILY)
                            .withConfiguration(
                                new ExportDatasetConfiguration()
                                    .withColumns(
                                        Arrays
                                            .asList("Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity")))))
            .create();
    }
}
