コード例 #1
0
        /// <summary>Snippet for CreateTriggerAsync</summary>
        public async Task CreateTriggerResourceNamesAsync()
        {
            // Snippet: CreateTriggerAsync(LocationName, Trigger, string, CallSettings)
            // Additional: CreateTriggerAsync(LocationName, Trigger, string, CancellationToken)
            // Create client
            EventarcClient eventarcClient = await EventarcClient.CreateAsync();

            // Initialize request argument(s)
            LocationName parent    = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
            Trigger      trigger   = new Trigger();
            string       triggerId = "";
            // Make the request
            Operation <Trigger, OperationMetadata> response = await eventarcClient.CreateTriggerAsync(parent, trigger, triggerId);

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

            // Retrieve the operation result
            Trigger 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 <Trigger, OperationMetadata> retrievedResponse = await eventarcClient.PollOnceCreateTriggerAsync(operationName);

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