/******************************************************************************* * 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.SageMakerFeatureStoreRuntime; using Amazon.SageMakerFeatureStoreRuntime.Model; namespace Amazon.PowerShell.Cmdlets.SMFS { /// /// Deletes a Record from a FeatureGroup in the OnlineStore. /// Feature Store supports both SoftDelete and HardDelete. For /// SoftDelete (default), feature columns are set to null and /// the record is no longer retrievable by GetRecord or BatchGetRecord. /// For HardDelete, the complete Record is removed from the /// OnlineStore. In both cases, Feature Store appends the deleted record /// marker to the OfflineStore with feature values set to null, /// is_deleted value set to True, and EventTime /// set to the delete input EventTime. /// /// /// /// Note that the EventTime specified in DeleteRecord should /// be set later than the EventTime of the existing record in the OnlineStore /// for that RecordIdentifer. If it is not, the deletion does not occur: /// /// [Cmdlet("Remove", "SMFSRecord", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)] [OutputType("None")] [AWSCmdlet("Calls the Amazon SageMaker Feature Store Runtime DeleteRecord API operation.", Operation = new[] {"DeleteRecord"}, SelectReturnType = typeof(Amazon.SageMakerFeatureStoreRuntime.Model.DeleteRecordResponse))] [AWSCmdletOutput("None or Amazon.SageMakerFeatureStoreRuntime.Model.DeleteRecordResponse", "This cmdlet does not generate any output." + "The service response (type Amazon.SageMakerFeatureStoreRuntime.Model.DeleteRecordResponse) can be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class RemoveSMFSRecordCmdlet : AmazonSageMakerFeatureStoreRuntimeClientCmdlet, IExecutor { #region Parameter DeletionMode /// /// /// The name of the deletion mode for deleting the record. By default, the deletion mode /// is set to SoftDelete. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.SageMakerFeatureStoreRuntime.DeletionMode")] public Amazon.SageMakerFeatureStoreRuntime.DeletionMode DeletionMode { get; set; } #endregion #region Parameter EventTime /// /// /// Timestamp indicating when the deletion event occurred. EventTime can /// be used to query data at a certain point in time. /// /// #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 EventTime { get; set; } #endregion #region Parameter FeatureGroupName /// /// /// The name or Amazon Resource Name (ARN) of the feature group to delete the record from. /// /// /// #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 FeatureGroupName { get; set; } #endregion #region Parameter RecordIdentifierValueAsString /// /// /// The value for the RecordIdentifier that uniquely identifies the record, /// in string 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 RecordIdentifierValueAsString { get; set; } #endregion #region Parameter TargetStore /// /// /// A list of stores from which you're deleting the record. By default, Feature Store /// deletes the record from all of the stores that you're using for the FeatureGroup. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("TargetStores")] public System.String[] TargetStore { 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.SageMakerFeatureStoreRuntime.Model.DeleteRecordResponse). /// 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.FeatureGroupName), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Remove-SMFSRecord (DeleteRecord)")) { 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.DeletionMode = this.DeletionMode; context.EventTime = this.EventTime; #if MODULAR if (this.EventTime == null && ParameterWasBound(nameof(this.EventTime))) { WriteWarning("You are passing $null as a value for parameter EventTime 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.FeatureGroupName = this.FeatureGroupName; #if MODULAR if (this.FeatureGroupName == null && ParameterWasBound(nameof(this.FeatureGroupName))) { WriteWarning("You are passing $null as a value for parameter FeatureGroupName 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.RecordIdentifierValueAsString = this.RecordIdentifierValueAsString; #if MODULAR if (this.RecordIdentifierValueAsString == null && ParameterWasBound(nameof(this.RecordIdentifierValueAsString))) { WriteWarning("You are passing $null as a value for parameter RecordIdentifierValueAsString 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.TargetStore != null) { context.TargetStore = new List(this.TargetStore); } // 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.SageMakerFeatureStoreRuntime.Model.DeleteRecordRequest(); if (cmdletContext.DeletionMode != null) { request.DeletionMode = cmdletContext.DeletionMode; } if (cmdletContext.EventTime != null) { request.EventTime = cmdletContext.EventTime; } if (cmdletContext.FeatureGroupName != null) { request.FeatureGroupName = cmdletContext.FeatureGroupName; } if (cmdletContext.RecordIdentifierValueAsString != null) { request.RecordIdentifierValueAsString = cmdletContext.RecordIdentifierValueAsString; } if (cmdletContext.TargetStore != null) { request.TargetStores = cmdletContext.TargetStore; } 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.SageMakerFeatureStoreRuntime.Model.DeleteRecordResponse CallAWSServiceOperation(IAmazonSageMakerFeatureStoreRuntime client, Amazon.SageMakerFeatureStoreRuntime.Model.DeleteRecordRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon SageMaker Feature Store Runtime", "DeleteRecord"); try { #if DESKTOP return client.DeleteRecord(request); #elif CORECLR return client.DeleteRecordAsync(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 Amazon.SageMakerFeatureStoreRuntime.DeletionMode DeletionMode { get; set; } public System.String EventTime { get; set; } public System.String FeatureGroupName { get; set; } public System.String RecordIdentifierValueAsString { get; set; } public List TargetStore { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => null; } } }