/******************************************************************************* * 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.DataSync; using Amazon.DataSync.Model; namespace Amazon.PowerShell.Cmdlets.DSYN { /// /// Updates some of the parameters of a previously created location for Network File System /// (NFS) access. For information about creating an NFS location, see Creating /// a location for NFS. /// [Cmdlet("Update", "DSYNLocationNfs", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("None")] [AWSCmdlet("Calls the AWS DataSync UpdateLocationNfs API operation.", Operation = new[] {"UpdateLocationNfs"}, SelectReturnType = typeof(Amazon.DataSync.Model.UpdateLocationNfsResponse))] [AWSCmdletOutput("None or Amazon.DataSync.Model.UpdateLocationNfsResponse", "This cmdlet does not generate any output." + "The service response (type Amazon.DataSync.Model.UpdateLocationNfsResponse) can be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class UpdateDSYNLocationNfsCmdlet : AmazonDataSyncClientCmdlet, IExecutor { #region Parameter OnPremConfig_AgentArn /// /// /// ARNs of the agents to use for an NFS location. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("OnPremConfig_AgentArns")] public System.String[] OnPremConfig_AgentArn { get; set; } #endregion #region Parameter LocationArn /// /// /// Specifies the Amazon Resource Name (ARN) of the NFS location that you want to update. /// /// #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 LocationArn { get; set; } #endregion #region Parameter Subdirectory /// /// /// Specifies the subdirectory in your NFS file system that DataSync uses to read from /// or write to during a transfer. The NFS path should be exported by the NFS server, /// or a subdirectory of that path. The path should be such that it can be mounted by /// other NFS clients in your network.To see all the paths exported by your NFS server, run "showmount -e nfs-server-name" /// from an NFS client that has access to your server. You can specify any directory that /// appears in the results, and any subdirectory of that directory. Ensure that the NFS /// export is accessible without Kerberos authentication. To transfer all the data in the folder that you specified, DataSync must have permissions /// to read all the data. To ensure this, either configure the NFS export with no_root_squash, /// or ensure that the files you want DataSync to access have permissions that allow read /// access for all users. Doing either option enables the agent to read the files. For /// the agent to access directories, you must additionally enable all execute access.If you are copying data to or from your Snowcone device, see NFS /// Server on Snowcone for more information. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public System.String Subdirectory { get; set; } #endregion #region Parameter MountOptions_Version /// /// /// Specifies the NFS version that you want DataSync to use when mounting your NFS share. /// If the server refuses to use the version specified, the task fails.You can specify the following options:DataSync currently only supports NFS version 3 with Amazon FSx for NetApp ONTAP locations. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [AWSConstantClassSource("Amazon.DataSync.NfsVersion")] public Amazon.DataSync.NfsVersion MountOptions_Version { 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.DataSync.Model.UpdateLocationNfsResponse). /// 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 PassThru /// /// Changes the cmdlet behavior to return the value passed to the LocationArn parameter. /// The -PassThru parameter is deprecated, use -Select '^LocationArn' instead. This parameter will be removed in a future version. /// [System.Obsolete("The -PassThru parameter is deprecated, use -Select '^LocationArn' 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.LocationArn), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Update-DSYNLocationNfs (UpdateLocationNfs)")) { 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.LocationArn; } #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute context.LocationArn = this.LocationArn; #if MODULAR if (this.LocationArn == null && ParameterWasBound(nameof(this.LocationArn))) { WriteWarning("You are passing $null as a value for parameter LocationArn 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.MountOptions_Version = this.MountOptions_Version; if (this.OnPremConfig_AgentArn != null) { context.OnPremConfig_AgentArn = new List(this.OnPremConfig_AgentArn); } context.Subdirectory = this.Subdirectory; // 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.DataSync.Model.UpdateLocationNfsRequest(); if (cmdletContext.LocationArn != null) { request.LocationArn = cmdletContext.LocationArn; } // populate MountOptions var requestMountOptionsIsNull = true; request.MountOptions = new Amazon.DataSync.Model.NfsMountOptions(); Amazon.DataSync.NfsVersion requestMountOptions_mountOptions_Version = null; if (cmdletContext.MountOptions_Version != null) { requestMountOptions_mountOptions_Version = cmdletContext.MountOptions_Version; } if (requestMountOptions_mountOptions_Version != null) { request.MountOptions.Version = requestMountOptions_mountOptions_Version; requestMountOptionsIsNull = false; } // determine if request.MountOptions should be set to null if (requestMountOptionsIsNull) { request.MountOptions = null; } // populate OnPremConfig var requestOnPremConfigIsNull = true; request.OnPremConfig = new Amazon.DataSync.Model.OnPremConfig(); List requestOnPremConfig_onPremConfig_AgentArn = null; if (cmdletContext.OnPremConfig_AgentArn != null) { requestOnPremConfig_onPremConfig_AgentArn = cmdletContext.OnPremConfig_AgentArn; } if (requestOnPremConfig_onPremConfig_AgentArn != null) { request.OnPremConfig.AgentArns = requestOnPremConfig_onPremConfig_AgentArn; requestOnPremConfigIsNull = false; } // determine if request.OnPremConfig should be set to null if (requestOnPremConfigIsNull) { request.OnPremConfig = null; } if (cmdletContext.Subdirectory != null) { request.Subdirectory = cmdletContext.Subdirectory; } 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.DataSync.Model.UpdateLocationNfsResponse CallAWSServiceOperation(IAmazonDataSync client, Amazon.DataSync.Model.UpdateLocationNfsRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS DataSync", "UpdateLocationNfs"); try { #if DESKTOP return client.UpdateLocationNfs(request); #elif CORECLR return client.UpdateLocationNfsAsync(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 LocationArn { get; set; } public Amazon.DataSync.NfsVersion MountOptions_Version { get; set; } public List OnPremConfig_AgentArn { get; set; } public System.String Subdirectory { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => null; } } }