Esempio n. 1
0
 private Amazon.IoTSiteWise.Model.UpdateAccessPolicyResponse CallAWSServiceOperation(IAmazonIoTSiteWise client, Amazon.IoTSiteWise.Model.UpdateAccessPolicyRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT SiteWise", "UpdateAccessPolicy");
     try
     {
         #if DESKTOP
         return(client.UpdateAccessPolicy(request));
         #elif CORECLR
         return(client.UpdateAccessPolicyAsync(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;
     }
 }
Esempio n. 2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.IoTSiteWise.Model.UpdateAccessPolicyRequest();

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

            // populate AccessPolicyIdentity
            var requestAccessPolicyIdentityIsNull = true;

            request.AccessPolicyIdentity = new Amazon.IoTSiteWise.Model.Identity();
            Amazon.IoTSiteWise.Model.GroupIdentity requestAccessPolicyIdentity_accessPolicyIdentity_Group = null;

            // populate Group
            var requestAccessPolicyIdentity_accessPolicyIdentity_GroupIsNull = true;

            requestAccessPolicyIdentity_accessPolicyIdentity_Group = new Amazon.IoTSiteWise.Model.GroupIdentity();
            System.String requestAccessPolicyIdentity_accessPolicyIdentity_Group_group_Id = null;
            if (cmdletContext.Group_Id != null)
            {
                requestAccessPolicyIdentity_accessPolicyIdentity_Group_group_Id = cmdletContext.Group_Id;
            }
            if (requestAccessPolicyIdentity_accessPolicyIdentity_Group_group_Id != null)
            {
                requestAccessPolicyIdentity_accessPolicyIdentity_Group.Id    = requestAccessPolicyIdentity_accessPolicyIdentity_Group_group_Id;
                requestAccessPolicyIdentity_accessPolicyIdentity_GroupIsNull = false;
            }
            // determine if requestAccessPolicyIdentity_accessPolicyIdentity_Group should be set to null
            if (requestAccessPolicyIdentity_accessPolicyIdentity_GroupIsNull)
            {
                requestAccessPolicyIdentity_accessPolicyIdentity_Group = null;
            }
            if (requestAccessPolicyIdentity_accessPolicyIdentity_Group != null)
            {
                request.AccessPolicyIdentity.Group = requestAccessPolicyIdentity_accessPolicyIdentity_Group;
                requestAccessPolicyIdentityIsNull  = false;
            }
            Amazon.IoTSiteWise.Model.IAMUserIdentity requestAccessPolicyIdentity_accessPolicyIdentity_IamUser = null;

            // populate IamUser
            var requestAccessPolicyIdentity_accessPolicyIdentity_IamUserIsNull = true;

            requestAccessPolicyIdentity_accessPolicyIdentity_IamUser = new Amazon.IoTSiteWise.Model.IAMUserIdentity();
            System.String requestAccessPolicyIdentity_accessPolicyIdentity_IamUser_iamUser_Arn = null;
            if (cmdletContext.IamUser_Arn != null)
            {
                requestAccessPolicyIdentity_accessPolicyIdentity_IamUser_iamUser_Arn = cmdletContext.IamUser_Arn;
            }
            if (requestAccessPolicyIdentity_accessPolicyIdentity_IamUser_iamUser_Arn != null)
            {
                requestAccessPolicyIdentity_accessPolicyIdentity_IamUser.Arn   = requestAccessPolicyIdentity_accessPolicyIdentity_IamUser_iamUser_Arn;
                requestAccessPolicyIdentity_accessPolicyIdentity_IamUserIsNull = false;
            }
            // determine if requestAccessPolicyIdentity_accessPolicyIdentity_IamUser should be set to null
            if (requestAccessPolicyIdentity_accessPolicyIdentity_IamUserIsNull)
            {
                requestAccessPolicyIdentity_accessPolicyIdentity_IamUser = null;
            }
            if (requestAccessPolicyIdentity_accessPolicyIdentity_IamUser != null)
            {
                request.AccessPolicyIdentity.IamUser = requestAccessPolicyIdentity_accessPolicyIdentity_IamUser;
                requestAccessPolicyIdentityIsNull    = false;
            }
            Amazon.IoTSiteWise.Model.UserIdentity requestAccessPolicyIdentity_accessPolicyIdentity_User = null;

            // populate User
            var requestAccessPolicyIdentity_accessPolicyIdentity_UserIsNull = true;

            requestAccessPolicyIdentity_accessPolicyIdentity_User = new Amazon.IoTSiteWise.Model.UserIdentity();
            System.String requestAccessPolicyIdentity_accessPolicyIdentity_User_user_Id = null;
            if (cmdletContext.User_Id != null)
            {
                requestAccessPolicyIdentity_accessPolicyIdentity_User_user_Id = cmdletContext.User_Id;
            }
            if (requestAccessPolicyIdentity_accessPolicyIdentity_User_user_Id != null)
            {
                requestAccessPolicyIdentity_accessPolicyIdentity_User.Id    = requestAccessPolicyIdentity_accessPolicyIdentity_User_user_Id;
                requestAccessPolicyIdentity_accessPolicyIdentity_UserIsNull = false;
            }
            // determine if requestAccessPolicyIdentity_accessPolicyIdentity_User should be set to null
            if (requestAccessPolicyIdentity_accessPolicyIdentity_UserIsNull)
            {
                requestAccessPolicyIdentity_accessPolicyIdentity_User = null;
            }
            if (requestAccessPolicyIdentity_accessPolicyIdentity_User != null)
            {
                request.AccessPolicyIdentity.User = requestAccessPolicyIdentity_accessPolicyIdentity_User;
                requestAccessPolicyIdentityIsNull = false;
            }
            // determine if request.AccessPolicyIdentity should be set to null
            if (requestAccessPolicyIdentityIsNull)
            {
                request.AccessPolicyIdentity = null;
            }
            if (cmdletContext.AccessPolicyPermission != null)
            {
                request.AccessPolicyPermission = cmdletContext.AccessPolicyPermission;
            }

            // populate AccessPolicyResource
            var requestAccessPolicyResourceIsNull = true;

            request.AccessPolicyResource = new Amazon.IoTSiteWise.Model.Resource();
            Amazon.IoTSiteWise.Model.PortalResource requestAccessPolicyResource_accessPolicyResource_Portal = null;

            // populate Portal
            var requestAccessPolicyResource_accessPolicyResource_PortalIsNull = true;

            requestAccessPolicyResource_accessPolicyResource_Portal = new Amazon.IoTSiteWise.Model.PortalResource();
            System.String requestAccessPolicyResource_accessPolicyResource_Portal_portal_Id = null;
            if (cmdletContext.Portal_Id != null)
            {
                requestAccessPolicyResource_accessPolicyResource_Portal_portal_Id = cmdletContext.Portal_Id;
            }
            if (requestAccessPolicyResource_accessPolicyResource_Portal_portal_Id != null)
            {
                requestAccessPolicyResource_accessPolicyResource_Portal.Id    = requestAccessPolicyResource_accessPolicyResource_Portal_portal_Id;
                requestAccessPolicyResource_accessPolicyResource_PortalIsNull = false;
            }
            // determine if requestAccessPolicyResource_accessPolicyResource_Portal should be set to null
            if (requestAccessPolicyResource_accessPolicyResource_PortalIsNull)
            {
                requestAccessPolicyResource_accessPolicyResource_Portal = null;
            }
            if (requestAccessPolicyResource_accessPolicyResource_Portal != null)
            {
                request.AccessPolicyResource.Portal = requestAccessPolicyResource_accessPolicyResource_Portal;
                requestAccessPolicyResourceIsNull   = false;
            }
            Amazon.IoTSiteWise.Model.ProjectResource requestAccessPolicyResource_accessPolicyResource_Project = null;

            // populate Project
            var requestAccessPolicyResource_accessPolicyResource_ProjectIsNull = true;

            requestAccessPolicyResource_accessPolicyResource_Project = new Amazon.IoTSiteWise.Model.ProjectResource();
            System.String requestAccessPolicyResource_accessPolicyResource_Project_project_Id = null;
            if (cmdletContext.Project_Id != null)
            {
                requestAccessPolicyResource_accessPolicyResource_Project_project_Id = cmdletContext.Project_Id;
            }
            if (requestAccessPolicyResource_accessPolicyResource_Project_project_Id != null)
            {
                requestAccessPolicyResource_accessPolicyResource_Project.Id    = requestAccessPolicyResource_accessPolicyResource_Project_project_Id;
                requestAccessPolicyResource_accessPolicyResource_ProjectIsNull = false;
            }
            // determine if requestAccessPolicyResource_accessPolicyResource_Project should be set to null
            if (requestAccessPolicyResource_accessPolicyResource_ProjectIsNull)
            {
                requestAccessPolicyResource_accessPolicyResource_Project = null;
            }
            if (requestAccessPolicyResource_accessPolicyResource_Project != null)
            {
                request.AccessPolicyResource.Project = requestAccessPolicyResource_accessPolicyResource_Project;
                requestAccessPolicyResourceIsNull    = false;
            }
            // determine if request.AccessPolicyResource should be set to null
            if (requestAccessPolicyResourceIsNull)
            {
                request.AccessPolicyResource = null;
            }
            if (cmdletContext.ClientToken != null)
            {
                request.ClientToken = cmdletContext.ClientToken;
            }

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