/******************************************************************************* * Copyright 2012-2018 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.Text; using System.Management.Automation; namespace Amazon.PowerShell.Common { /// /// Clears the contents of the AWS cmdlet history buffer ($AWSHistory) in the current shell. /// [Cmdlet("Clear", "AWSHistory")] [AWSCmdlet("Clears the contents of the AWS cmdlet history buffer ($AWSHistory) in the current shell.")] [OutputType("None")] [AWSCmdletOutput("None", "This cmdlet does not generate any output.")] public class ClearAWSHistoryCmdlet : PSCmdlet { protected override void ProcessRecord() { base.ProcessRecord(); AWSCmdletHistoryBuffer.Instance.Clear(); } } /// /// /// Configures the $AWSHistory instance for the current session. /// /// /// A history buffer size of 0 disables overall AWS cmdlet activity recording and clears any data currently /// in the buffer. If the new size is smaller than the current data in the buffer, older records are deleted. /// /// /// By default, only service responses are recorded for a cmdlet. Use the -EnableRequestRecording switch /// to turn on tracing of service requests in the buffer. /// /// [Cmdlet("Set", "AWSHistoryConfiguration")] [AWSCmdlet("Configures how the $AWSHistory session variable records AWS cmdlet processing.")] [OutputType("None")] [AWSCmdletOutput("None", "This cmdlet does not generate any output.")] public class SetAWSHistoryConfigurationCmdlet : PSCmdlet { /// /// The maximum number of AWS cmdlet invocations that will be held in the history buffer. /// [Parameter(ValueFromPipelineByPropertyName = true)] public int? MaxCmdletHistory { get; set; } /// /// The maximum number of service responses (and requests, if enabled) /// that will be recorded for a single AWS cmdlet. /// [Parameter(ValueFromPipelineByPropertyName = true)] public int? MaxServiceCallHistory { get; set; } /// /// If set, also records the service requests that a cmdlet makes. Default: Off. /// [Parameter(ValueFromPipelineByPropertyName = true)] public SwitchParameter RecordServiceRequests { get; set; } /// /// If set, record the service requests and responses that contain sensitive data. Default: Off. /// [Parameter(ValueFromPipelineByPropertyName = true)] public SwitchParameter IncludeSensitiveData { get; set; } protected override void ProcessRecord() { base.ProcessRecord(); if (MaxCmdletHistory != null) { if (MaxCmdletHistory.Value >= 0) AWSCmdletHistoryBuffer.Instance.MaxHistoryLength = MaxCmdletHistory.Value; else this.ThrowTerminatingError(new ErrorRecord(new ArgumentException("Negative values are not valid."), "ArgumentException", ErrorCategory.InvalidArgument, this.MaxCmdletHistory)); } if (MaxServiceCallHistory != null) { if (MaxServiceCallHistory.Value > 0) AWSCmdletHistoryBuffer.Instance.ServiceCallHistoryLength = MaxServiceCallHistory.Value; else this.ThrowTerminatingError(new ErrorRecord(new ArgumentException("Value must be greater than 0."), "ArgumentException", ErrorCategory.InvalidArgument, this.MaxServiceCallHistory)); } AWSCmdletHistoryBuffer.Instance.RecordServiceRequests = RecordServiceRequests.IsPresent; AWSCmdletHistoryBuffer.Instance.IncludeSensitiveData = IncludeSensitiveData.IsPresent; } } }