public static object DeleteInstance(string instanceId) { BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.Create(); Console.WriteLine("Print list of instances in the project"); ListInstances(); Console.WriteLine("Deleting Instance"); // [START bigtable_delete_instance] // Deletes an instance from the project. // Initialize request argument(s). DeleteInstanceRequest request = new DeleteInstanceRequest { InstanceName = new InstanceName(projectId, instanceId) }; try { // Make request. Console.WriteLine("Waiting for operation to complete..."); bigtableInstanceAdminClient.DeleteInstance(request); // [END bigtable_delete_instance] Console.WriteLine($"Instance {instanceId} deleted successfuly"); Console.WriteLine("Print list of instances in the project after instance is deleted"); ListInstances(); // [START bigtable_delete_instance] } catch (Exception ex) { Console.WriteLine($"Exception while deleting {instanceId} instance"); Console.WriteLine(ex.Message); } // [END bigtable_delete_instance] return(0); }
/// <summary>Snippet for DeleteInstance</summary> public void DeleteInstance_RequestObject() { // Snippet: DeleteInstance(DeleteInstanceRequest,CallSettings) // Create client CloudRedisClient cloudRedisClient = CloudRedisClient.Create(); // Initialize request argument(s) DeleteInstanceRequest request = new DeleteInstanceRequest { InstanceName = new InstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"), }; // Make the request Operation <Empty, OperationMetadata> response = cloudRedisClient.DeleteInstance(request); // Poll until the returned long-running operation is complete Operation <Empty, OperationMetadata> 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, OperationMetadata> retrievedResponse = cloudRedisClient.PollOnceDeleteInstance(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 DeleteInstance</summary> public void DeleteInstanceRequestObject() { // Snippet: DeleteInstance(DeleteInstanceRequest, CallSettings) // Create client InstancesClient instancesClient = InstancesClient.Create(); // Initialize request argument(s) DeleteInstanceRequest request = new DeleteInstanceRequest { Name = "", }; // Make the request Operation <Empty, OperationMetadataV1> response = instancesClient.DeleteInstance(request); // Poll until the returned long-running operation is complete Operation <Empty, OperationMetadataV1> 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, OperationMetadataV1> retrievedResponse = instancesClient.PollOnceDeleteInstance(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 }
/// <summary>Snippet for DeleteInstanceAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task DeleteInstanceRequestObjectAsync() { // Create client InstancesClient instancesClient = await InstancesClient.CreateAsync(); // Initialize request argument(s) DeleteInstanceRequest request = new DeleteInstanceRequest { Name = "", }; // Make the request Operation <Empty, OperationMetadataV1> response = await instancesClient.DeleteInstanceAsync(request); // Poll until the returned long-running operation is complete Operation <Empty, OperationMetadataV1> 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, OperationMetadataV1> retrievedResponse = await instancesClient.PollOnceDeleteInstanceAsync(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; } }
/// <summary> /// 删除实例 /// </summary> public static void DeleteInstance(DdsClient client) { DeleteInstanceRequest req = new DeleteInstanceRequest { InstanceId = "95fafd4e2b864e48a5fa162b6bce4f75in02" }; try { DeleteInstanceResponse resp = client.DeleteInstance(req); Console.WriteLine(resp.JobId); Console.WriteLine("Delete Instance Success!"); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } }
/// <summary>Snippet for DeleteInstanceAsync</summary> public async Task DeleteInstanceRequestObjectAsync() { // Snippet: DeleteInstanceAsync(DeleteInstanceRequest, CallSettings) // Additional: DeleteInstanceAsync(DeleteInstanceRequest, CancellationToken) // Create client DataFusionClient dataFusionClient = await DataFusionClient.CreateAsync(); // Initialize request argument(s) DeleteInstanceRequest request = new DeleteInstanceRequest { InstanceName = InstanceName.FromProjectLocationInstance("[PROJECT]", "[LOCATION]", "[INSTANCE]"), }; // Make the request Operation <Empty, OperationMetadata> response = await dataFusionClient.DeleteInstanceAsync(request); // 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 dataFusionClient.PollOnceDeleteInstanceAsync(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 }
public void TestDeleteInstance() { var vmClient = GetVmClient(); DeleteInstanceRequest request = new DeleteInstanceRequest(); request.RegionId = "cn-north-1"; request.InstanceId = "i-zjjyo8hz89"; DeleteInstanceResponse response = vmClient.DeleteInstance(request); Console.WriteLine(JsonConvert.SerializeObject(response)); }
public void TestDeleteInstance() { MongodbClient mongodbClient = GetMongodbClient(); DeleteInstanceRequest request = new DeleteInstanceRequest(); request.RegionId = "cn-north-1"; request.InstanceId = "mongo-hfu1w2uhbc"; var response = mongodbClient.DeleteInstance(request).Result; _output.WriteLine(JsonConvert.SerializeObject(response)); }
/// <summary> /// 删除指定的实例 /// </summary> public async Task <DeleteInstanceResponse> DeleteInstanceAsync(DeleteInstanceRequest deleteInstanceRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("instance_id", deleteInstanceRequest.InstanceId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v2/{project_id}/instances/{instance_id}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", deleteInstanceRequest); HttpResponseMessage response = await DoHttpRequestAsync("DELETE", request); return(JsonUtils.DeSerializeNull <DeleteInstanceResponse>(response)); }
/// <summary> /// 删除数据库实例 /// </summary> public DeleteInstanceResponse DeleteInstance(DeleteInstanceRequest deleteInstanceRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("instance_id", deleteInstanceRequest.InstanceId.ToString()); string urlPath = HttpUtils.AddUrlPath("/v3/{project_id}/instances/{instance_id}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, deleteInstanceRequest); SdkResponse response = DoHttpRequest("DELETE", request); return(JsonUtils.DeSerialize <DeleteInstanceResponse>(response)); }
public void TestDeleteInstance() { var vmClient = GetVmClient(); DeleteInstanceRequest request = new DeleteInstanceRequest(); request.RegionId = "cn-north-1"; request.InstanceId = "i-ifz5os5gkj"; DeleteInstanceResponse response = vmClient.DeleteInstance(request).Result; _output.WriteLine(JsonConvert.SerializeObject(response)); }
/// <summary>Snippet for DeleteInstanceAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task DeleteInstanceRequestObjectAsync() { // Create client BigtableInstanceAdminClient bigtableInstanceAdminClient = await BigtableInstanceAdminClient.CreateAsync(); // Initialize request argument(s) DeleteInstanceRequest request = new DeleteInstanceRequest { InstanceName = InstanceName.FromProjectInstance("[PROJECT]", "[INSTANCE]"), }; // Make the request await bigtableInstanceAdminClient.DeleteInstanceAsync(request); }
/// <summary>Snippet for DeleteInstance</summary> public void DeleteInstance_RequestObject() { // Snippet: DeleteInstance(DeleteInstanceRequest,CallSettings) // Create client BigtableInstanceAdminClient bigtableInstanceAdminClient = BigtableInstanceAdminClient.Create(); // Initialize request argument(s) DeleteInstanceRequest request = new DeleteInstanceRequest { InstanceName = new InstanceName("[PROJECT]", "[INSTANCE]"), }; // Make the request bigtableInstanceAdminClient.DeleteInstance(request); // End snippet }
/// <summary> /// 销毁集群实例 /// </summary> /// <param name="req"><see cref="DeleteInstanceRequest"/></param> /// <returns><see cref="DeleteInstanceResponse"/></returns> public DeleteInstanceResponse DeleteInstanceSync(DeleteInstanceRequest req) { JsonResponseModel <DeleteInstanceResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "DeleteInstance"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <DeleteInstanceResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
public async Task DeleteInstanceAsync_RequestObject() { // Snippet: DeleteInstanceAsync(DeleteInstanceRequest,CallSettings) // Create client InstanceAdminClient instanceAdminClient = await InstanceAdminClient.CreateAsync(); // Initialize request argument(s) DeleteInstanceRequest request = new DeleteInstanceRequest { InstanceName = new InstanceName("[PROJECT]", "[INSTANCE]"), }; // Make the request await instanceAdminClient.DeleteInstanceAsync(request); // End snippet }
public async Task DeleteInstanceAsync2() { Mock <InstanceAdmin.InstanceAdminClient> mockGrpcClient = new Mock <InstanceAdmin.InstanceAdminClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); DeleteInstanceRequest request = new DeleteInstanceRequest { InstanceName = new InstanceName("[PROJECT]", "[INSTANCE]"), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteInstanceAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null)); InstanceAdminClient client = new InstanceAdminClientImpl(mockGrpcClient.Object, null); await client.DeleteInstanceAsync(request); mockGrpcClient.VerifyAll(); }
public void DeleteInstance2() { Mock <InstanceAdmin.InstanceAdminClient> mockGrpcClient = new Mock <InstanceAdmin.InstanceAdminClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); DeleteInstanceRequest request = new DeleteInstanceRequest { InstanceName = new InstanceName("[PROJECT]", "[INSTANCE]"), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteInstance(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); InstanceAdminClient client = new InstanceAdminClientImpl(mockGrpcClient.Object, null); client.DeleteInstance(request); mockGrpcClient.VerifyAll(); }
private void btn1_Click(object sender, EventArgs e) { btn1.Enabled = false; btn2.Enabled = false; BackgroundWork(() => { if (string.IsNullOrEmpty(instanceId)) { var request = new RunInstancesRequest { RegionId = regionId, LaunchTemplateName = launchTemplateName, InstanceChargeType = "PostPaid" }; var response = client.GetAcsResponse(request); if (!response.InstanceIdSets.Any()) { throw new Exception("创建失败!"); } StartTimer(); } else { var request = new DeleteInstanceRequest { RegionId = regionId, InstanceId = instanceId, Force = true }; client.GetAcsResponse(request); instanceId = null; CheckInstances(); } }); }
/// <summary> /// Stops a running instance. /// /// The instance might be automatically recreated based on the scaling settings /// of the version. For more information, see "How Instances are Managed" /// ([standard environment](https://cloud.google.com/appengine/docs/standard/python/how-instances-are-managed) | /// [flexible environment](https://cloud.google.com/appengine/docs/flexible/python/how-instances-are-managed)). /// /// To ensure that instances are not re-created and avoid getting billed, you /// can stop all instances within the target version by changing the serving /// status of the version to `STOPPED` with the /// [`apps.services.versions.patch`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch) /// method. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>A Task containing the RPC response.</returns> public virtual stt::Task <lro::Operation <wkt::Empty, OperationMetadataV1> > DeleteInstanceAsync(DeleteInstanceRequest request, gaxgrpc::CallSettings callSettings = null) => throw new sys::NotImplementedException();
/// <summary> /// Stops a running instance. /// /// The instance might be automatically recreated based on the scaling settings /// of the version. For more information, see "How Instances are Managed" /// ([standard environment](https://cloud.google.com/appengine/docs/standard/python/how-instances-are-managed) | /// [flexible environment](https://cloud.google.com/appengine/docs/flexible/python/how-instances-are-managed)). /// /// To ensure that instances are not re-created and avoid getting billed, you /// can stop all instances within the target version by changing the serving /// status of the version to `STOPPED` with the /// [`apps.services.versions.patch`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch) /// method. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param> /// <returns>A Task containing the RPC response.</returns> public virtual stt::Task <lro::Operation <wkt::Empty, OperationMetadataV1> > DeleteInstanceAsync(DeleteInstanceRequest request, st::CancellationToken cancellationToken) => DeleteInstanceAsync(request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
partial void Modify_DeleteInstanceRequest(ref DeleteInstanceRequest request, ref gaxgrpc::CallSettings settings);
/// <summary> /// 删除实例 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public async Task <DeleteInstanceResponse> DeleteInstance(DeleteInstanceRequest request) { return(await new DeleteInstanceExecutor().Client(this).Execute <DeleteInstanceResponse, DeleteInstanceResult, DeleteInstanceRequest>(request).ConfigureAwait(false)); }
/// <summary> /// 删除实例 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public DeleteInstanceResponse DeleteInstance(DeleteInstanceRequest request) { return(new DeleteInstanceExecutor().Client(this).Execute <DeleteInstanceResponse, DeleteInstanceResult, DeleteInstanceRequest>(request)); }
/// <summary> /// Stops a running instance. /// /// The instance might be automatically recreated based on the scaling settings /// of the version. For more information, see "How Instances are Managed" /// ([standard environment](https://cloud.google.com/appengine/docs/standard/python/how-instances-are-managed) | /// [flexible environment](https://cloud.google.com/appengine/docs/flexible/python/how-instances-are-managed)). /// /// To ensure that instances are not re-created and avoid getting billed, you /// can stop all instances within the target version by changing the serving /// status of the version to `STOPPED` with the /// [`apps.services.versions.patch`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch) /// method. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>The RPC response.</returns> public override lro::Operation <wkt::Empty, OperationMetadataV1> DeleteInstance(DeleteInstanceRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_DeleteInstanceRequest(ref request, ref callSettings); return(new lro::Operation <wkt::Empty, OperationMetadataV1>(_callDeleteInstance.Sync(request, callSettings), DeleteInstanceOperationsClient)); }
/// <summary> /// Stops a running instance. /// /// The instance might be automatically recreated based on the scaling settings /// of the version. For more information, see "How Instances are Managed" /// ([standard environment](https://cloud.google.com/appengine/docs/standard/python/how-instances-are-managed) | /// [flexible environment](https://cloud.google.com/appengine/docs/flexible/python/how-instances-are-managed)). /// /// To ensure that instances are not re-created and avoid getting billed, you /// can stop all instances within the target version by changing the serving /// status of the version to `STOPPED` with the /// [`apps.services.versions.patch`](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch) /// method. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>A Task containing the RPC response.</returns> public override async stt::Task <lro::Operation <wkt::Empty, OperationMetadataV1> > DeleteInstanceAsync(DeleteInstanceRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_DeleteInstanceRequest(ref request, ref callSettings); return(new lro::Operation <wkt::Empty, OperationMetadataV1>(await _callDeleteInstance.Async(request, callSettings).ConfigureAwait(false), DeleteInstanceOperationsClient)); }