|
16 | 16 |
|
17 | 17 | import six |
18 | 18 |
|
| 19 | +import google.api_core.client_options |
19 | 20 | from google.api_core import page_iterator |
20 | 21 | from google.cloud.client import Client as BaseClient |
21 | 22 |
|
@@ -56,14 +57,31 @@ class Client(BaseClient): |
56 | 57 | requests. If ``None``, then default info will be used. Generally, |
57 | 58 | you only need to set this if you're developing your own library |
58 | 59 | or partner tool. |
| 60 | + :type client_options: :class:`~google.api_core.client_options.ClientOptions` |
| 61 | + or :class:`dict` |
| 62 | + :param client_options: (Optional) Client options used to set user options |
| 63 | + on the client. API Endpoint should be set through client_options. |
59 | 64 | """ |
60 | 65 |
|
61 | 66 | SCOPE = ("https://www.googleapis.com/auth/cloud-platform",) |
62 | 67 | """The scopes required for authenticating as a Resouce Manager consumer.""" |
63 | 68 |
|
64 | | - def __init__(self, credentials=None, _http=None, client_info=None): |
| 69 | + def __init__( |
| 70 | + self, credentials=None, _http=None, client_info=None, client_options=None |
| 71 | + ): |
65 | 72 | super(Client, self).__init__(credentials=credentials, _http=_http) |
66 | | - self._connection = Connection(self, client_info=client_info) |
| 73 | + |
| 74 | + kw_args = {"client_info": client_info} |
| 75 | + if client_options: |
| 76 | + if type(client_options) == dict: |
| 77 | + client_options = google.api_core.client_options.from_dict( |
| 78 | + client_options |
| 79 | + ) |
| 80 | + if client_options.api_endpoint: |
| 81 | + api_endpoint = client_options.api_endpoint |
| 82 | + kw_args["api_endpoint"] = api_endpoint |
| 83 | + |
| 84 | + self._connection = Connection(self, **kw_args) |
67 | 85 |
|
68 | 86 | def new_project(self, project_id, name=None, labels=None): |
69 | 87 | """Create a project bound to the current client. |
|
0 commit comments