private Amazon.AppMesh.Model.CreateVirtualServiceResponse CallAWSServiceOperation(IAmazonAppMesh client, Amazon.AppMesh.Model.CreateVirtualServiceRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS App Mesh", "CreateVirtualService");
     try
     {
         #if DESKTOP
         return(client.CreateVirtualService(request));
         #elif CORECLR
         return(client.CreateVirtualServiceAsync(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;
     }
 }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.AppMesh.Model.CreateVirtualServiceRequest();

            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }
            if (cmdletContext.MeshName != null)
            {
                request.MeshName = cmdletContext.MeshName;
            }

            // populate Spec
            var requestSpecIsNull = true;

            request.Spec = new Amazon.AppMesh.Model.VirtualServiceSpec();
            Amazon.AppMesh.Model.VirtualServiceProvider requestSpec_spec_Provider = null;

            // populate Provider
            var requestSpec_spec_ProviderIsNull = true;

            requestSpec_spec_Provider = new Amazon.AppMesh.Model.VirtualServiceProvider();
            Amazon.AppMesh.Model.VirtualNodeServiceProvider requestSpec_spec_Provider_spec_Provider_VirtualNode = null;

            // populate VirtualNode
            var requestSpec_spec_Provider_spec_Provider_VirtualNodeIsNull = true;

            requestSpec_spec_Provider_spec_Provider_VirtualNode = new Amazon.AppMesh.Model.VirtualNodeServiceProvider();
            System.String requestSpec_spec_Provider_spec_Provider_VirtualNode_virtualNode_VirtualNodeName = null;
            if (cmdletContext.VirtualNode_VirtualNodeName != null)
            {
                requestSpec_spec_Provider_spec_Provider_VirtualNode_virtualNode_VirtualNodeName = cmdletContext.VirtualNode_VirtualNodeName;
            }
            if (requestSpec_spec_Provider_spec_Provider_VirtualNode_virtualNode_VirtualNodeName != null)
            {
                requestSpec_spec_Provider_spec_Provider_VirtualNode.VirtualNodeName = requestSpec_spec_Provider_spec_Provider_VirtualNode_virtualNode_VirtualNodeName;
                requestSpec_spec_Provider_spec_Provider_VirtualNodeIsNull           = false;
            }
            // determine if requestSpec_spec_Provider_spec_Provider_VirtualNode should be set to null
            if (requestSpec_spec_Provider_spec_Provider_VirtualNodeIsNull)
            {
                requestSpec_spec_Provider_spec_Provider_VirtualNode = null;
            }
            if (requestSpec_spec_Provider_spec_Provider_VirtualNode != null)
            {
                requestSpec_spec_Provider.VirtualNode = requestSpec_spec_Provider_spec_Provider_VirtualNode;
                requestSpec_spec_ProviderIsNull       = false;
            }
            Amazon.AppMesh.Model.VirtualRouterServiceProvider requestSpec_spec_Provider_spec_Provider_VirtualRouter = null;

            // populate VirtualRouter
            var requestSpec_spec_Provider_spec_Provider_VirtualRouterIsNull = true;

            requestSpec_spec_Provider_spec_Provider_VirtualRouter = new Amazon.AppMesh.Model.VirtualRouterServiceProvider();
            System.String requestSpec_spec_Provider_spec_Provider_VirtualRouter_virtualRouter_VirtualRouterName = null;
            if (cmdletContext.VirtualRouter_VirtualRouterName != null)
            {
                requestSpec_spec_Provider_spec_Provider_VirtualRouter_virtualRouter_VirtualRouterName = cmdletContext.VirtualRouter_VirtualRouterName;
            }
            if (requestSpec_spec_Provider_spec_Provider_VirtualRouter_virtualRouter_VirtualRouterName != null)
            {
                requestSpec_spec_Provider_spec_Provider_VirtualRouter.VirtualRouterName = requestSpec_spec_Provider_spec_Provider_VirtualRouter_virtualRouter_VirtualRouterName;
                requestSpec_spec_Provider_spec_Provider_VirtualRouterIsNull             = false;
            }
            // determine if requestSpec_spec_Provider_spec_Provider_VirtualRouter should be set to null
            if (requestSpec_spec_Provider_spec_Provider_VirtualRouterIsNull)
            {
                requestSpec_spec_Provider_spec_Provider_VirtualRouter = null;
            }
            if (requestSpec_spec_Provider_spec_Provider_VirtualRouter != null)
            {
                requestSpec_spec_Provider.VirtualRouter = requestSpec_spec_Provider_spec_Provider_VirtualRouter;
                requestSpec_spec_ProviderIsNull         = false;
            }
            // determine if requestSpec_spec_Provider should be set to null
            if (requestSpec_spec_ProviderIsNull)
            {
                requestSpec_spec_Provider = null;
            }
            if (requestSpec_spec_Provider != null)
            {
                request.Spec.Provider = requestSpec_spec_Provider;
                requestSpecIsNull     = false;
            }
            // determine if request.Spec should be set to null
            if (requestSpecIsNull)
            {
                request.Spec = null;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.VirtualServiceName != null)
            {
                request.VirtualServiceName = cmdletContext.VirtualServiceName;
            }

            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);
        }