AdminEnableUserRequest

We found 10 examples in language CSharp for this search. You will see 19 fragments of code.
        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>  
        /// <param name="input"></param>
        /// <returns></returns>
        public IRequest Marshall(AmazonWebServiceRequest input)
        {
            return this.Marshall((AdminEnableUserRequest)input);
        }

        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>  
        /// <param name="input"></param>
        /// <returns></returns>
        public IRequest Marshall(AmazonWebServiceRequest input)
        {
            return this.Marshall((AdminEnableUserRequest)input);
        }

        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>  
        /// <param name="input"></param>
        /// <returns></returns>
        public IRequest Marshall(AmazonWebServiceRequest input)
        {
            return this.Marshall((AdminEnableUserRequest)input);
        }

        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>  
        /// <param name="input"></param>
        /// <returns></returns>
        public IRequest Marshall(AmazonWebServiceRequest input)
        {
            return this.Marshall((AdminEnableUserRequest)input);
        }

        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>  
        /// <param name="input"></param>
        /// <returns></returns>
        public IRequest Marshall(AmazonWebServiceRequest input)
        {
            return this.Marshall((AdminEnableUserRequest)input);
        }

        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>  
        /// <param name="input"></param>
        /// <returns></returns>
        public IRequest Marshall(AmazonWebServiceRequest input)
        {
            return this.Marshall((AdminEnableUserRequest)input);
        }

        /// <summary>
        /// Marshaller the request object to the HTTP request.
        /// </summary>  
        /// <param name="input"></param>
        /// <returns></returns>
        public IRequest Marshall(AmazonWebServiceRequest input)
        {
            return this.Marshall((AdminEnableUserRequest)input);
        }


    public async Task ActivateUserAsync(string userName)
    {
      await _provider.AdminEnableUserAsync(new AdminEnableUserRequest
      {
        UserPoolId = _config.PoolId,
        Username = userName
      });
    }

    public async Task EnabledUserAsync(string userName)
    {
      var request = new AdminEnableUserRequest
      {
        Username = userName,
        UserPoolId = _config.PoolId
      };

      await _provider.AdminEnableUserAsync(request);
    }


        public async Task<Guid> CreateAsync(Profile profile)
        {
            var request = CreateUser(profile);

            AdminCreateUserResponse result = null;

            try
            {
                result = await _provider.AdminCreateUserAsync(request);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Exception: {e.Message}");
            }

            return Guid.Parse(result.User.Attributes.FirstOrDefault(a => a.Name == "sub").Value);
        }

        public async Task<HttpStatusCode> AdminUpdateUserAttributesAsync(Profile profile)
        {
            var request = new AdminUpdateUserAttributesRequest
            {
                UserPoolId = _cognito.UserPool.Id,
                Username = $"{profile.Email}",
                UserAttributes = profile.GetCognitoAttributes().ToList()
            };

            AdminUpdateUserAttributesResponse response;
            
            try
            {
                response = await _provider.AdminUpdateUserAttributesAsync(request);
            }
            catch (Exception e)
            {
                Console.WriteLine($"Exception: {e}");
                throw new Exception();
            }

            return response.HttpStatusCode;
        }

        public async Task DisableUserAsync(Guid key)
        {
            var request = new AdminDisableUserRequest
            {
                Username = $"{key}",
                UserPoolId = _cognito.UserPool.Id
            };

            await _provider.AdminDisableUserAsync(request);
        }

        public async Task EnableUserAsync(Guid key)
        {
            var request = new AdminEnableUserRequest
            {
                Username = $"{key}",
                UserPoolId = _cognito.UserPool.Id
            };

            await _provider.AdminEnableUserAsync(request);
        }

        public async Task AdminResetUserPassword(Guid key)
        {
            var request = new AdminResetUserPasswordRequest
            {
                Username = $"{key}",
                UserPoolId = _cognito.UserPool.Id
            };

            await _provider.AdminResetUserPasswordAsync(request);
        }

        AdminCreateUserRequest CreateUser(Profile profile)
        {
            // TODO: remove 
            var password = $"RSC-{Guid.NewGuid()}";
            Console.WriteLine([email protected]"PASSWORD: {password}");

            return new AdminCreateUserRequest
            {
                UserPoolId = _cognito.UserPool.Id,
                Username = profile.Email,
                TemporaryPassword = password,
                MessageAction = MessageActionType.SUPPRESS,
                UserAttributes = profile.GetCognitoAttributes().ToList(),
            };
        }

        #endregion
        
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            
            var resourceIdentifiersText = FormatParameterValuesForConfirmationMsg(nameof(this.UserPoolId), MyInvocation.BoundParameters);
            if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "Enable-CGIPUserAdmin (AdminEnableUser)"))
            {
                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<Amazon.CognitoIdentityProvider.Model.AdminEnableUserResponse, EnableCGIPUserAdminCmdlet>(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.UserPoolId;
            }
            #pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
            context.Username = this.Username;
            #if MODULAR
            if (this.Username == null && ParameterWasBound(nameof(this.Username)))
            {
                WriteWarning("You are passing $null as a value for parameter Username 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.UserPoolId = this.UserPoolId;
            #if MODULAR
            if (this.UserPoolId == null && ParameterWasBound(nameof(this.UserPoolId)))
            {
                WriteWarning("You are passing $null as a value for parameter UserPoolId 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
            
            // 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.CognitoIdentityProvider.Model.AdminEnableUserRequest();
            
            if (cmdletContext.Username != null)
            {
                request.Username = cmdletContext.Username;
            }
            if (cmdletContext.UserPoolId != null)
            {
                request.UserPoolId = cmdletContext.UserPoolId;
            }
            
            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.CognitoIdentityProvider.Model.AdminEnableUserResponse CallAWSServiceOperation(IAmazonCognitoIdentityProvider client, Amazon.CognitoIdentityProvider.Model.AdminEnableUserRequest request)
        {
            Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Cognito Identity Provider", "AdminEnableUser");
            try
            {
                #if DESKTOP
                return client.AdminEnableUser(request);
                #elif CORECLR
                return client.AdminEnableUserAsync(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;
            }
        }

Amazon.CognitoIdentityProvider.Model.AdminEnableUserRequest : IAmazonWebServiceRequest

Constructors :

public AdminEnableUserRequest()

Methods :

public String get_Username()
public Void set_Username(String value = )
public String get_UserPoolId()
public Void set_UserPoolId(String value = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()