Locations

Cloud Natural Language API offers you some control over where the resources for your project are stored and processed. In particular, you can configure Cloud Natural Language API to store your data at rest and perform machine learning processing on your data only in the European Union or the United States.

By default Cloud Natural Language API stores and processes resources in a Global location, which means that Cloud Natural Language API doesn't guarantee that your resources will remain within a particular location or region. If you choose the European Union location, Google will store your data and perform machine learning with it only in the European Union. If you choose the United States location, Google will store your data and perform machine learning with it only in the United States. You and your users can access the data from any location.

Setting the location using the API

Cloud Natural Language API supports a global API endpoint (language.googleapis.com), a European Union endpoint (eu-language.googleapis.com), and a United States endpoint (us-language.googleapis.com). To store and process your data in the European Union only, use the URI eu-language.googleapis.com in place of language.googleapis.com for your REST API calls. To store and process your data in the United States only, use the URI us-language.googleapis.com in place of language.googleapis.com for your REST API calls.

Setting the location using client libraries

The client libraries access the global API endpoint (language.googleapis.com) by default. To store and process your data in the European Union or United States only, you need to explicitly set the endpoint. The code samples below show how to configure this setting.

Python

# Imports the Google Cloud client library
from google.cloud import language

client_options = {'api_endpoint': 'eu-language.googleapis.com:443'}

# Instantiates a client
client = language.LanguageServiceClient(client_options=client_options)

Java

LanguageServiceSettings settings = LanguageServiceSettings.newBuilder()
        .setEndpoint("eu-language.googleapis.com:443")
        .build();

// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
// the "close" method on the client to safely clean up any remaining background resources.
LanguageServiceClient client = LanguageServiceClient.create(settings);

Node.js

// Imports the Google Cloud client library
const language = require('@google-cloud/language');

// Specifies the location of the api endpoint
const clientOptions = {apiEndpoint: 'eu-language.googleapis.com'};

// Instantiates a client
const client = new language.LanguageServiceClient(clientOptions);

Var denne siden nyttig? Si fra hva du synes:

Send tilbakemelding om ...

Cloud Natural Language API
Trenger du hjelp? Gå til brukerstøttesiden vår.