예제 #1
0
        /// <summary>Snippet for GetMembershipAsync</summary>
        public async Task GetMembershipAsync()
        {
            // Snippet: GetMembershipAsync(string, CallSettings)
            // Additional: GetMembershipAsync(string, CancellationToken)
            // Create client
            GkeHubMembershipServiceClient gkeHubMembershipServiceClient = await GkeHubMembershipServiceClient.CreateAsync();

            // Initialize request argument(s)
            string name = "";
            // Make the request
            Membership response = await gkeHubMembershipServiceClient.GetMembershipAsync(name);

            // End snippet
        }
        /// <summary>Snippet for GetMembershipAsync</summary>
        public async Task GetMembershipRequestObjectAsync()
        {
            // Snippet: GetMembershipAsync(GetMembershipRequest, CallSettings)
            // Additional: GetMembershipAsync(GetMembershipRequest, CancellationToken)
            // Create client
            GkeHubMembershipServiceClient gkeHubMembershipServiceClient = await GkeHubMembershipServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetMembershipRequest request = new GetMembershipRequest {
                Name = "",
            };
            // Make the request
            Membership response = await gkeHubMembershipServiceClient.GetMembershipAsync(request);

            // End snippet
        }
        /// <summary>Snippet for ListMembershipsAsync</summary>
        public async Task ListMembershipsAsync()
        {
            // Snippet: ListMembershipsAsync(string, string, int?, CallSettings)
            // Create client
            GkeHubMembershipServiceClient gkeHubMembershipServiceClient = await GkeHubMembershipServiceClient.CreateAsync();

            // Initialize request argument(s)
            string parent = "";
            // Make the request
            PagedAsyncEnumerable <ListMembershipsResponse, Membership> response = gkeHubMembershipServiceClient.ListMembershipsAsync(parent);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Membership item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((ListMembershipsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Membership item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            });

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <Membership> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Membership item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
        /// <summary>Snippet for ValidateExclusivityAsync</summary>
        public async Task ValidateExclusivityRequestObjectAsync()
        {
            // Snippet: ValidateExclusivityAsync(ValidateExclusivityRequest, CallSettings)
            // Additional: ValidateExclusivityAsync(ValidateExclusivityRequest, CancellationToken)
            // Create client
            GkeHubMembershipServiceClient gkeHubMembershipServiceClient = await GkeHubMembershipServiceClient.CreateAsync();

            // Initialize request argument(s)
            ValidateExclusivityRequest request = new ValidateExclusivityRequest
            {
                Parent             = "",
                CrManifest         = "",
                IntendedMembership = "",
            };
            // Make the request
            ValidateExclusivityResponse response = await gkeHubMembershipServiceClient.ValidateExclusivityAsync(request);

            // End snippet
        }
        /// <summary>Snippet for GenerateConnectManifestAsync</summary>
        public async Task GenerateConnectManifestRequestObjectAsync()
        {
            // Snippet: GenerateConnectManifestAsync(GenerateConnectManifestRequest, CallSettings)
            // Additional: GenerateConnectManifestAsync(GenerateConnectManifestRequest, CancellationToken)
            // Create client
            GkeHubMembershipServiceClient gkeHubMembershipServiceClient = await GkeHubMembershipServiceClient.CreateAsync();

            // Initialize request argument(s)
            GenerateConnectManifestRequest request = new GenerateConnectManifestRequest
            {
                Name                   = "",
                ConnectAgent           = new ConnectAgent(),
                Version                = "",
                IsUpgrade              = false,
                Registry               = "",
                ImagePullSecretContent = ByteString.Empty,
            };
            // Make the request
            GenerateConnectManifestResponse response = await gkeHubMembershipServiceClient.GenerateConnectManifestAsync(request);

            // End snippet
        }
        /// <summary>Snippet for UpdateMembershipAsync</summary>
        public async Task UpdateMembershipRequestObjectAsync()
        {
            // Snippet: UpdateMembershipAsync(UpdateMembershipRequest, CallSettings)
            // Additional: UpdateMembershipAsync(UpdateMembershipRequest, CancellationToken)
            // Create client
            GkeHubMembershipServiceClient gkeHubMembershipServiceClient = await GkeHubMembershipServiceClient.CreateAsync();

            // Initialize request argument(s)
            UpdateMembershipRequest request = new UpdateMembershipRequest
            {
                Name       = "",
                UpdateMask = new FieldMask(),
                Resource   = new Membership(),
                RequestId  = "",
            };
            // Make the request
            Operation <Membership, OperationMetadata> response = await gkeHubMembershipServiceClient.UpdateMembershipAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <Membership, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Membership result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Membership, OperationMetadata> retrievedResponse = await gkeHubMembershipServiceClient.PollOnceUpdateMembershipAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Membership retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }