|
| 1 | +# Copyright 2019 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +def set_endpoint(project_id): |
| 17 | + """Change your endpoint""" |
| 18 | + # [START automl_set_endpoint] |
| 19 | + from google.cloud import automl_v1beta1 as automl |
| 20 | + |
| 21 | + # You must first create a dataset, using the `eu` endpoint, before you can |
| 22 | + # call other operations such as: list, get, import, delete, etc. |
| 23 | + client_options = {'api_endpoint': 'eu-automl.googleapis.com:443'} |
| 24 | + |
| 25 | + # Instantiates a client |
| 26 | + client = automl.AutoMlClient(client_options=client_options) |
| 27 | + |
| 28 | + # A resource that represents Google Cloud Platform location. |
| 29 | + # project_id = 'YOUR_PROJECT_ID' |
| 30 | + project_location = client.location_path(project_id, 'eu') |
| 31 | + # [END automl_set_endpoint] |
| 32 | + |
| 33 | + # List all the datasets available |
| 34 | + # Note: Create a dataset in `eu`, before calling `list_datasets`. |
| 35 | + response = client.list_datasets( |
| 36 | + project_location, filter_='') |
| 37 | + |
| 38 | + for dataset in response: |
| 39 | + print(dataset) |
0 commit comments