Eliminazione di un endpoint
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Elimina un endpoint utilizzando il metodo delete_endpoint.
Esempio di codice
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],[],[],[],null,["# Delete an endpoint\n\nDeletes an endpoint using the delete_endpoint method.\n\nCode sample\n-----------\n\n### Java\n\n\nBefore trying this sample, follow the Java setup instructions in the\n[Vertex AI quickstart using\nclient libraries](/vertex-ai/docs/start/client-libraries).\n\n\nFor more information, see the\n[Vertex AI Java API\nreference documentation](/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1).\n\n\nTo authenticate to Vertex AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n import com.google.api.gax.longrunning.https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.longrunning.OperationFuture.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.DeleteOperationMetadata.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointName.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointServiceClient.html;\n import com.google.cloud.aiplatform.v1.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointServiceSettings.html;\n import com.google.protobuf.https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html;\n import java.io.IOException;\n import java.util.concurrent.ExecutionException;\n import java.util.concurrent.TimeUnit;\n import java.util.concurrent.TimeoutException;\n\n public class DeleteEndpointSample {\n\n public static void main(String[] args)\n throws IOException, InterruptedException, ExecutionException, TimeoutException {\n // TODO(developer): Replace these variables before running the sample.\n String project = \"YOUR_PROJECT_ID\";\n String endpointId = \"YOUR_ENDPOINT_ID\";\n deleteEndpointSample(project, endpointId);\n }\n\n static void deleteEndpointSample(String project, String endpointId)\n throws IOException, InterruptedException, ExecutionException, TimeoutException {\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointServiceSettings.html endpointServiceSettings =\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointServiceSettings.html.newBuilder()\n .setEndpoint(\"us-central1-aiplatform.googleapis.com:443\")\n .build();\n\n // Initialize client that will be used to send requests. This client only needs to be created\n // once, and can be reused for multiple requests. After completing all of your requests, call\n // the \"close\" method on the client to safely clean up any remaining background resources.\n try (https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointServiceClient.html endpointServiceClient =\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointServiceClient.html.create(endpointServiceSettings)) {\n String location = \"us-central1\";\n https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointName.html endpointName = https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointName.html.of(project, location, endpointId);\n\n // NOTE: Be sure to undeploy any models deployed to the endpoint\n // before attempting to delete the endpoint.\n OperationFuture\u003cEmpty, DeleteOperationMetadata\u003e operationFuture =\n endpointServiceClient.https://cloud.google.com/java/docs/reference/google-cloud-aiplatform/latest/com.google.cloud.aiplatform.v1.EndpointServiceClient.html#com_google_cloud_aiplatform_v1_EndpointServiceClient_deleteEndpointAsync_com_google_cloud_aiplatform_v1_DeleteEndpointRequest_(endpointName);\n System.out.format(\"Operation name: %s\\n\", operationFuture.getInitialFuture().get().getName());\n System.out.println(\"Waiting for operation to finish...\");\n https://cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.Empty.html deleteResponse = operationFuture.get(300, TimeUnit.SECONDS);\n\n System.out.format(\"Delete Endpoint Response: %s\\n\", deleteResponse);\n }\n }\n }\n\n### Node.js\n\n\nBefore trying this sample, follow the Node.js setup instructions in the\n[Vertex AI quickstart using\nclient libraries](/vertex-ai/docs/start/client-libraries).\n\n\nFor more information, see the\n[Vertex AI Node.js API\nreference documentation](/nodejs/docs/reference/aiplatform/latest).\n\n\nTo authenticate to Vertex AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n /**\n * TODO(developer): Uncomment these variables before running the sample.\\\n * (Not necessary if passing values as arguments)\n */\n\n // const endpointId = 'YOUR_ENDPOINT_ID';\n // const project = 'YOUR_PROJECT_ID';\n // const location = 'YOUR_PROJECT_LOCATION';\n\n // Imports the Google Cloud Endpoint Service Client library\n const {EndpointServiceClient} = require('https://cloud.google.com/nodejs/docs/reference/aiplatform/latest/overview.html');\n\n // Specifies the location of the api endpoint\n const clientOptions = {\n apiEndpoint: 'us-central1-aiplatform.googleapis.com',\n };\n\n // Instantiates a client\n const endpointServiceClient = new https://cloud.google.com/nodejs/docs/reference/aiplatform/latest/overview.html(clientOptions);\n\n async function deleteEndpoint() {\n // Configure the parent resource\n const endpoint = {\n name: `projects/${project}/locations/${location}/endpoints/${endpointId}`,\n };\n\n // NOTE: Be sure to undeploy any models deployed to the endpoint before\n // attempting to delete the endpoint.\n\n // Delete endpoint request\n const [response] = await endpointServiceClient.deleteEndpoint(endpoint);\n console.log(`Long running operation : ${response.name}`);\n\n // Wait for operation to complete\n await response.promise();\n const result = response.result;\n\n console.log('Delete endpoint response:\\n', result);\n }\n deleteEndpoint();\n\n### Python\n\n\nBefore trying this sample, follow the Python setup instructions in the\n[Vertex AI quickstart using\nclient libraries](/vertex-ai/docs/start/client-libraries).\n\n\nFor more information, see the\n[Vertex AI Python API\nreference documentation](/python/docs/reference/aiplatform/latest).\n\n\nTo authenticate to Vertex AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n from google.cloud import aiplatform\n\n\n def delete_endpoint_sample(\n project: str,\n endpoint_id: str,\n location: str = \"us-central1\",\n api_endpoint: str = \"us-central1-aiplatform.googleapis.com\",\n timeout: int = 300,\n ):\n # The AI Platform services require regional API endpoints.\n client_options = {\"api_endpoint\": api_endpoint}\n # Initialize client that will be used to create and send requests.\n # This client only needs to be created once, and can be reused for multiple requests.\n client = aiplatform.gapic.https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1.services.endpoint_service.EndpointServiceClient.html(client_options=client_options)\n name = client.https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1.services.endpoint_service.EndpointServiceClient.html#google_cloud_aiplatform_v1_services_endpoint_service_EndpointServiceClient_endpoint_path(\n project=project, location=location, endpoint=endpoint_id\n )\n response = client.https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform_v1.services.endpoint_service.EndpointServiceClient.html#google_cloud_aiplatform_v1_services_endpoint_service_EndpointServiceClient_delete_endpoint(name=name)\n print(\"Long running operation:\", response.operation.name)\n delete_endpoint_response = response.result(timeout=timeout)\n print(\"delete_endpoint_response:\", delete_endpoint_response)\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=aiplatform)."]]