|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use |
| 4 | + * this file except in compliance with the License. A copy of the License is located at |
| 5 | + * |
| 6 | + * http://aws.amazon.com/apache2.0 |
| 7 | + * |
| 8 | + * or in the "license" file accompanying this file. |
| 9 | + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 10 | + * CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 11 | + * specific language governing permissions and limitations under the License. |
| 12 | + * ***************************************************************************** |
| 13 | + * |
| 14 | + * AWS Tools for Windows (TM) PowerShell (TM) |
| 15 | + * |
| 16 | + */ |
| 17 | + |
| 18 | +using System; |
| 19 | +using System.Collections.Generic; |
| 20 | +using System.Linq; |
| 21 | +using System.Management.Automation; |
| 22 | +using System.Text; |
| 23 | +using Amazon.PowerShell.Common; |
| 24 | +using Amazon.Runtime; |
| 25 | +using Amazon.Kinesis; |
| 26 | +using Amazon.Kinesis.Model; |
| 27 | + |
| 28 | +namespace Amazon.PowerShell.Cmdlets.KIN |
| 29 | +{ |
| 30 | + /// <summary> |
| 31 | + /// This allows you to update the <c>MaxRecordSize</c> of a single record that you can |
| 32 | + /// write to, and read from a stream. You can ingest and digest single records up to 10240 |
| 33 | + /// KiB. |
| 34 | + /// </summary> |
| 35 | + [Cmdlet("Update", "KINMaxRecordSize", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] |
| 36 | + [OutputType("None")] |
| 37 | + [AWSCmdlet("Calls the Amazon Kinesis UpdateMaxRecordSize API operation.", Operation = new[] {"UpdateMaxRecordSize"}, SelectReturnType = typeof(Amazon.Kinesis.Model.UpdateMaxRecordSizeResponse))] |
| 38 | + [AWSCmdletOutput("None or Amazon.Kinesis.Model.UpdateMaxRecordSizeResponse", |
| 39 | + "This cmdlet does not generate any output." + |
| 40 | + "The service response (type Amazon.Kinesis.Model.UpdateMaxRecordSizeResponse) be returned by specifying '-Select *'." |
| 41 | + )] |
| 42 | + public partial class UpdateKINMaxRecordSizeCmdlet : AmazonKinesisClientCmdlet, IExecutor |
| 43 | + { |
| 44 | + |
| 45 | + protected override bool IsGeneratedCmdlet { get; set; } = true; |
| 46 | + |
| 47 | + #region Parameter MaxRecordSizeInKiB |
| 48 | + /// <summary> |
| 49 | + /// <para> |
| 50 | + /// <para>The maximum record size of a single record in KiB that you can write to, and read |
| 51 | + /// from a stream. Specify a value between 1024 and 10240 KiB (1 to 10 MiB). If you specify |
| 52 | + /// a value that is out of this range, <c>UpdateMaxRecordSize</c> sends back an <c>ValidationException</c> |
| 53 | + /// message.</para> |
| 54 | + /// </para> |
| 55 | + /// </summary> |
| 56 | + #if !MODULAR |
| 57 | + [System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)] |
| 58 | + #else |
| 59 | + [System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, Mandatory = true)] |
| 60 | + [System.Management.Automation.AllowNull] |
| 61 | + #endif |
| 62 | + [Amazon.PowerShell.Common.AWSRequiredParameter] |
| 63 | + public System.Int32? MaxRecordSizeInKiB { get; set; } |
| 64 | + #endregion |
| 65 | + |
| 66 | + #region Parameter StreamARN |
| 67 | + /// <summary> |
| 68 | + /// <para> |
| 69 | + /// <para>The Amazon Resource Name (ARN) of the stream for the <c>MaxRecordSize</c> update.</para> |
| 70 | + /// </para> |
| 71 | + /// </summary> |
| 72 | + [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] |
| 73 | + public System.String StreamARN { get; set; } |
| 74 | + #endregion |
| 75 | + |
| 76 | + #region Parameter Select |
| 77 | + /// <summary> |
| 78 | + /// Use the -Select parameter to control the cmdlet output. The cmdlet doesn't have a return value by default. |
| 79 | + /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.Kinesis.Model.UpdateMaxRecordSizeResponse). |
| 80 | + /// Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value. |
| 81 | + /// </summary> |
| 82 | + [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] |
| 83 | + public string Select { get; set; } = "*"; |
| 84 | + #endregion |
| 85 | + |
| 86 | + #region Parameter PassThru |
| 87 | + /// <summary> |
| 88 | + /// Changes the cmdlet behavior to return the value passed to the MaxRecordSizeInKiB parameter. |
| 89 | + /// The -PassThru parameter is deprecated, use -Select '^MaxRecordSizeInKiB' instead. This parameter will be removed in a future version. |
| 90 | + /// </summary> |
| 91 | + [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^MaxRecordSizeInKiB' instead. This parameter will be removed in a future version.")] |
| 92 | + [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] |
| 93 | + public SwitchParameter PassThru { get; set; } |
| 94 | + #endregion |
| 95 | + |
| 96 | + #region Parameter Force |
| 97 | + /// <summary> |
| 98 | + /// This parameter overrides confirmation prompts to force |
| 99 | + /// the cmdlet to continue its operation. This parameter should always |
| 100 | + /// be used with caution. |
| 101 | + /// </summary> |
| 102 | + [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] |
| 103 | + public SwitchParameter Force { get; set; } |
| 104 | + #endregion |
| 105 | + |
| 106 | + protected override void ProcessRecord() |
| 107 | + { |
| 108 | + this._AWSSignerType = "v4"; |
| 109 | + base.ProcessRecord(); |
| 110 | + |
| 111 | + var resourceIdentifiersText = FormatParameterValuesForConfirmationMsg(nameof(this.MaxRecordSizeInKiB), MyInvocation.BoundParameters); |
| 112 | + if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-KINMaxRecordSize (UpdateMaxRecordSize)")) |
| 113 | + { |
| 114 | + return; |
| 115 | + } |
| 116 | + |
| 117 | + var context = new CmdletContext(); |
| 118 | + |
| 119 | + // allow for manipulation of parameters prior to loading into context |
| 120 | + PreExecutionContextLoad(context); |
| 121 | + |
| 122 | + #pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute |
| 123 | + if (ParameterWasBound(nameof(this.Select))) |
| 124 | + { |
| 125 | + context.Select = CreateSelectDelegate<Amazon.Kinesis.Model.UpdateMaxRecordSizeResponse, UpdateKINMaxRecordSizeCmdlet>(Select) ?? |
| 126 | + throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select)); |
| 127 | + if (this.PassThru.IsPresent) |
| 128 | + { |
| 129 | + throw new System.ArgumentException("-PassThru cannot be used when -Select is specified.", nameof(this.Select)); |
| 130 | + } |
| 131 | + } |
| 132 | + else if (this.PassThru.IsPresent) |
| 133 | + { |
| 134 | + context.Select = (response, cmdlet) => this.MaxRecordSizeInKiB; |
| 135 | + } |
| 136 | + #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute |
| 137 | + context.MaxRecordSizeInKiB = this.MaxRecordSizeInKiB; |
| 138 | + #if MODULAR |
| 139 | + if (this.MaxRecordSizeInKiB == null && ParameterWasBound(nameof(this.MaxRecordSizeInKiB))) |
| 140 | + { |
| 141 | + WriteWarning("You are passing $null as a value for parameter MaxRecordSizeInKiB 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."); |
| 142 | + } |
| 143 | + #endif |
| 144 | + context.StreamARN = this.StreamARN; |
| 145 | + |
| 146 | + // allow further manipulation of loaded context prior to processing |
| 147 | + PostExecutionContextLoad(context); |
| 148 | + |
| 149 | + var output = Execute(context) as CmdletOutput; |
| 150 | + ProcessOutput(output); |
| 151 | + } |
| 152 | + |
| 153 | + #region IExecutor Members |
| 154 | + |
| 155 | + public object Execute(ExecutorContext context) |
| 156 | + { |
| 157 | + var cmdletContext = context as CmdletContext; |
| 158 | + // create request |
| 159 | + var request = new Amazon.Kinesis.Model.UpdateMaxRecordSizeRequest(); |
| 160 | + |
| 161 | + if (cmdletContext.MaxRecordSizeInKiB != null) |
| 162 | + { |
| 163 | + request.MaxRecordSizeInKiB = cmdletContext.MaxRecordSizeInKiB.Value; |
| 164 | + } |
| 165 | + if (cmdletContext.StreamARN != null) |
| 166 | + { |
| 167 | + request.StreamARN = cmdletContext.StreamARN; |
| 168 | + } |
| 169 | + |
| 170 | + CmdletOutput output; |
| 171 | + |
| 172 | + // issue call |
| 173 | + var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); |
| 174 | + try |
| 175 | + { |
| 176 | + var response = CallAWSServiceOperation(client, request); |
| 177 | + object pipelineOutput = null; |
| 178 | + pipelineOutput = cmdletContext.Select(response, this); |
| 179 | + output = new CmdletOutput |
| 180 | + { |
| 181 | + PipelineOutput = pipelineOutput, |
| 182 | + ServiceResponse = response |
| 183 | + }; |
| 184 | + } |
| 185 | + catch (Exception e) |
| 186 | + { |
| 187 | + output = new CmdletOutput { ErrorResponse = e }; |
| 188 | + } |
| 189 | + |
| 190 | + return output; |
| 191 | + } |
| 192 | + |
| 193 | + public ExecutorContext CreateContext() |
| 194 | + { |
| 195 | + return new CmdletContext(); |
| 196 | + } |
| 197 | + |
| 198 | + #endregion |
| 199 | + |
| 200 | + #region AWS Service Operation Call |
| 201 | + |
| 202 | + private Amazon.Kinesis.Model.UpdateMaxRecordSizeResponse CallAWSServiceOperation(IAmazonKinesis client, Amazon.Kinesis.Model.UpdateMaxRecordSizeRequest request) |
| 203 | + { |
| 204 | + Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Kinesis", "UpdateMaxRecordSize"); |
| 205 | + try |
| 206 | + { |
| 207 | + #if DESKTOP |
| 208 | + return client.UpdateMaxRecordSize(request); |
| 209 | + #elif CORECLR |
| 210 | + return client.UpdateMaxRecordSizeAsync(request).GetAwaiter().GetResult(); |
| 211 | + #else |
| 212 | + #error "Unknown build edition" |
| 213 | + #endif |
| 214 | + } |
| 215 | + catch (AmazonServiceException exc) |
| 216 | + { |
| 217 | + var webException = exc.InnerException as System.Net.WebException; |
| 218 | + if (webException != null) |
| 219 | + { |
| 220 | + throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); |
| 221 | + } |
| 222 | + throw; |
| 223 | + } |
| 224 | + } |
| 225 | + |
| 226 | + #endregion |
| 227 | + |
| 228 | + internal partial class CmdletContext : ExecutorContext |
| 229 | + { |
| 230 | + public System.Int32? MaxRecordSizeInKiB { get; set; } |
| 231 | + public System.String StreamARN { get; set; } |
| 232 | + public System.Func<Amazon.Kinesis.Model.UpdateMaxRecordSizeResponse, UpdateKINMaxRecordSizeCmdlet, object> Select { get; set; } = |
| 233 | + (response, cmdlet) => null; |
| 234 | + } |
| 235 | + |
| 236 | + } |
| 237 | +} |
0 commit comments