예제 #1
0
        internal ListGrantsResponse ListGrants(ListGrantsRequest request)
        {
            var marshaller   = new ListGrantsRequestMarshaller();
            var unmarshaller = ListGrantsResponseUnmarshaller.Instance;

            return(Invoke <ListGrantsRequest, ListGrantsResponse>(request, marshaller, unmarshaller));
        }
예제 #2
0
        public static async Task Main()
        {
            // The identifier of the AWS KMS key to disable. You can use the
            // key Id or the Amazon Resource Name (ARN) of the AWS KMS key.
            var keyId   = "1234abcd-12ab-34cd-56ef-1234567890ab";
            var client  = new AmazonKeyManagementServiceClient();
            var request = new ListGrantsRequest
            {
                KeyId = keyId,
            };

            var response = new ListGrantsResponse();

            do
            {
                response = await client.ListGrantsAsync(request);

                response.Grants.ForEach(grant =>
                {
                    Console.WriteLine($"{grant.GrantId}");
                });

                request.Marker = response.NextMarker;
            }while (response.Truncated);
        }
        private static void ListGrant(KmsClient kmsClient)
        {
            try
            {
                var request = new ListGrantsRequest
                {
                    VersionId = "v1.0",
                    Body      = new ListGrantsRequestBody()
                    {
                        KeyId = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2")
                    }
                };
                var resp = kmsClient.ListGrants(request);

                Console.WriteLine(resp);
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }
예제 #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListGrants operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the ListGrants 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 <ListGrantsResponse> ListGrantsAsync(ListGrantsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new ListGrantsRequestMarshaller();
            var unmarshaller = ListGrantsResponseUnmarshaller.Instance;

            return(InvokeAsync <ListGrantsRequest, ListGrantsResponse>(request, marshaller,
                                                                       unmarshaller, cancellationToken));
        }
예제 #5
0
        /// <summary>
        /// 查询授权列表
        /// </summary>
        public async Task <ListGrantsResponse> ListGrantsAsync(ListGrantsRequest listGrantsRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("version_id", listGrantsRequest.VersionId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/{version_id}/{project_id}/kms/list-grants", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", listGrantsRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("POST", request);

            return(JsonUtils.DeSerialize <ListGrantsResponse>(response));
        }
예제 #6
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListGrantsRequest request;

            try
            {
                request = new ListGrantsRequest
                {
                    UserAssessmentId  = UserAssessmentId,
                    UserKey           = UserKey,
                    GrantKey          = GrantKey,
                    GrantName         = GrantName,
                    PrivilegeType     = PrivilegeType,
                    PrivilegeCategory = PrivilegeCategory,
                    DepthLevel        = DepthLevel,
                    DepthLevelGreaterThanOrEqualTo = DepthLevelGreaterThanOrEqualTo,
                    DepthLevelLessThan             = DepthLevelLessThan,
                    Limit        = Limit,
                    Page         = Page,
                    SortOrder    = SortOrder,
                    SortBy       = SortBy,
                    OpcRequestId = OpcRequestId
                };
                IEnumerable <ListGrantsResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null)
                {
                    WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources.");
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }