File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed
Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ # Copyright 2020 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 create_client_with_endpoint (gcp_project_id ):
17+ """Create a Tables client with a non-default endpoint."""
18+ # [START automl_set_endpoint]
19+ from google .cloud import automl_v1beta1 as automl
20+ from google .api_core .client_options import ClientOptions
21+
22+ # Set the endpoint you want to use via the ClientOptions.
23+ # gcp_project_id = 'YOUR_PROJECT_ID'
24+ client_options = ClientOptions (api_endpoint = "eu-automl.googleapis.com:443" )
25+ client = automl .TablesClient (
26+ project = gcp_project_id , region = "eu" , client_options = client_options
27+ )
28+ # [END automl_set_endpoint]
29+
30+ return client
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ # Copyright 2020 Google LLC
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+ import os
17+
18+ from google .api_core import exceptions
19+ import pytest
20+
21+ import automl_tables_set_endpoint
22+ from google .cloud import automl_v1beta1 as automl
23+ from google .api_core .client_options import ClientOptions
24+
25+ PROJECT = os .environ ["GCLOUD_PROJECT" ]
26+
27+
28+ def test_client_creation (capsys ):
29+ client = automl_tables_set_endpoint .create_client_with_endpoint (PROJECT )
30+ print (client .list_datasets ())
31+ out , _ = capsys .readouterr ()
32+ assert "GRPCIterator" in out
You can’t perform that action at this time.
0 commit comments