/*******************************************************************************
* 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.FraudDetector;
using Amazon.FraudDetector.Model;
namespace Amazon.PowerShell.Cmdlets.FD
{
///
/// Updates the status of a model version.
///
///
///
/// You can perform the following status updates:
/// -
/// Change the
TRAINING_IN_PROGRESS
status to TRAINING_CANCELLED
.
/// -
/// Change the
TRAINING_COMPLETE
status to ACTIVE
.
/// -
/// Change
ACTIVE
to INACTIVE
.
///
///
[Cmdlet("Update", "FDModelVersionStatus", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("None")]
[AWSCmdlet("Calls the Amazon Fraud Detector UpdateModelVersionStatus API operation.", Operation = new[] {"UpdateModelVersionStatus"}, SelectReturnType = typeof(Amazon.FraudDetector.Model.UpdateModelVersionStatusResponse))]
[AWSCmdletOutput("None or Amazon.FraudDetector.Model.UpdateModelVersionStatusResponse",
"This cmdlet does not generate any output." +
"The service response (type Amazon.FraudDetector.Model.UpdateModelVersionStatusResponse) can be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class UpdateFDModelVersionStatusCmdlet : AmazonFraudDetectorClientCmdlet, IExecutor
{
#region Parameter ModelId
///
///
/// The model ID of the model version to update.
///
///
#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 ModelId { get; set; }
#endregion
#region Parameter ModelType
///
///
/// The model type.
///
///
#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.FraudDetector.ModelTypeEnum")]
public Amazon.FraudDetector.ModelTypeEnum ModelType { get; set; }
#endregion
#region Parameter ModelVersionNumber
///
///
/// The model version number.
///
///
#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 ModelVersionNumber { get; set; }
#endregion
#region Parameter Status
///
///
/// The model version status.
///
///
#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.FraudDetector.ModelVersionStatus")]
public Amazon.FraudDetector.ModelVersionStatus Status { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The cmdlet doesn't have a return value by default.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.FraudDetector.Model.UpdateModelVersionStatusResponse).
/// 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 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.ModelId), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-FDModelVersionStatus (UpdateModelVersionStatus)"))
{
return;
}
var context = new CmdletContext();
// allow for manipulation of parameters prior to loading into context
PreExecutionContextLoad(context);
if (ParameterWasBound(nameof(this.Select)))
{
context.Select = CreateSelectDelegate(Select) ??
throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select));
}
context.ModelId = this.ModelId;
#if MODULAR
if (this.ModelId == null && ParameterWasBound(nameof(this.ModelId)))
{
WriteWarning("You are passing $null as a value for parameter ModelId 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.ModelType = this.ModelType;
#if MODULAR
if (this.ModelType == null && ParameterWasBound(nameof(this.ModelType)))
{
WriteWarning("You are passing $null as a value for parameter ModelType 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.ModelVersionNumber = this.ModelVersionNumber;
#if MODULAR
if (this.ModelVersionNumber == null && ParameterWasBound(nameof(this.ModelVersionNumber)))
{
WriteWarning("You are passing $null as a value for parameter ModelVersionNumber 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.Status = this.Status;
#if MODULAR
if (this.Status == null && ParameterWasBound(nameof(this.Status)))
{
WriteWarning("You are passing $null as a value for parameter Status 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.FraudDetector.Model.UpdateModelVersionStatusRequest();
if (cmdletContext.ModelId != null)
{
request.ModelId = cmdletContext.ModelId;
}
if (cmdletContext.ModelType != null)
{
request.ModelType = cmdletContext.ModelType;
}
if (cmdletContext.ModelVersionNumber != null)
{
request.ModelVersionNumber = cmdletContext.ModelVersionNumber;
}
if (cmdletContext.Status != null)
{
request.Status = cmdletContext.Status;
}
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.FraudDetector.Model.UpdateModelVersionStatusResponse CallAWSServiceOperation(IAmazonFraudDetector client, Amazon.FraudDetector.Model.UpdateModelVersionStatusRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Fraud Detector", "UpdateModelVersionStatus");
try
{
#if DESKTOP
return client.UpdateModelVersionStatus(request);
#elif CORECLR
return client.UpdateModelVersionStatusAsync(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 ModelId { get; set; }
public Amazon.FraudDetector.ModelTypeEnum ModelType { get; set; }
public System.String ModelVersionNumber { get; set; }
public Amazon.FraudDetector.ModelVersionStatus Status { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => null;
}
}
}