예제 #1
0
        /// <summary>Snippet for DiagnoseCluster</summary>
        public void DiagnoseCluster_RequestObject()
        {
            // Snippet: DiagnoseCluster(DiagnoseClusterRequest,CallSettings)
            // Create client
            ClusterControllerClient clusterControllerClient = ClusterControllerClient.Create();
            // Initialize request argument(s)
            DiagnoseClusterRequest request = new DiagnoseClusterRequest
            {
                ProjectId   = "",
                Region      = "",
                ClusterName = "",
            };
            // Make the request
            Operation <Empty, DiagnoseClusterResults> response =
                clusterControllerClient.DiagnoseCluster(request);

            // Poll until the returned long-running operation is complete
            Operation <Empty, DiagnoseClusterResults> completedResponse =
                response.PollUntilCompleted();
            // The long-running operation is now complete.

            // 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, DiagnoseClusterResults> retrievedResponse =
                clusterControllerClient.PollOnceDiagnoseCluster(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // The long-running operation is now complete.
            }
            // End snippet
        }
        /// <summary>Snippet for DiagnoseClusterAsync</summary>
        public async Task DiagnoseClusterRequestObjectAsync()
        {
            // Snippet: DiagnoseClusterAsync(DiagnoseClusterRequest, CallSettings)
            // Additional: DiagnoseClusterAsync(DiagnoseClusterRequest, CancellationToken)
            // Create client
            ClusterControllerClient clusterControllerClient = await ClusterControllerClient.CreateAsync();

            // Initialize request argument(s)
            DiagnoseClusterRequest request = new DiagnoseClusterRequest
            {
                ProjectId   = "",
                ClusterName = "",
                Region      = "",
            };
            // Make the request
            Operation <DiagnoseClusterResults, ClusterOperationMetadata> response = await clusterControllerClient.DiagnoseClusterAsync(request);

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

            // Retrieve the operation result
            DiagnoseClusterResults 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 <DiagnoseClusterResults, ClusterOperationMetadata> retrievedResponse = await clusterControllerClient.PollOnceDiagnoseClusterAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                DiagnoseClusterResults retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
        /// <summary>
        /// Gets cluster diagnostic information. After the operation completes, the Operation.response field contains `DiagnoseClusterOutputLocation`.
        /// Documentation https://developers.google.com/dataproc/v1beta1/reference/clusters/diagnose
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated dataproc service.</param>
        /// <param name="projectId">[Required] The ID of the Google Cloud Platform project that the cluster belongs to.</param>
        /// <param name="clusterName">[Required] The cluster name.</param>
        /// <param name="body">A valid dataproc v1beta1 body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation Diagnose(dataprocService service, string projectId, string clusterName, DiagnoseClusterRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (projectId == null)
                {
                    throw new ArgumentNullException(projectId);
                }
                if (clusterName == null)
                {
                    throw new ArgumentNullException(clusterName);
                }

                // Make the request.
                return(service.Clusters.Diagnose(body, projectId, clusterName).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Clusters.Diagnose failed.", ex);
            }
        }