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

package com.azure.resourcemanager.streamanalytics.generated;

import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.streamanalytics.models.AvroSerialization;
import com.azure.resourcemanager.streamanalytics.models.AzureDataLakeStoreOutputDataSource;
import com.azure.resourcemanager.streamanalytics.models.AzureSqlDatabaseOutputDataSource;
import com.azure.resourcemanager.streamanalytics.models.AzureTableOutputDataSource;
import com.azure.resourcemanager.streamanalytics.models.BlobOutputDataSource;
import com.azure.resourcemanager.streamanalytics.models.CsvSerialization;
import com.azure.resourcemanager.streamanalytics.models.DocumentDbOutputDataSource;
import com.azure.resourcemanager.streamanalytics.models.Encoding;
import com.azure.resourcemanager.streamanalytics.models.EventHubOutputDataSource;
import com.azure.resourcemanager.streamanalytics.models.JsonOutputSerializationFormat;
import com.azure.resourcemanager.streamanalytics.models.JsonSerialization;
import com.azure.resourcemanager.streamanalytics.models.PowerBIOutputDataSource;
import com.azure.resourcemanager.streamanalytics.models.ServiceBusQueueOutputDataSource;
import com.azure.resourcemanager.streamanalytics.models.ServiceBusTopicOutputDataSource;
import com.azure.resourcemanager.streamanalytics.models.StorageAccount;
import java.io.IOException;
import java.util.Arrays;

/** Samples for Outputs CreateOrReplace. */
public final class OutputsCreateOrReplaceSamples {
    /*
     * x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/examples/Output_Create_Blob_CSV.json
     */
    /**
     * Sample code: Create a blob output with CSV serialization.
     *
     * @param manager Entry point to StreamAnalyticsManager.
     */
    public static void createABlobOutputWithCSVSerialization(
        com.azure.resourcemanager.streamanalytics.StreamAnalyticsManager manager) {
        manager
            .outputs()
            .define("output1623")
            .withExistingStreamingjob("sjrg5023", "sj900")
            .withDatasource(
                new BlobOutputDataSource()
                    .withStorageAccounts(
                        Arrays
                            .asList(
                                new StorageAccount().withAccountName("someAccountName").withAccountKey("accountKey==")))
                    .withContainer("state")
                    .withPathPattern("{date}/{time}")
                    .withDateFormat("yyyy/MM/dd")
                    .withTimeFormat("HH"))
            .withSerialization(new CsvSerialization().withFieldDelimiter(",").withEncoding(Encoding.UTF8))
            .create();
    }

    /*
     * x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/examples/Output_Create_ServiceBusTopic_CSV.json
     */
    /**
     * Sample code: Create a Service Bus Topic output with CSV serialization.
     *
     * @param manager Entry point to StreamAnalyticsManager.
     */
    public static void createAServiceBusTopicOutputWithCSVSerialization(
        com.azure.resourcemanager.streamanalytics.StreamAnalyticsManager manager) {
        manager
            .outputs()
            .define("output7886")
            .withExistingStreamingjob("sjrg6450", "sj7094")
            .withDatasource(
                new ServiceBusTopicOutputDataSource()
                    .withTopicName("sdktopic")
                    .withPropertyColumns(Arrays.asList("column1", "column2"))
                    .withServiceBusNamespace("sdktest")
                    .withSharedAccessPolicyName("RootManageSharedAccessKey")
                    .withSharedAccessPolicyKey("sharedAccessPolicyKey="))
            .withSerialization(new CsvSerialization().withFieldDelimiter(",").withEncoding(Encoding.UTF8))
            .create();
    }

    /*
     * x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/examples/Output_Create_AzureSQL.json
     */
    /**
     * Sample code: Create an Azure SQL database output.
     *
     * @param manager Entry point to StreamAnalyticsManager.
     */
    public static void createAnAzureSQLDatabaseOutput(
        com.azure.resourcemanager.streamanalytics.StreamAnalyticsManager manager) {
        manager
            .outputs()
            .define("output1755")
            .withExistingStreamingjob("sjrg2157", "sj6458")
            .withDatasource(new AzureSqlDatabaseOutputDataSource())
            .create();
    }

    /*
     * x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/examples/Output_Create_PowerBI.json
     */
    /**
     * Sample code: Create a Power BI output.
     *
     * @param manager Entry point to StreamAnalyticsManager.
     */
    public static void createAPowerBIOutput(com.azure.resourcemanager.streamanalytics.StreamAnalyticsManager manager) {
        manager
            .outputs()
            .define("output3022")
            .withExistingStreamingjob("sjrg7983", "sj2331")
            .withDatasource(
                new PowerBIOutputDataSource()
                    .withDataset("someDataset")
                    .withTable("someTable")
                    .withGroupId("ac40305e-3e8d-43ac-8161-c33799f43e95")
                    .withGroupName("MyPowerBIGroup")
                    .withRefreshToken("someRefreshToken==")
                    .withTokenUserPrincipalName("bobsmith@contoso.com")
                    .withTokenUserDisplayName("Bob Smith"))
            .create();
    }

    /*
     * x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/examples/Output_Create_EventHub_JSON.json
     */
    /**
     * Sample code: Create an Event Hub output with JSON serialization.
     *
     * @param manager Entry point to StreamAnalyticsManager.
     */
    public static void createAnEventHubOutputWithJSONSerialization(
        com.azure.resourcemanager.streamanalytics.StreamAnalyticsManager manager) {
        manager
            .outputs()
            .define("output5195")
            .withExistingStreamingjob("sjrg6912", "sj3310")
            .withDatasource(
                new EventHubOutputDataSource()
                    .withPartitionKey("partitionKey")
                    .withEventHubName("sdkeventhub")
                    .withServiceBusNamespace("sdktest")
                    .withSharedAccessPolicyName("RootManageSharedAccessKey")
                    .withSharedAccessPolicyKey("sharedAccessPolicyKey="))
            .withSerialization(
                new JsonSerialization().withEncoding(Encoding.UTF8).withFormat(JsonOutputSerializationFormat.ARRAY))
            .create();
    }

    /*
     * x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/examples/Output_Create_ServiceBusQueue_Avro.json
     */
    /**
     * Sample code: Create a Service Bus Queue output with Avro serialization.
     *
     * @param manager Entry point to StreamAnalyticsManager.
     */
    public static void createAServiceBusQueueOutputWithAvroSerialization(
        com.azure.resourcemanager.streamanalytics.StreamAnalyticsManager manager) throws IOException {
        manager
            .outputs()
            .define("output3456")
            .withExistingStreamingjob("sjrg3410", "sj5095")
            .withDatasource(
                new ServiceBusQueueOutputDataSource()
                    .withQueueName("sdkqueue")
                    .withPropertyColumns(Arrays.asList("column1", "column2"))
                    .withSystemPropertyColumns(
                        SerializerFactory
                            .createDefaultManagementSerializerAdapter()
                            .deserialize(
                                "{\"MessageId\":\"col3\",\"PartitionKey\":\"col4\"}",
                                Object.class,
                                SerializerEncoding.JSON))
                    .withServiceBusNamespace("sdktest")
                    .withSharedAccessPolicyName("RootManageSharedAccessKey")
                    .withSharedAccessPolicyKey("sharedAccessPolicyKey="))
            .withSerialization(new AvroSerialization())
            .create();
    }

    /*
     * x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/examples/Output_Create_DocumentDB.json
     */
    /**
     * Sample code: Create a DocumentDB output.
     *
     * @param manager Entry point to StreamAnalyticsManager.
     */
    public static void createADocumentDBOutput(
        com.azure.resourcemanager.streamanalytics.StreamAnalyticsManager manager) {
        manager
            .outputs()
            .define("output3022")
            .withExistingStreamingjob("sjrg7983", "sj2331")
            .withDatasource(
                new DocumentDbOutputDataSource()
                    .withAccountId("someAccountId")
                    .withAccountKey("accountKey==")
                    .withDatabase("db01")
                    .withCollectionNamePattern("collection")
                    .withPartitionKey("key")
                    .withDocumentId("documentId"))
            .create();
    }

    /*
     * x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/examples/Output_Create_AzureTable.json
     */
    /**
     * Sample code: Create an Azure Table output.
     *
     * @param manager Entry point to StreamAnalyticsManager.
     */
    public static void createAnAzureTableOutput(
        com.azure.resourcemanager.streamanalytics.StreamAnalyticsManager manager) {
        manager
            .outputs()
            .define("output958")
            .withExistingStreamingjob("sjrg5176", "sj2790")
            .withDatasource(
                new AzureTableOutputDataSource()
                    .withAccountName("someAccountName")
                    .withAccountKey("accountKey==")
                    .withTable("samples")
                    .withPartitionKey("partitionKey")
                    .withRowKey("rowKey")
                    .withColumnsToRemove(Arrays.asList("column1", "column2"))
                    .withBatchSize(25))
            .create();
    }

    /*
     * x-ms-original-file: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/stable/2020-03-01/examples/Output_Create_AzureDataLakeStore_JSON.json
     */
    /**
     * Sample code: Create an Azure Data Lake Store output with JSON serialization.
     *
     * @param manager Entry point to StreamAnalyticsManager.
     */
    public static void createAnAzureDataLakeStoreOutputWithJSONSerialization(
        com.azure.resourcemanager.streamanalytics.StreamAnalyticsManager manager) {
        manager
            .outputs()
            .define("output5195")
            .withExistingStreamingjob("sjrg6912", "sj3310")
            .withDatasource(
                new AzureDataLakeStoreOutputDataSource()
                    .withAccountName("someaccount")
                    .withTenantId("cea4e98b-c798-49e7-8c40-4a2b3beb47dd")
                    .withFilePathPrefix("{date}/{time}")
                    .withDateFormat("yyyy/MM/dd")
                    .withTimeFormat("HH")
                    .withRefreshToken("someRefreshToken==")
                    .withTokenUserPrincipalName("bobsmith@contoso.com")
                    .withTokenUserDisplayName("Bob Smith"))
            .withSerialization(
                new JsonSerialization().withEncoding(Encoding.UTF8).withFormat(JsonOutputSerializationFormat.ARRAY))
            .create();
    }
}
