コード例 #1
0
        /// <summary>Snippet for DeleteConnectorAsync</summary>
        public async Task DeleteConnectorResourceNamesAsync()
        {
            // Snippet: DeleteConnectorAsync(ConnectorName, CallSettings)
            // Additional: DeleteConnectorAsync(ConnectorName, CancellationToken)
            // Create client
            VpcAccessServiceClient vpcAccessServiceClient = await VpcAccessServiceClient.CreateAsync();

            // Initialize request argument(s)
            ConnectorName name = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]");
            // Make the request
            Operation <Empty, OperationMetadata> response = await vpcAccessServiceClient.DeleteConnectorAsync(name);

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

            // Retrieve the operation result
            Empty 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 <Empty, OperationMetadata> retrievedResponse = await vpcAccessServiceClient.PollOnceDeleteConnectorAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Empty retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
コード例 #2
0
        /// <summary>Snippet for CreateConnectorAsync</summary>
        public async Task CreateConnectorResourceNamesAsync()
        {
            // Snippet: CreateConnectorAsync(LocationName, string, Connector, CallSettings)
            // Additional: CreateConnectorAsync(LocationName, string, Connector, CancellationToken)
            // Create client
            VpcAccessServiceClient vpcAccessServiceClient = await VpcAccessServiceClient.CreateAsync();

            // Initialize request argument(s)
            LocationName parent      = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            string       connectorId = "";
            Connector    connector   = new Connector();
            // Make the request
            Operation <Connector, OperationMetadata> response = await vpcAccessServiceClient.CreateConnectorAsync(parent, connectorId, connector);

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

            // Retrieve the operation result
            Connector 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 <Connector, OperationMetadata> retrievedResponse = await vpcAccessServiceClient.PollOnceCreateConnectorAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Connector retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
コード例 #3
0
        /// <summary>Snippet for GetConnectorAsync</summary>
        public async Task GetConnectorResourceNamesAsync()
        {
            // Snippet: GetConnectorAsync(ConnectorName, CallSettings)
            // Additional: GetConnectorAsync(ConnectorName, CancellationToken)
            // Create client
            VpcAccessServiceClient vpcAccessServiceClient = await VpcAccessServiceClient.CreateAsync();

            // Initialize request argument(s)
            ConnectorName name = ConnectorName.FromProjectLocationConnector("[PROJECT]", "[LOCATION]", "[CONNECTOR]");
            // Make the request
            Connector response = await vpcAccessServiceClient.GetConnectorAsync(name);

            // End snippet
        }
コード例 #4
0
        /// <summary>Snippet for GetConnectorAsync</summary>
        public async Task GetConnectorAsync()
        {
            // Snippet: GetConnectorAsync(string, CallSettings)
            // Additional: GetConnectorAsync(string, CancellationToken)
            // Create client
            VpcAccessServiceClient vpcAccessServiceClient = await VpcAccessServiceClient.CreateAsync();

            // Initialize request argument(s)
            string name = "projects/[PROJECT]/locations/[LOCATION]/connectors/[CONNECTOR]";
            // Make the request
            Connector response = await vpcAccessServiceClient.GetConnectorAsync(name);

            // End snippet
        }
コード例 #5
0
        /// <summary>Snippet for ListConnectorsAsync</summary>
        public async Task ListConnectorsRequestObjectAsync()
        {
            // Snippet: ListConnectorsAsync(ListConnectorsRequest, CallSettings)
            // Create client
            VpcAccessServiceClient vpcAccessServiceClient = await VpcAccessServiceClient.CreateAsync();

            // Initialize request argument(s)
            ListConnectorsRequest request = new ListConnectorsRequest
            {
                ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            };
            // Make the request
            PagedAsyncEnumerable <ListConnectorsResponse, Connector> response = vpcAccessServiceClient.ListConnectorsAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((Connector 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((ListConnectorsResponse page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Connector 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 <Connector> 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 (Connector 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
        }