/*******************************************************************************
* 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.Connect;
using Amazon.Connect.Model;
namespace Amazon.PowerShell.Cmdlets.CONN
{
///
/// Places an outbound call to a contact, and then initiates the flow. It performs the
/// actions in the flow that's specified (in ContactFlowId
).
///
///
///
/// Agents do not initiate the outbound API, which means that they do not dial the contact.
/// If the flow places an outbound call to a contact, and then puts the contact in queue,
/// the call is then routed to the agent, like any other inbound case.
///
/// There is a 60-second dialing timeout for this operation. If the call is not connected
/// after 60 seconds, it fails.
///
/// UK numbers with a 447 prefix are not allowed by default. Before you can dial these
/// UK mobile numbers, you must submit a service quota increase request. For more information,
/// see Amazon
/// Connect Service Quotas in the Amazon Connect Administrator Guide.
///
/// Campaign calls are not allowed by default. Before you can make a call with TrafficType
/// = CAMPAIGN
, you must submit a service quota increase request to the quota
/// Amazon
/// Connect campaigns.
///
///
[Cmdlet("Start", "CONNOutboundVoiceContact", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("System.String")]
[AWSCmdlet("Calls the Amazon Connect Service StartOutboundVoiceContact API operation.", Operation = new[] {"StartOutboundVoiceContact"}, SelectReturnType = typeof(Amazon.Connect.Model.StartOutboundVoiceContactResponse))]
[AWSCmdletOutput("System.String or Amazon.Connect.Model.StartOutboundVoiceContactResponse",
"This cmdlet returns a System.String object.",
"The service call response (type Amazon.Connect.Model.StartOutboundVoiceContactResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class StartCONNOutboundVoiceContactCmdlet : AmazonConnectClientCmdlet, IExecutor
{
#region Parameter Attribute
///
///
/// A custom key-value pair using an attribute map. The attributes are standard Amazon
/// Connect attributes, and can be accessed in flows just like any other contact attributes.There can be up to 32,768 UTF-8 bytes across all key-value pairs per contact. Attribute
/// keys can include only alphanumeric, dash, and underscore characters.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Attributes")]
public System.Collections.Hashtable Attribute { get; set; }
#endregion
#region Parameter AnswerMachineDetectionConfig_AwaitAnswerMachinePrompt
///
///
/// Wait for the answering machine prompt.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? AnswerMachineDetectionConfig_AwaitAnswerMachinePrompt { get; set; }
#endregion
#region Parameter CampaignId
///
///
/// The campaign identifier of the outbound communication.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String CampaignId { get; set; }
#endregion
#region Parameter ContactFlowId
///
///
/// The identifier of the flow for the outbound call. To see the ContactFlowId in the
/// Amazon Connect console user interface, on the navigation menu go to Routing,
/// Contact Flows. Choose the flow. On the flow page, under the name of the flow,
/// choose Show additional flow information. The ContactFlowId is the last part
/// of the ARN, shown here in bold: arn:aws:connect:us-west-2:xxxxxxxxxxxx:instance/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/contact-flow/846ec553-a005-41c0-8341-xxxxxxxxxxxx
///
///
#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 ContactFlowId { get; set; }
#endregion
#region Parameter DestinationPhoneNumber
///
///
/// The phone number of the customer, in E.164 format.
///
///
#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 DestinationPhoneNumber { get; set; }
#endregion
#region Parameter AnswerMachineDetectionConfig_EnableAnswerMachineDetection
///
///
/// The flag to indicate if answer machine detection analysis needs to be performed for
/// a voice call. If set to true
, TrafficType
must be set as
/// CAMPAIGN
.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? AnswerMachineDetectionConfig_EnableAnswerMachineDetection { get; set; }
#endregion
#region Parameter InstanceId
///
///
/// The identifier of the Amazon Connect instance. You can find
/// the instance ID in the Amazon Resource Name (ARN) of the instance.
///
///
#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 InstanceId { get; set; }
#endregion
#region Parameter QueueId
///
///
/// The queue for the call. If you specify a queue, the phone displayed for caller ID
/// is the phone number specified in the queue. If you do not specify a queue, the queue
/// defined in the flow is used. If you do not specify a queue, you must specify a source
/// phone number.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String QueueId { get; set; }
#endregion
#region Parameter SourcePhoneNumber
///
///
/// The phone number associated with the Amazon Connect instance, in E.164 format. If
/// you do not specify a source phone number, you must specify a queue.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String SourcePhoneNumber { get; set; }
#endregion
#region Parameter TrafficType
///
///
/// Denotes the class of traffic. Calls with different traffic types are handled differently
/// by Amazon Connect. The default value is GENERAL
. Use CAMPAIGN
/// if EnableAnswerMachineDetection
is set to true
. For all
/// other cases, use GENERAL
.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[AWSConstantClassSource("Amazon.Connect.TrafficType")]
public Amazon.Connect.TrafficType TrafficType { get; set; }
#endregion
#region Parameter ClientToken
///
///
/// A unique, case-sensitive identifier that you provide to ensure the idempotency of
/// the request. If not provided, the Amazon Web Services SDK populates this field. For
/// more information about idempotency, see Making
/// retries safe with idempotent APIs. The token is valid for 7 days after creation.
/// If a contact is already started, the contact ID is returned.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String ClientToken { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The default value is 'ContactId'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.Connect.Model.StartOutboundVoiceContactResponse).
/// Specifying the name of a property of type Amazon.Connect.Model.StartOutboundVoiceContactResponse 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; } = "ContactId";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the ContactFlowId parameter.
/// The -PassThru parameter is deprecated, use -Select '^ContactFlowId' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^ContactFlowId' 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.ContactFlowId), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Start-CONNOutboundVoiceContact (StartOutboundVoiceContact)"))
{
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.ContactFlowId;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.AnswerMachineDetectionConfig_AwaitAnswerMachinePrompt = this.AnswerMachineDetectionConfig_AwaitAnswerMachinePrompt;
context.AnswerMachineDetectionConfig_EnableAnswerMachineDetection = this.AnswerMachineDetectionConfig_EnableAnswerMachineDetection;
if (this.Attribute != null)
{
context.Attribute = new Dictionary(StringComparer.Ordinal);
foreach (var hashKey in this.Attribute.Keys)
{
context.Attribute.Add((String)hashKey, (String)(this.Attribute[hashKey]));
}
}
context.CampaignId = this.CampaignId;
context.ClientToken = this.ClientToken;
context.ContactFlowId = this.ContactFlowId;
#if MODULAR
if (this.ContactFlowId == null && ParameterWasBound(nameof(this.ContactFlowId)))
{
WriteWarning("You are passing $null as a value for parameter ContactFlowId 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.DestinationPhoneNumber = this.DestinationPhoneNumber;
#if MODULAR
if (this.DestinationPhoneNumber == null && ParameterWasBound(nameof(this.DestinationPhoneNumber)))
{
WriteWarning("You are passing $null as a value for parameter DestinationPhoneNumber 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.InstanceId = this.InstanceId;
#if MODULAR
if (this.InstanceId == null && ParameterWasBound(nameof(this.InstanceId)))
{
WriteWarning("You are passing $null as a value for parameter InstanceId 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.QueueId = this.QueueId;
context.SourcePhoneNumber = this.SourcePhoneNumber;
context.TrafficType = this.TrafficType;
// 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.Connect.Model.StartOutboundVoiceContactRequest();
// populate AnswerMachineDetectionConfig
var requestAnswerMachineDetectionConfigIsNull = true;
request.AnswerMachineDetectionConfig = new Amazon.Connect.Model.AnswerMachineDetectionConfig();
System.Boolean? requestAnswerMachineDetectionConfig_answerMachineDetectionConfig_AwaitAnswerMachinePrompt = null;
if (cmdletContext.AnswerMachineDetectionConfig_AwaitAnswerMachinePrompt != null)
{
requestAnswerMachineDetectionConfig_answerMachineDetectionConfig_AwaitAnswerMachinePrompt = cmdletContext.AnswerMachineDetectionConfig_AwaitAnswerMachinePrompt.Value;
}
if (requestAnswerMachineDetectionConfig_answerMachineDetectionConfig_AwaitAnswerMachinePrompt != null)
{
request.AnswerMachineDetectionConfig.AwaitAnswerMachinePrompt = requestAnswerMachineDetectionConfig_answerMachineDetectionConfig_AwaitAnswerMachinePrompt.Value;
requestAnswerMachineDetectionConfigIsNull = false;
}
System.Boolean? requestAnswerMachineDetectionConfig_answerMachineDetectionConfig_EnableAnswerMachineDetection = null;
if (cmdletContext.AnswerMachineDetectionConfig_EnableAnswerMachineDetection != null)
{
requestAnswerMachineDetectionConfig_answerMachineDetectionConfig_EnableAnswerMachineDetection = cmdletContext.AnswerMachineDetectionConfig_EnableAnswerMachineDetection.Value;
}
if (requestAnswerMachineDetectionConfig_answerMachineDetectionConfig_EnableAnswerMachineDetection != null)
{
request.AnswerMachineDetectionConfig.EnableAnswerMachineDetection = requestAnswerMachineDetectionConfig_answerMachineDetectionConfig_EnableAnswerMachineDetection.Value;
requestAnswerMachineDetectionConfigIsNull = false;
}
// determine if request.AnswerMachineDetectionConfig should be set to null
if (requestAnswerMachineDetectionConfigIsNull)
{
request.AnswerMachineDetectionConfig = null;
}
if (cmdletContext.Attribute != null)
{
request.Attributes = cmdletContext.Attribute;
}
if (cmdletContext.CampaignId != null)
{
request.CampaignId = cmdletContext.CampaignId;
}
if (cmdletContext.ClientToken != null)
{
request.ClientToken = cmdletContext.ClientToken;
}
if (cmdletContext.ContactFlowId != null)
{
request.ContactFlowId = cmdletContext.ContactFlowId;
}
if (cmdletContext.DestinationPhoneNumber != null)
{
request.DestinationPhoneNumber = cmdletContext.DestinationPhoneNumber;
}
if (cmdletContext.InstanceId != null)
{
request.InstanceId = cmdletContext.InstanceId;
}
if (cmdletContext.QueueId != null)
{
request.QueueId = cmdletContext.QueueId;
}
if (cmdletContext.SourcePhoneNumber != null)
{
request.SourcePhoneNumber = cmdletContext.SourcePhoneNumber;
}
if (cmdletContext.TrafficType != null)
{
request.TrafficType = cmdletContext.TrafficType;
}
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.Connect.Model.StartOutboundVoiceContactResponse CallAWSServiceOperation(IAmazonConnect client, Amazon.Connect.Model.StartOutboundVoiceContactRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Connect Service", "StartOutboundVoiceContact");
try
{
#if DESKTOP
return client.StartOutboundVoiceContact(request);
#elif CORECLR
return client.StartOutboundVoiceContactAsync(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.Boolean? AnswerMachineDetectionConfig_AwaitAnswerMachinePrompt { get; set; }
public System.Boolean? AnswerMachineDetectionConfig_EnableAnswerMachineDetection { get; set; }
public Dictionary Attribute { get; set; }
public System.String CampaignId { get; set; }
public System.String ClientToken { get; set; }
public System.String ContactFlowId { get; set; }
public System.String DestinationPhoneNumber { get; set; }
public System.String InstanceId { get; set; }
public System.String QueueId { get; set; }
public System.String SourcePhoneNumber { get; set; }
public Amazon.Connect.TrafficType TrafficType { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response.ContactId;
}
}
}