/******************************************************************************* * 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.Comprehend; using Amazon.Comprehend.Model; namespace Amazon.PowerShell.Cmdlets.COMP { /// /// Starts an asynchronous targeted sentiment detection job for a collection of documents. /// Use the DescribeTargetedSentimentDetectionJob operation to track the /// status of a job. /// [Cmdlet("Start", "COMPTargetedSentimentDetectionJob", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("Amazon.Comprehend.Model.StartTargetedSentimentDetectionJobResponse")] [AWSCmdlet("Calls the Amazon Comprehend StartTargetedSentimentDetectionJob API operation.", Operation = new[] {"StartTargetedSentimentDetectionJob"}, SelectReturnType = typeof(Amazon.Comprehend.Model.StartTargetedSentimentDetectionJobResponse))] [AWSCmdletOutput("Amazon.Comprehend.Model.StartTargetedSentimentDetectionJobResponse", "This cmdlet returns an Amazon.Comprehend.Model.StartTargetedSentimentDetectionJobResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class StartCOMPTargetedSentimentDetectionJobCmdlet : AmazonComprehendClientCmdlet, IExecutor { #region Parameter ClientRequestToken /// /// /// A unique identifier for the request. If you don't set the client request token, Amazon /// Comprehend generates one. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String ClientRequestToken { get; set; } #endregion #region Parameter DataAccessRoleArn /// /// /// The Amazon Resource Name (ARN) of the IAM role that grants Amazon Comprehend read /// access to your input data. For more information, see Role-based /// permissions. /// /// #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 DataAccessRoleArn { get; set; } #endregion #region Parameter InputDataConfig /// /// /// The service has not provided documentation for this parameter; please refer to the service's API reference documentation for the latest available information. /// /// #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.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] public Amazon.Comprehend.Model.InputDataConfig InputDataConfig { get; set; } #endregion #region Parameter JobName /// /// /// The identifier of the job. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String JobName { get; set; } #endregion #region Parameter LanguageCode /// /// /// The language of the input documents. Currently, English is the only supported language. /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] [AWSConstantClassSource("Amazon.Comprehend.LanguageCode")] public Amazon.Comprehend.LanguageCode LanguageCode { get; set; } #endregion #region Parameter OutputDataConfig /// /// /// Specifies where to send the output files. /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] public Amazon.Comprehend.Model.OutputDataConfig OutputDataConfig { get; set; } #endregion #region Parameter VpcConfig_SecurityGroupId /// /// /// The ID number for a security group on an instance of your private VPC. Security groups /// on your VPC function serve as a virtual firewall to control inbound and outbound traffic /// and provides security for the resources that you’ll be accessing on the VPC. This /// ID number is preceded by "sg-", for instance: "sg-03b388029b0a285ea". For more information, /// see Security /// Groups for your VPC. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("VpcConfig_SecurityGroupIds")] public System.String[] VpcConfig_SecurityGroupId { get; set; } #endregion #region Parameter VpcConfig_Subnet /// /// /// The ID for each subnet being used in your private VPC. This subnet is a subset of /// the a range of IPv4 addresses used by the VPC and is specific to a given availability /// zone in the VPC’s Region. This ID number is preceded by "subnet-", for instance: "subnet-04ccf456919e69055". /// For more information, see VPCs /// and Subnets. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("VpcConfig_Subnets")] public System.String[] VpcConfig_Subnet { get; set; } #endregion #region Parameter Tag /// /// /// Tags to associate with the targeted sentiment detection job. A tag is a key-value /// pair that adds metadata to a resource used by Amazon Comprehend. For example, a tag /// with "Sales" as the key might be added to a resource to indicate its use by the sales /// department. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("Tags")] public Amazon.Comprehend.Model.Tag[] Tag { get; set; } #endregion #region Parameter VolumeKmsKeyId /// /// /// ID for the KMS key that Amazon Comprehend uses to encrypt data on the storage volume /// attached to the ML compute instance(s) that process the analysis job. The VolumeKmsKeyId /// can be either of the following formats: /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String VolumeKmsKeyId { 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.Comprehend.Model.StartTargetedSentimentDetectionJobResponse). /// Specifying the name of a property of type Amazon.Comprehend.Model.StartTargetedSentimentDetectionJobResponse 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 InputDataConfig parameter. /// The -PassThru parameter is deprecated, use -Select '^InputDataConfig' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^InputDataConfig' 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.DataAccessRoleArn), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Start-COMPTargetedSentimentDetectionJob (StartTargetedSentimentDetectionJob)")) { 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.InputDataConfig; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.ClientRequestToken = this.ClientRequestToken; context.DataAccessRoleArn = this.DataAccessRoleArn; #if MODULAR if (this.DataAccessRoleArn == null && ParameterWasBound(nameof(this.DataAccessRoleArn))) { WriteWarning("You are passing $null as a value for parameter DataAccessRoleArn 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.InputDataConfig = this.InputDataConfig; #if MODULAR if (this.InputDataConfig == null && ParameterWasBound(nameof(this.InputDataConfig))) { WriteWarning("You are passing $null as a value for parameter InputDataConfig 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.JobName = this.JobName; context.LanguageCode = this.LanguageCode; #if MODULAR if (this.LanguageCode == null && ParameterWasBound(nameof(this.LanguageCode))) { WriteWarning("You are passing $null as a value for parameter LanguageCode 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.OutputDataConfig = this.OutputDataConfig; #if MODULAR if (this.OutputDataConfig == null && ParameterWasBound(nameof(this.OutputDataConfig))) { WriteWarning("You are passing $null as a value for parameter OutputDataConfig 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.Tag != null) { context.Tag = new List(this.Tag); } context.VolumeKmsKeyId = this.VolumeKmsKeyId; if (this.VpcConfig_SecurityGroupId != null) { context.VpcConfig_SecurityGroupId = new List(this.VpcConfig_SecurityGroupId); } if (this.VpcConfig_Subnet != null) { context.VpcConfig_Subnet = new List(this.VpcConfig_Subnet); } // 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.Comprehend.Model.StartTargetedSentimentDetectionJobRequest(); if (cmdletContext.ClientRequestToken != null) { request.ClientRequestToken = cmdletContext.ClientRequestToken; } if (cmdletContext.DataAccessRoleArn != null) { request.DataAccessRoleArn = cmdletContext.DataAccessRoleArn; } if (cmdletContext.InputDataConfig != null) { request.InputDataConfig = cmdletContext.InputDataConfig; } if (cmdletContext.JobName != null) { request.JobName = cmdletContext.JobName; } if (cmdletContext.LanguageCode != null) { request.LanguageCode = cmdletContext.LanguageCode; } if (cmdletContext.OutputDataConfig != null) { request.OutputDataConfig = cmdletContext.OutputDataConfig; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } if (cmdletContext.VolumeKmsKeyId != null) { request.VolumeKmsKeyId = cmdletContext.VolumeKmsKeyId; } // populate VpcConfig var requestVpcConfigIsNull = true; request.VpcConfig = new Amazon.Comprehend.Model.VpcConfig(); List requestVpcConfig_vpcConfig_SecurityGroupId = null; if (cmdletContext.VpcConfig_SecurityGroupId != null) { requestVpcConfig_vpcConfig_SecurityGroupId = cmdletContext.VpcConfig_SecurityGroupId; } if (requestVpcConfig_vpcConfig_SecurityGroupId != null) { request.VpcConfig.SecurityGroupIds = requestVpcConfig_vpcConfig_SecurityGroupId; requestVpcConfigIsNull = false; } List requestVpcConfig_vpcConfig_Subnet = null; if (cmdletContext.VpcConfig_Subnet != null) { requestVpcConfig_vpcConfig_Subnet = cmdletContext.VpcConfig_Subnet; } if (requestVpcConfig_vpcConfig_Subnet != null) { request.VpcConfig.Subnets = requestVpcConfig_vpcConfig_Subnet; requestVpcConfigIsNull = false; } // determine if request.VpcConfig should be set to null if (requestVpcConfigIsNull) { request.VpcConfig = null; } 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.Comprehend.Model.StartTargetedSentimentDetectionJobResponse CallAWSServiceOperation(IAmazonComprehend client, Amazon.Comprehend.Model.StartTargetedSentimentDetectionJobRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Comprehend", "StartTargetedSentimentDetectionJob"); try { #if DESKTOP return client.StartTargetedSentimentDetectionJob(request); #elif CORECLR return client.StartTargetedSentimentDetectionJobAsync(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 ClientRequestToken { get; set; } public System.String DataAccessRoleArn { get; set; } public Amazon.Comprehend.Model.InputDataConfig InputDataConfig { get; set; } public System.String JobName { get; set; } public Amazon.Comprehend.LanguageCode LanguageCode { get; set; } public Amazon.Comprehend.Model.OutputDataConfig OutputDataConfig { get; set; } public List Tag { get; set; } public System.String VolumeKmsKeyId { get; set; } public List VpcConfig_SecurityGroupId { get; set; } public List VpcConfig_Subnet { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => response; } } }