Ejemplo n.º 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
        }
Ejemplo n.º 2
0
        public static int Main(string[] args)
        {
            // Read projectId from args
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: Project ID must be passed as first argument.");
                Console.WriteLine();
                return(1);
            }
            string projectId = args[0];

            // Create client
            ClusterControllerClient client = ClusterControllerClient.Create();

            // Initialize request argument(s)
            string projectId2 = projectId;
            string region     = "global";

            // Call API method
            PagedEnumerable <ListClustersResponse, Cluster> pagedResponse = client.ListClusters(projectId2, region);

            // Show the result
            foreach (var item in pagedResponse)
            {
                Console.WriteLine(item);
            }

            // Success
            Console.WriteLine("Smoke test passed OK");
            return(0);
        }
Ejemplo n.º 3
0
        /// <summary>Snippet for CreateCluster</summary>
        public void CreateCluster()
        {
            // Snippet: CreateCluster(string,string,Cluster,CallSettings)
            // Create client
            ClusterControllerClient clusterControllerClient = ClusterControllerClient.Create();
            // Initialize request argument(s)
            string  projectId = "";
            string  region    = "";
            Cluster cluster   = new Cluster();
            // Make the request
            Operation <Cluster, ClusterOperationMetadata> response =
                clusterControllerClient.CreateCluster(projectId, region, cluster);

            // Poll until the returned long-running operation is complete
            Operation <Cluster, ClusterOperationMetadata> completedResponse =
                response.PollUntilCompleted();
            // Retrieve the operation result
            Cluster 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 <Cluster, ClusterOperationMetadata> retrievedResponse =
                clusterControllerClient.PollOnceCreateCluster(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Cluster retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
        /// <summary>Snippet for DeleteCluster</summary>
        public void DeleteClusterRequestObject()
        {
            // Snippet: DeleteCluster(DeleteClusterRequest, CallSettings)
            // Create client
            ClusterControllerClient clusterControllerClient = ClusterControllerClient.Create();
            // Initialize request argument(s)
            DeleteClusterRequest request = new DeleteClusterRequest
            {
                ProjectId   = "",
                ClusterName = "",
                Region      = "",
                ClusterUuid = "",
                RequestId   = "",
            };
            // Make the request
            Operation <Empty, ClusterOperationMetadata> response = clusterControllerClient.DeleteCluster(request);

            // Poll until the returned long-running operation is complete
            Operation <Empty, ClusterOperationMetadata> completedResponse = response.PollUntilCompleted();
            // 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, ClusterOperationMetadata> retrievedResponse = clusterControllerClient.PollOnceDeleteCluster(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
        }
Ejemplo n.º 5
0
 /// <summary>Snippet for GetCluster</summary>
 public void GetCluster()
 {
     // Snippet: GetCluster(string,string,string,CallSettings)
     // Create client
     ClusterControllerClient clusterControllerClient = ClusterControllerClient.Create();
     // Initialize request argument(s)
     string projectId   = "";
     string region      = "";
     string clusterName = "";
     // Make the request
     Cluster response = clusterControllerClient.GetCluster(projectId, region, clusterName);
     // End snippet
 }
        /// <summary>Snippet for ListClusters</summary>
        public void ListClustersRequestObject()
        {
            // Snippet: ListClusters(ListClustersRequest, CallSettings)
            // Create client
            ClusterControllerClient clusterControllerClient = ClusterControllerClient.Create();
            // Initialize request argument(s)
            ListClustersRequest request = new ListClustersRequest
            {
                ProjectId = "",
                Region    = "",
                Filter    = "",
            };
            // Make the request
            PagedEnumerable <ListClustersResponse, Cluster> response = clusterControllerClient.ListClusters(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Cluster item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (ListClustersResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Cluster 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 <Cluster> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (Cluster 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
        }
Ejemplo n.º 7
0
 /// <summary>Snippet for GetCluster</summary>
 public void GetCluster_RequestObject()
 {
     // Snippet: GetCluster(GetClusterRequest,CallSettings)
     // Create client
     ClusterControllerClient clusterControllerClient = ClusterControllerClient.Create();
     // Initialize request argument(s)
     GetClusterRequest request = new GetClusterRequest
     {
         ProjectId   = "",
         Region      = "",
         ClusterName = "",
     };
     // Make the request
     Cluster response = clusterControllerClient.GetCluster(request);
     // End snippet
 }
        /// <summary>Snippet for UpdateCluster</summary>
        public void UpdateClusterRequestObject()
        {
            // Snippet: UpdateCluster(UpdateClusterRequest, CallSettings)
            // Create client
            ClusterControllerClient clusterControllerClient = ClusterControllerClient.Create();
            // Initialize request argument(s)
            UpdateClusterRequest request = new UpdateClusterRequest
            {
                ProjectId   = "",
                ClusterName = "",
                Cluster     = new Cluster(),
                UpdateMask  = new FieldMask(),
                Region      = "",
                GracefulDecommissionTimeout = new Duration(),
                RequestId = "",
            };
            // Make the request
            Operation <Cluster, ClusterOperationMetadata> response = clusterControllerClient.UpdateCluster(request);

            // Poll until the returned long-running operation is complete
            Operation <Cluster, ClusterOperationMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Cluster 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 <Cluster, ClusterOperationMetadata> retrievedResponse = clusterControllerClient.PollOnceUpdateCluster(operationName);

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