/// <summary> /// Get the user associated with the current profile. /// </summary> /// <returns></returns> public User GetCurrentUser() { var request = new GetUserRequest(); GetUserResponse response = _iamClient.GetUser(request); return response.User; }
public async Task<User> RetrieveUser( string identifier, IAmazonIdentityManagementService proxy) { if (null == identifier) { throw new ArgumentException(AnchoringByNameBehavior.ArgumentNameIdentifier); } if (null == proxy) { throw new ArgumentNullException(AnchoringByNameBehavior.ArgumentNameProxy); } GetUserRequest request = new GetUserRequest() { UserName = identifier }; GetUserResult response = await proxy.GetUserAsync(request); User result = response.User; return result; }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.IdentityManagement.Model.GetUserRequest(); if (cmdletContext.UserName != null) { request.UserName = cmdletContext.UserName; } 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); }
/// <summary> /// <para>Retrieves information about the specified user, including the user's path, GUID, and ARN.</para> <para>If you do not specify a user /// name, IAM determines the user name implicitly based on the AWS Access Key ID signing the request.</para> /// </summary> /// /// <param name="getUserRequest">Container for the necessary parameters to execute the GetUser service method on /// AmazonIdentityManagementService.</param> /// /// <returns>The response from the GetUser service method, as returned by AmazonIdentityManagementService.</returns> /// /// <exception cref="NoSuchEntityException"/> public GetUserResponse GetUser(GetUserRequest getUserRequest) { IAsyncResult asyncResult = invokeGetUser(getUserRequest, null, null, true); return EndGetUser(asyncResult); }
/// <summary> /// Initiates the asynchronous execution of the GetUser operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetUser operation on AmazonIdentityManagementServiceClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetUser /// operation.</returns> public IAsyncResult BeginGetUser(GetUserRequest request, AsyncCallback callback, object state) { var marshaller = new GetUserRequestMarshaller(); var unmarshaller = GetUserResponseUnmarshaller.Instance; return BeginInvoke<GetUserRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// <para>Retrieves information about the specified User, including the /// User's path, GUID, and ARN.</para> <para>If you do not specify a User /// name, IAM determines the User name implicitly based on the AWS Access /// Key ID signing the request.</para> /// </summary> /// /// <param name="getUserRequest">Container for the necessary parameters to /// execute the GetUser service method on /// AmazonIdentityManagementService.</param> /// /// <returns>The response from the GetUser service method, as returned by /// AmazonIdentityManagementService.</returns> /// /// <exception cref="NoSuchEntityException"/> public GetUserResponse GetUser(GetUserRequest getUserRequest) { IRequest<GetUserRequest> request = new GetUserRequestMarshaller().Marshall(getUserRequest); GetUserResponse response = Invoke<GetUserRequest, GetUserResponse> (request, this.signer, GetUserResponseUnmarshaller.GetInstance()); return response; }
/// <summary> /// Initiates the asynchronous execution of the GetUser operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetUser operation on AmazonIdentityManagementServiceClient.</param> /// <param name="callback">An Action delegate that is invoked when the operation completes.</param> /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> public void GetUserAsync(GetUserRequest request, AmazonServiceCallback<GetUserRequest, GetUserResponse> callback, AsyncOptions options = null) { options = options == null?new AsyncOptions():options; var marshaller = new GetUserRequestMarshaller(); var unmarshaller = GetUserResponseUnmarshaller.Instance; Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null; if(callback !=null ) callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { AmazonServiceResult<GetUserRequest,GetUserResponse> responseObject = new AmazonServiceResult<GetUserRequest,GetUserResponse>((GetUserRequest)req, (GetUserResponse)res, ex , ao.State); callback(responseObject); }; BeginInvoke<GetUserRequest>(request, marshaller, unmarshaller, options, callbackHelper); }
IAsyncResult invokeGetUser(GetUserRequest request, AsyncCallback callback, object state, bool synchronized) { var marshaller = new GetUserRequestMarshaller(); var unmarshaller = GetUserResponseUnmarshaller.Instance; return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer); }
internal GetUserResponse GetUser(GetUserRequest request) { var marshaller = new GetUserRequestMarshaller(); var unmarshaller = GetUserResponseUnmarshaller.Instance; return Invoke<GetUserRequest,GetUserResponse>(request, marshaller, unmarshaller); }
public override async Task<Resource[]> Query( IQueryParameters parameters, string correlationIdentifier) { if (null == parameters) { throw new ArgumentNullException(AmazonWebServicesProvider.ArgumentNameParameters); } if (string.IsNullOrWhiteSpace(correlationIdentifier)) { throw new ArgumentNullException(AmazonWebServicesProvider.ArgumentNameCorrelationIdentifier); } if (null == parameters.AlternateFilters) { throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidParameters); } if (string.IsNullOrWhiteSpace(parameters.SchemaIdentifier)) { throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidParameters); } string informationAlternateFilterCount = parameters.AlternateFilters.Count.ToString(CultureInfo.InvariantCulture); ProvisioningAgentMonitor.Instance.Inform(informationAlternateFilterCount, true, correlationIdentifier); if (parameters.AlternateFilters.Count != 1) { string exceptionMessage = string.Format( CultureInfo.InvariantCulture, ProvisioningAgentResources.ExceptionFilterCountTemplate, 1, parameters.AlternateFilters.Count); throw new NotSupportedException(exceptionMessage); } Resource[] results; IFilter queryFilter = parameters.AlternateFilters.Single(); if (queryFilter.AdditionalFilter != null) { results = await this.QueryReference(parameters, correlationIdentifier); return results; } AmazonWebServicesProvider.Validate(parameters); if (string.IsNullOrWhiteSpace(queryFilter.AttributePath)) { throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidParameters); } if (string.IsNullOrWhiteSpace(queryFilter.ComparisonValue)) { throw new ArgumentException(ProvisioningAgentResources.ExceptionInvalidParameters); } if (!string.Equals(queryFilter.AttributePath, AttributeNames.ExternalIdentifier, StringComparison.Ordinal)) { throw new NotSupportedException(queryFilter.AttributePath); } IAmazonIdentityManagementService proxy = null; try { proxy = AWSClientFactory.CreateAmazonIdentityManagementServiceClient(this.credentials); switch (parameters.SchemaIdentifier) { case SchemaIdentifiers.Core2EnterpriseUser: GetUserRequest getRequestUser = new GetUserRequest() { UserName = queryFilter.ComparisonValue }; GetUserResult responseUser = await proxy.GetUserAsync(getRequestUser); if (null == responseUser.User) { return new Resource[0]; } Core2EnterpriseUser resourceUser = new Core2EnterpriseUser() { Identifier = responseUser.User.UserId, ExternalIdentifier = responseUser.User.UserName }; Resource[] resourceUsers = new Resource[] { resourceUser }; return resourceUsers; case SchemaIdentifiers.WindowsAzureActiveDirectoryGroup: GetGroupRequest getRequestGroup = new GetGroupRequest() { GroupName = queryFilter.ComparisonValue }; GetGroupResult responseGroup = await proxy.GetGroupAsync(getRequestGroup); if (null == responseGroup.Group) { return new Resource[0]; } WindowsAzureActiveDirectoryGroup resourceGroup = new WindowsAzureActiveDirectoryGroup() { Identifier = responseGroup.Group.GroupId, ExternalIdentifier = responseGroup.Group.GroupName }; Resource[] resourceGroups = new Resource[] { resourceGroup }; return resourceGroups; default: throw new NotSupportedException(parameters.SchemaIdentifier); } } finally { if (proxy != null) { proxy.Dispose(); proxy = null; } } }
/// <summary> /// <para>Retrieves information about the specified user, including the user's path, unique ID, and ARN.</para> <para>If you do not specify a /// user name, IAM determines the user name implicitly based on the AWS access key ID signing the request.</para> /// </summary> /// /// <param name="getUserRequest">Container for the necessary parameters to execute the GetUser service method on /// AmazonIdentityManagementService.</param> /// /// <returns>The response from the GetUser service method, as returned by AmazonIdentityManagementService.</returns> /// /// <exception cref="T:Amazon.IdentityManagement.Model.NoSuchEntityException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task<GetUserResponse> GetUserAsync(GetUserRequest getUserRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetUserRequestMarshaller(); var unmarshaller = GetUserResponseUnmarshaller.GetInstance(); return Invoke<IRequest, GetUserRequest, GetUserResponse>(getUserRequest, marshaller, unmarshaller, signer, cancellationToken); }
internal GetUserResponse GetUser(GetUserRequest request) { var task = GetUserAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
public virtual string PrepMode_GetUserArn(AmazonIdentityManagementServiceClient iamClient, string userName) { var userArn = String.Empty; var getUserRequest = new GetUserRequest {UserName = userName}; // Send the request and save the user arn. userArn = iamClient.GetUser(getUserRequest).User.Arn; return userArn; }
private Amazon.IdentityManagement.Model.GetUserResponse CallAWSServiceOperation(IAmazonIdentityManagementService client, Amazon.IdentityManagement.Model.GetUserRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Identity and Access Management", "GetUser"); try { #if DESKTOP return(client.GetUser(request)); #elif CORECLR return(client.GetUserAsync(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; } }
IAsyncResult invokeGetUser(GetUserRequest getUserRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new GetUserRequestMarshaller().Marshall(getUserRequest); var unmarshaller = GetUserResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the GetUser operation. /// <seealso cref="Amazon.IdentityManagement.AmazonIdentityManagementService.GetUser"/> /// </summary> /// /// <param name="getUserRequest">Container for the necessary parameters to execute the GetUser operation on /// AmazonIdentityManagementService.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetUser /// operation.</returns> public IAsyncResult BeginGetUser(GetUserRequest getUserRequest, AsyncCallback callback, object state) { return invokeGetUser(getUserRequest, callback, state, false); }
/// <summary> /// <para>Retrieves information about the specified user, including the user's path, unique ID, and ARN.</para> <para>If you do not specify a /// user name, IAM determines the user name implicitly based on the AWS access key ID signing the request.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetUser service method on /// AmazonIdentityManagementService.</param> /// /// <returns>The response from the GetUser service method, as returned by AmazonIdentityManagementService.</returns> /// /// <exception cref="T:Amazon.IdentityManagement.Model.NoSuchEntityException" /> public GetUserResponse GetUser(GetUserRequest request) { var task = GetUserAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// Initiates the asynchronous execution of the GetUser operation. /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetUser operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<GetUserResponse> GetUserAsync(GetUserRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetUserRequestMarshaller(); var unmarshaller = GetUserResponseUnmarshaller.Instance; return InvokeAsync<GetUserRequest,GetUserResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Initiates the asynchronous execution of the GetUser operation. /// <seealso cref="Amazon.IdentityManagement.IAmazonIdentityManagementService.GetUser"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the GetUser operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public async Task<GetUserResponse> GetUserAsync(GetUserRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new GetUserRequestMarshaller(); var unmarshaller = GetUserResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, GetUserRequest, GetUserResponse>(request, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }