/*******************************************************************************
* 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 entity detection job for a collection of documents. Use the
/// operation to track the status of a job.
///
///
///
/// This API can be used for either standard entity detection or custom entity recognition.
/// In order to be used for custom entity recognition, the optional EntityRecognizerArn
/// must be used in order to provide access to the recognizer being used to detect the
/// custom entity.
///
///
[Cmdlet("Start", "COMPEntitiesDetectionJob", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("Amazon.Comprehend.Model.StartEntitiesDetectionJobResponse")]
[AWSCmdlet("Calls the Amazon Comprehend StartEntitiesDetectionJob API operation.", Operation = new[] {"StartEntitiesDetectionJob"}, SelectReturnType = typeof(Amazon.Comprehend.Model.StartEntitiesDetectionJobResponse))]
[AWSCmdletOutput("Amazon.Comprehend.Model.StartEntitiesDetectionJobResponse",
"This cmdlet returns an Amazon.Comprehend.Model.StartEntitiesDetectionJobResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class StartCOMPEntitiesDetectionJobCmdlet : 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 EntityRecognizerArn
///
///
/// The Amazon Resource Name (ARN) that identifies the specific entity recognizer to be
/// used by the StartEntitiesDetectionJob
. This ARN is optional and is only
/// used for a custom entity recognition job.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String EntityRecognizerArn { get; set; }
#endregion
#region Parameter FlywheelArn
///
///
/// The Amazon Resource Number (ARN) of the flywheel associated with the model to use.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String FlywheelArn { get; set; }
#endregion
#region Parameter InputDataConfig
///
///
/// Specifies the format and location of the input data for the job.
///
///
#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. All documents must be in the same language. You
/// can specify any of the languages supported by Amazon Comprehend. If custom entities
/// recognition is used, this parameter is ignored and the language used for training
/// the model is used instead.
///
///
#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 entities 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 Amazon Web Services Key Management Service (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:- KMS Key ID:
"1234abcd-12ab-34cd-56ef-1234567890ab"
- Amazon Resource Name (ARN) of a KMS Key:
"arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
///
///
[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.StartEntitiesDetectionJobResponse).
/// Specifying the name of a property of type Amazon.Comprehend.Model.StartEntitiesDetectionJobResponse 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 = string.Empty;
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Start-COMPEntitiesDetectionJob (StartEntitiesDetectionJob)"))
{
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.EntityRecognizerArn = this.EntityRecognizerArn;
context.FlywheelArn = this.FlywheelArn;
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.StartEntitiesDetectionJobRequest();
if (cmdletContext.ClientRequestToken != null)
{
request.ClientRequestToken = cmdletContext.ClientRequestToken;
}
if (cmdletContext.DataAccessRoleArn != null)
{
request.DataAccessRoleArn = cmdletContext.DataAccessRoleArn;
}
if (cmdletContext.EntityRecognizerArn != null)
{
request.EntityRecognizerArn = cmdletContext.EntityRecognizerArn;
}
if (cmdletContext.FlywheelArn != null)
{
request.FlywheelArn = cmdletContext.FlywheelArn;
}
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.StartEntitiesDetectionJobResponse CallAWSServiceOperation(IAmazonComprehend client, Amazon.Comprehend.Model.StartEntitiesDetectionJobRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Comprehend", "StartEntitiesDetectionJob");
try
{
#if DESKTOP
return client.StartEntitiesDetectionJob(request);
#elif CORECLR
return client.StartEntitiesDetectionJobAsync(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 System.String EntityRecognizerArn { get; set; }
public System.String FlywheelArn { 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;
}
}
}