/*******************************************************************************
* Copyright 2012-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file.
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
* *****************************************************************************
*
* AWS Tools for Windows (TM) PowerShell (TM)
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using Amazon.PowerShell.Common;
using Amazon.Runtime;
using Amazon.IoTSiteWise;
using Amazon.IoTSiteWise.Model;
namespace Amazon.PowerShell.Cmdlets.IOTSW
{
///
/// Defines a job to ingest data to IoT SiteWise from Amazon S3. For more information,
/// see Create
/// a bulk import job (CLI) in the Amazon Simple Storage Service User Guide.
///
///
/// You must enable IoT SiteWise to export data to Amazon S3 before you create a bulk
/// import job. For more information about how to configure storage settings, see PutStorageConfiguration.
///
///
[Cmdlet("New", "IOTSWBulkImportJob", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("Amazon.IoTSiteWise.Model.CreateBulkImportJobResponse")]
[AWSCmdlet("Calls the AWS IoT SiteWise CreateBulkImportJob API operation.", Operation = new[] {"CreateBulkImportJob"}, SelectReturnType = typeof(Amazon.IoTSiteWise.Model.CreateBulkImportJobResponse))]
[AWSCmdletOutput("Amazon.IoTSiteWise.Model.CreateBulkImportJobResponse",
"This cmdlet returns an Amazon.IoTSiteWise.Model.CreateBulkImportJobResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class NewIOTSWBulkImportJobCmdlet : AmazonIoTSiteWiseClientCmdlet, IExecutor
{
#region Parameter ErrorReportLocation_Bucket
///
///
/// The name of the Amazon S3 bucket to which errors associated with the bulk import job
/// are sent.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String ErrorReportLocation_Bucket { get; set; }
#endregion
#region Parameter Csv_ColumnName
///
///
/// The column names specified in the .csv file.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("JobConfiguration_FileFormat_Csv_ColumnNames")]
public System.String[] Csv_ColumnName { get; set; }
#endregion
#region Parameter File
///
///
/// The files in the specified Amazon S3 bucket that contain your data.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyCollection]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
[Alias("Files")]
public Amazon.IoTSiteWise.Model.File[] File { get; set; }
#endregion
#region Parameter JobName
///
///
/// The unique name that helps identify the job request.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)]
#else
[System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String JobName { get; set; }
#endregion
#region Parameter JobRoleArn
///
///
/// The ARN
/// of the IAM role that allows IoT SiteWise to read Amazon S3 data.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String JobRoleArn { get; set; }
#endregion
#region Parameter ErrorReportLocation_Prefix
///
///
/// Amazon S3 uses the prefix as a folder name to organize data in the bucket. Each Amazon
/// S3 object has a key that is its unique identifier in the bucket. Each object in a
/// bucket has exactly one key. The prefix must end with a forward slash (/). For more
/// information, see Organizing
/// objects using prefixes in the Amazon Simple Storage Service User Guide.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String ErrorReportLocation_Prefix { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The default value is '*'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.IoTSiteWise.Model.CreateBulkImportJobResponse).
/// Specifying the name of a property of type Amazon.IoTSiteWise.Model.CreateBulkImportJobResponse will result in that property being returned.
/// Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public string Select { get; set; } = "*";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the JobName parameter.
/// The -PassThru parameter is deprecated, use -Select '^JobName' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^JobName' instead. This parameter will be removed in a future version.")]
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter PassThru { get; set; }
#endregion
#region Parameter Force
///
/// This parameter overrides confirmation prompts to force
/// the cmdlet to continue its operation. This parameter should always
/// be used with caution.
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter Force { get; set; }
#endregion
protected override void ProcessRecord()
{
this._AWSSignerType = "v4";
base.ProcessRecord();
var resourceIdentifiersText = FormatParameterValuesForConfirmationMsg(nameof(this.JobName), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "New-IOTSWBulkImportJob (CreateBulkImportJob)"))
{
return;
}
var context = new CmdletContext();
// allow for manipulation of parameters prior to loading into context
PreExecutionContextLoad(context);
#pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
if (ParameterWasBound(nameof(this.Select)))
{
context.Select = CreateSelectDelegate(Select) ??
throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select));
if (this.PassThru.IsPresent)
{
throw new System.ArgumentException("-PassThru cannot be used when -Select is specified.", nameof(this.Select));
}
}
else if (this.PassThru.IsPresent)
{
context.Select = (response, cmdlet) => this.JobName;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.ErrorReportLocation_Bucket = this.ErrorReportLocation_Bucket;
#if MODULAR
if (this.ErrorReportLocation_Bucket == null && ParameterWasBound(nameof(this.ErrorReportLocation_Bucket)))
{
WriteWarning("You are passing $null as a value for parameter ErrorReportLocation_Bucket which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
context.ErrorReportLocation_Prefix = this.ErrorReportLocation_Prefix;
#if MODULAR
if (this.ErrorReportLocation_Prefix == null && ParameterWasBound(nameof(this.ErrorReportLocation_Prefix)))
{
WriteWarning("You are passing $null as a value for parameter ErrorReportLocation_Prefix which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
if (this.File != null)
{
context.File = new List(this.File);
}
#if MODULAR
if (this.File == null && ParameterWasBound(nameof(this.File)))
{
WriteWarning("You are passing $null as a value for parameter File which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
if (this.Csv_ColumnName != null)
{
context.Csv_ColumnName = new List(this.Csv_ColumnName);
}
context.JobName = this.JobName;
#if MODULAR
if (this.JobName == null && ParameterWasBound(nameof(this.JobName)))
{
WriteWarning("You are passing $null as a value for parameter JobName which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
context.JobRoleArn = this.JobRoleArn;
#if MODULAR
if (this.JobRoleArn == null && ParameterWasBound(nameof(this.JobRoleArn)))
{
WriteWarning("You are passing $null as a value for parameter JobRoleArn which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
// allow further manipulation of loaded context prior to processing
PostExecutionContextLoad(context);
var output = Execute(context) as CmdletOutput;
ProcessOutput(output);
}
#region IExecutor Members
public object Execute(ExecutorContext context)
{
var cmdletContext = context as CmdletContext;
// create request
var request = new Amazon.IoTSiteWise.Model.CreateBulkImportJobRequest();
// populate ErrorReportLocation
var requestErrorReportLocationIsNull = true;
request.ErrorReportLocation = new Amazon.IoTSiteWise.Model.ErrorReportLocation();
System.String requestErrorReportLocation_errorReportLocation_Bucket = null;
if (cmdletContext.ErrorReportLocation_Bucket != null)
{
requestErrorReportLocation_errorReportLocation_Bucket = cmdletContext.ErrorReportLocation_Bucket;
}
if (requestErrorReportLocation_errorReportLocation_Bucket != null)
{
request.ErrorReportLocation.Bucket = requestErrorReportLocation_errorReportLocation_Bucket;
requestErrorReportLocationIsNull = false;
}
System.String requestErrorReportLocation_errorReportLocation_Prefix = null;
if (cmdletContext.ErrorReportLocation_Prefix != null)
{
requestErrorReportLocation_errorReportLocation_Prefix = cmdletContext.ErrorReportLocation_Prefix;
}
if (requestErrorReportLocation_errorReportLocation_Prefix != null)
{
request.ErrorReportLocation.Prefix = requestErrorReportLocation_errorReportLocation_Prefix;
requestErrorReportLocationIsNull = false;
}
// determine if request.ErrorReportLocation should be set to null
if (requestErrorReportLocationIsNull)
{
request.ErrorReportLocation = null;
}
if (cmdletContext.File != null)
{
request.Files = cmdletContext.File;
}
// populate JobConfiguration
var requestJobConfigurationIsNull = true;
request.JobConfiguration = new Amazon.IoTSiteWise.Model.JobConfiguration();
Amazon.IoTSiteWise.Model.FileFormat requestJobConfiguration_jobConfiguration_FileFormat = null;
// populate FileFormat
var requestJobConfiguration_jobConfiguration_FileFormatIsNull = true;
requestJobConfiguration_jobConfiguration_FileFormat = new Amazon.IoTSiteWise.Model.FileFormat();
Amazon.IoTSiteWise.Model.Csv requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv = null;
// populate Csv
var requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_CsvIsNull = true;
requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv = new Amazon.IoTSiteWise.Model.Csv();
List requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv_csv_ColumnName = null;
if (cmdletContext.Csv_ColumnName != null)
{
requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv_csv_ColumnName = cmdletContext.Csv_ColumnName;
}
if (requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv_csv_ColumnName != null)
{
requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv.ColumnNames = requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv_csv_ColumnName;
requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_CsvIsNull = false;
}
// determine if requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv should be set to null
if (requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_CsvIsNull)
{
requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv = null;
}
if (requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv != null)
{
requestJobConfiguration_jobConfiguration_FileFormat.Csv = requestJobConfiguration_jobConfiguration_FileFormat_jobConfiguration_FileFormat_Csv;
requestJobConfiguration_jobConfiguration_FileFormatIsNull = false;
}
// determine if requestJobConfiguration_jobConfiguration_FileFormat should be set to null
if (requestJobConfiguration_jobConfiguration_FileFormatIsNull)
{
requestJobConfiguration_jobConfiguration_FileFormat = null;
}
if (requestJobConfiguration_jobConfiguration_FileFormat != null)
{
request.JobConfiguration.FileFormat = requestJobConfiguration_jobConfiguration_FileFormat;
requestJobConfigurationIsNull = false;
}
// determine if request.JobConfiguration should be set to null
if (requestJobConfigurationIsNull)
{
request.JobConfiguration = null;
}
if (cmdletContext.JobName != null)
{
request.JobName = cmdletContext.JobName;
}
if (cmdletContext.JobRoleArn != null)
{
request.JobRoleArn = cmdletContext.JobRoleArn;
}
CmdletOutput output;
// issue call
var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);
try
{
var response = CallAWSServiceOperation(client, request);
object pipelineOutput = null;
pipelineOutput = cmdletContext.Select(response, this);
output = new CmdletOutput
{
PipelineOutput = pipelineOutput,
ServiceResponse = response
};
}
catch (Exception e)
{
output = new CmdletOutput { ErrorResponse = e };
}
return output;
}
public ExecutorContext CreateContext()
{
return new CmdletContext();
}
#endregion
#region AWS Service Operation Call
private Amazon.IoTSiteWise.Model.CreateBulkImportJobResponse CallAWSServiceOperation(IAmazonIoTSiteWise client, Amazon.IoTSiteWise.Model.CreateBulkImportJobRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT SiteWise", "CreateBulkImportJob");
try
{
#if DESKTOP
return client.CreateBulkImportJob(request);
#elif CORECLR
return client.CreateBulkImportJobAsync(request).GetAwaiter().GetResult();
#else
#error "Unknown build edition"
#endif
}
catch (AmazonServiceException exc)
{
var webException = exc.InnerException as System.Net.WebException;
if (webException != null)
{
throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
}
throw;
}
}
#endregion
internal partial class CmdletContext : ExecutorContext
{
public System.String ErrorReportLocation_Bucket { get; set; }
public System.String ErrorReportLocation_Prefix { get; set; }
public List File { get; set; }
public List Csv_ColumnName { get; set; }
public System.String JobName { get; set; }
public System.String JobRoleArn { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response;
}
}
}