From eccf661eaaa7d45fe0e3482f6fc15aee0acc5b7a Mon Sep 17 00:00:00 2001 From: "Vi Eng (CI)" Date: Wed, 13 Sep 2023 19:28:09 +0000 Subject: [PATCH] [skip ci] updated docs --- gcloud.html | 213 +---- gcloud/aio.html | 252 ------ gcloud/aio/auth.html | 1754 ----------------------------------------- gcloud/rest.html | 252 ------ gcloud/rest/auth.html | 1751 ---------------------------------------- search.js | 2 +- 6 files changed, 6 insertions(+), 4218 deletions(-) delete mode 100644 gcloud/aio.html delete mode 100644 gcloud/aio/auth.html delete mode 100644 gcloud/rest.html delete mode 100644 gcloud/rest/auth.html diff --git a/gcloud.html b/gcloud.html index f289291c8..1b82442fa 100644 --- a/gcloud.html +++ b/gcloud.html @@ -18,15 +18,8 @@
- -

Submodules

- @@ -42,207 +35,11 @@

Submodules

gcloud

-

-
- - - - - -
1"""
-2.. include:: ../../docs/gcloud.md
-3"""
-4try:
-5    import pkg_resources
-6    pkg_resources.declare_namespace(__name__)
-7except ImportError:
-8    import pkgutil
-9    __path__ = pkgutil.extend_path(__path__, __name__)
-
- - + + + + - + \ No newline at end of file diff --git a/gcloud/aio.html b/gcloud/aio.html deleted file mode 100644 index 1ec44d35e..000000000 --- a/gcloud/aio.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - gcloud.aio API documentation - - - - - - - - - -
-
-

-gcloud.aio

- -

-
- - - - - -
1"""
-2.. include:: ../../../docs/aio.md
-3"""
-4try:
-5    import pkg_resources
-6    pkg_resources.declare_namespace(__name__)
-7except ImportError:
-8    import pkgutil
-9    __path__ = pkgutil.extend_path(__path__, __name__)
-
- - -
-
- - \ No newline at end of file diff --git a/gcloud/aio/auth.html b/gcloud/aio/auth.html deleted file mode 100644 index 89375f4c9..000000000 --- a/gcloud/aio/auth.html +++ /dev/null @@ -1,1754 +0,0 @@ - - - - - - - gcloud.aio.auth API documentation - - - - - - - - - -
-
-

-gcloud.aio.auth

- -

This library implements various methods for working with the Google IAM / auth -APIs. This includes authenticating for the purpose of using other Google APIs, -managing service accounts and public keys, URL-signing blobs, etc.

- -

Installation

- -
-
$ pip install --upgrade gcloud-aio-auth
-
-
- -

Usage

- -
-
from gcloud.aio.auth import IamClient
-from gcloud.aio.auth import Token
-
-
-client = IamClient()
-pubkeys = await client.list_public_keys()
-
-token = Token()
-print(await token.get())
-
-
- -

Additionally, the Token constructor accepts the following optional arguments:

- -
    -
  • service_file: path to a service account authorized user -file, or any other application credentials. Alternatively, you can pass a -file-like object, like an io.StringIO instance, in case your credentials -are not stored in a file but in memory. If omitted, will attempt to find one -on your path or fallback to generating a token from GCE metadata.
  • -
  • session: an aiohttp.ClientSession instance to be used for all requests. -If omitted, a default session will be created. If you use the default -session, you may be interested in using Token() as a context manager -(async with Token(..) as token:) or explicitly calling the Token.close() -method to ensure the session is cleaned up appropriately.
  • -
  • scopes: an optional list of GCP scopes_ for which to generate our token. -Only valid (and required!) for service account -authentication.
  • -
-
- - - - - -
 1"""
- 2This library implements various methods for working with the Google IAM / auth
- 3APIs. This includes authenticating for the purpose of using other Google APIs,
- 4managing service accounts and public keys, URL-signing blobs, etc.
- 5
- 6## Installation
- 7
- 8```console
- 9$ pip install --upgrade gcloud-aio-auth
-10```
-11
-12## Usage
-13
-14```python
-15from gcloud.aio.auth import IamClient
-16from gcloud.aio.auth import Token
-17
-18
-19client = IamClient()
-20pubkeys = await client.list_public_keys()
-21
-22token = Token()
-23print(await token.get())
-24```
-25
-26Additionally, the `Token` constructor accepts the following optional arguments:
-27
-28* `service_file`: path to a [service account][service-account] authorized user
-29  file, or any other application credentials. Alternatively, you can pass a
-30  file-like object, like an `io.StringIO` instance, in case your credentials
-31  are not stored in a file but in memory. If omitted, will attempt to find one
-32  on your path or fallback to generating a token from GCE metadata.
-33* `session`: an `aiohttp.ClientSession` instance to be used for all requests.
-34  If omitted, a default session will be created. If you use the default
-35  session, you may be interested in using `Token()` as a context manager
-36  (`async with Token(..) as token:`) or explicitly calling the `Token.close()`
-37  method to ensure the session is cleaned up appropriately.
-38* `scopes`: an optional list of GCP `scopes`_ for which to generate our token.
-39  Only valid (and required!) for [service account][service-account]
-40  authentication.
-41
-42[service-account]: https://console.cloud.google.com/iam-admin/serviceaccounts
-43"""
-44from pkg_resources import get_distribution
-45
-46__version__ = get_distribution('gcloud-aio-auth').version
-47
-48from gcloud.aio.auth.build_constants import BUILD_GCLOUD_REST
-49from gcloud.aio.auth.iam import IamClient
-50from gcloud.aio.auth.session import AioSession
-51from gcloud.aio.auth.token import Token
-52from gcloud.aio.auth.utils import decode, encode
-53
-54__all__ = [
-55    'AioSession',
-56    'BUILD_GCLOUD_REST',
-57    'IamClient',
-58    'Token',
-59    '__version__',
-60    'decode',
-61    'encode',
-62]
-
- - -
-
- -
- - class - AioSession(gcloud.aio.auth.session.BaseSession): - - - -
- -
131    class AioSession(BaseSession):
-132        _session: aiohttp.ClientSession  # type: ignore[assignment]
-133        _timeout: Timeout  # type: ignore[assignment]
-134
-135        @property
-136        def session(self) -> aiohttp.ClientSession:  # type: ignore[override]
-137            if not self._session:
-138                connector = aiohttp.TCPConnector(ssl=self._ssl)
-139
-140                if isinstance(self._timeout, aiohttp.ClientTimeout):
-141                    timeout = self._timeout
-142                else:
-143                    timeout = aiohttp.ClientTimeout(total=self._timeout)
-144
-145                self._session = aiohttp.ClientSession(
-146                    connector=connector,
-147                    timeout=timeout,
-148                )
-149            return self._session
-150
-151        async def post(  # type: ignore[override]
-152            self, url: str,
-153            headers: Mapping[str, str],
-154            data: Optional[Union[bytes, str, IO[AnyStr]]] = None,
-155            timeout: Timeout = 10,
-156            params: Optional[Mapping[str, Union[int, str]]] = None,
-157        ) -> aiohttp.ClientResponse:
-158            resp = await self.session.post(
-159                url, data=data, headers=headers,
-160                timeout=timeout, params=params,
-161            )
-162            await _raise_for_status(resp)
-163            return resp
-164
-165        async def get(  # type: ignore[override]
-166            self, url: str,
-167            headers: Optional[Mapping[str, str]] = None,
-168            timeout: Timeout = 10,
-169            params: Optional[Mapping[str, Union[int, str]]] = None,
-170            stream: Optional[bool] = None,
-171        ) -> aiohttp.ClientResponse:
-172            if stream is not None:
-173                log.warning(
-174                    'passed unused argument stream=%s to AioSession: '
-175                    'this argument is only used by SyncSession',
-176                    stream,
-177                )
-178            resp = await self.session.get(
-179                url, headers=headers,
-180                timeout=timeout, params=params,
-181            )
-182            await _raise_for_status(resp)
-183            return resp
-184
-185        async def patch(  # type: ignore[override]
-186            self, url: str, headers: Mapping[str, str],
-187            data: Optional[Union[bytes, str]] = None,
-188            timeout: Timeout = 10,
-189            params: Optional[Mapping[str, Union[int, str]]] = None,
-190        ) -> aiohttp.ClientResponse:
-191            resp = await self.session.patch(
-192                url, data=data, headers=headers,
-193                timeout=timeout, params=params,
-194            )
-195            await _raise_for_status(resp)
-196            return resp
-197
-198        async def put(  # type: ignore[override]
-199            self, url: str,
-200            headers: Mapping[str, str], data: Union[bytes, str, IO[Any]],
-201            timeout: Timeout = 10,
-202        ) -> aiohttp.ClientResponse:
-203            resp = await self.session.put(
-204                url, data=data, headers=headers,
-205                timeout=timeout,
-206            )
-207            await _raise_for_status(resp)
-208            return resp
-209
-210        async def delete(  # type: ignore[override]
-211            self, url: str,
-212            headers: Mapping[str, str],
-213            params: Optional[Mapping[str, Union[int, str]]] = None,
-214            timeout: Timeout = 10,
-215        ) -> aiohttp.ClientResponse:
-216            resp = await self.session.delete(
-217                url, headers=headers,
-218                params=params, timeout=timeout,
-219            )
-220            await _raise_for_status(resp)
-221            return resp
-222
-223        async def request(  # type: ignore[override]
-224            self, method: str,
-225            url: str, headers: Mapping[str, str],
-226            auto_raise_for_status: bool = True,
-227            **kwargs: Any,
-228        ) -> aiohttp.ClientResponse:
-229            resp = await self.session.request(
-230                method, url, headers=headers, **kwargs,
-231            )
-232            if auto_raise_for_status:
-233                await _raise_for_status(resp)
-234            return resp
-235
-236        async def close(self) -> None:
-237            if not self._shared_session and self._session:
-238                await self._session.close()
-
- - - - -
-
- session: aiohttp.client.ClientSession - - -
- - - - -
-
- -
- - async def - post( self, url: str, headers: Mapping[str, str], data: Union[bytes, str, IO[~AnyStr], NoneType] = None, timeout: Union[aiohttp.client.ClientTimeout, float] = 10, params: Optional[Mapping[str, Union[int, str]]] = None) -> aiohttp.client_reqrep.ClientResponse: - - - -
- -
151        async def post(  # type: ignore[override]
-152            self, url: str,
-153            headers: Mapping[str, str],
-154            data: Optional[Union[bytes, str, IO[AnyStr]]] = None,
-155            timeout: Timeout = 10,
-156            params: Optional[Mapping[str, Union[int, str]]] = None,
-157        ) -> aiohttp.ClientResponse:
-158            resp = await self.session.post(
-159                url, data=data, headers=headers,
-160                timeout=timeout, params=params,
-161            )
-162            await _raise_for_status(resp)
-163            return resp
-
- - - - -
-
- -
- - async def - get( self, url: str, headers: Optional[Mapping[str, str]] = None, timeout: Union[aiohttp.client.ClientTimeout, float] = 10, params: Optional[Mapping[str, Union[int, str]]] = None, stream: Optional[bool] = None) -> aiohttp.client_reqrep.ClientResponse: - - - -
- -
165        async def get(  # type: ignore[override]
-166            self, url: str,
-167            headers: Optional[Mapping[str, str]] = None,
-168            timeout: Timeout = 10,
-169            params: Optional[Mapping[str, Union[int, str]]] = None,
-170            stream: Optional[bool] = None,
-171        ) -> aiohttp.ClientResponse:
-172            if stream is not None:
-173                log.warning(
-174                    'passed unused argument stream=%s to AioSession: '
-175                    'this argument is only used by SyncSession',
-176                    stream,
-177                )
-178            resp = await self.session.get(
-179                url, headers=headers,
-180                timeout=timeout, params=params,
-181            )
-182            await _raise_for_status(resp)
-183            return resp
-
- - - - -
-
- -
- - async def - patch( self, url: str, headers: Mapping[str, str], data: Union[bytes, str, NoneType] = None, timeout: Union[aiohttp.client.ClientTimeout, float] = 10, params: Optional[Mapping[str, Union[int, str]]] = None) -> aiohttp.client_reqrep.ClientResponse: - - - -
- -
185        async def patch(  # type: ignore[override]
-186            self, url: str, headers: Mapping[str, str],
-187            data: Optional[Union[bytes, str]] = None,
-188            timeout: Timeout = 10,
-189            params: Optional[Mapping[str, Union[int, str]]] = None,
-190        ) -> aiohttp.ClientResponse:
-191            resp = await self.session.patch(
-192                url, data=data, headers=headers,
-193                timeout=timeout, params=params,
-194            )
-195            await _raise_for_status(resp)
-196            return resp
-
- - - - -
-
- -
- - async def - put( self, url: str, headers: Mapping[str, str], data: Union[bytes, str, IO[Any]], timeout: Union[aiohttp.client.ClientTimeout, float] = 10) -> aiohttp.client_reqrep.ClientResponse: - - - -
- -
198        async def put(  # type: ignore[override]
-199            self, url: str,
-200            headers: Mapping[str, str], data: Union[bytes, str, IO[Any]],
-201            timeout: Timeout = 10,
-202        ) -> aiohttp.ClientResponse:
-203            resp = await self.session.put(
-204                url, data=data, headers=headers,
-205                timeout=timeout,
-206            )
-207            await _raise_for_status(resp)
-208            return resp
-
- - - - -
-
- -
- - async def - delete( self, url: str, headers: Mapping[str, str], params: Optional[Mapping[str, Union[int, str]]] = None, timeout: Union[aiohttp.client.ClientTimeout, float] = 10) -> aiohttp.client_reqrep.ClientResponse: - - - -
- -
210        async def delete(  # type: ignore[override]
-211            self, url: str,
-212            headers: Mapping[str, str],
-213            params: Optional[Mapping[str, Union[int, str]]] = None,
-214            timeout: Timeout = 10,
-215        ) -> aiohttp.ClientResponse:
-216            resp = await self.session.delete(
-217                url, headers=headers,
-218                params=params, timeout=timeout,
-219            )
-220            await _raise_for_status(resp)
-221            return resp
-
- - - - -
-
- -
- - async def - request( self, method: str, url: str, headers: Mapping[str, str], auto_raise_for_status: bool = True, **kwargs: Any) -> aiohttp.client_reqrep.ClientResponse: - - - -
- -
223        async def request(  # type: ignore[override]
-224            self, method: str,
-225            url: str, headers: Mapping[str, str],
-226            auto_raise_for_status: bool = True,
-227            **kwargs: Any,
-228        ) -> aiohttp.ClientResponse:
-229            resp = await self.session.request(
-230                method, url, headers=headers, **kwargs,
-231            )
-232            if auto_raise_for_status:
-233                await _raise_for_status(resp)
-234            return resp
-
- - - - -
-
- -
- - async def - close(self) -> None: - - - -
- -
236        async def close(self) -> None:
-237            if not self._shared_session and self._session:
-238                await self._session.close()
-
- - - - -
-
-
Inherited Members
-
-
gcloud.aio.auth.session.BaseSession
-
BaseSession
- -
-
-
-
-
-
- BUILD_GCLOUD_REST = -False - - -
- - - - -
-
- -
- - class - IamClient: - - - -
- -
 28class IamClient:
- 29    def __init__(
- 30        self, service_file: Optional[Union[str, IO[AnyStr]]] = None,
- 31        session: Optional[Session] = None,
- 32        token: Optional[Token] = None,
- 33    ) -> None:
- 34        self.session = AioSession(session)
- 35        self.token = token or Token(
- 36            service_file=service_file, scopes=SCOPES,
- 37            session=self.session.session,  # type: ignore[arg-type]
- 38        )
- 39
- 40        if self.token.token_type not in {
- 41            Type.GCE_METADATA,
- 42            Type.SERVICE_ACCOUNT,
- 43        }:
- 44            raise TypeError(
- 45                'IAM Credentials Client is only valid for use '
- 46                'with Service Accounts or GCE Metadata',
- 47            )
- 48
- 49    async def headers(self) -> Dict[str, str]:
- 50        token = await self.token.get()
- 51        return {
- 52            'Authorization': f'Bearer {token}',
- 53        }
- 54
- 55    @property
- 56    def service_account_email(self) -> Optional[str]:
- 57        return self.token.service_data.get('client_email')
- 58
- 59    # https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts.keys/get
- 60    async def get_public_key(
- 61        self, key_id: Optional[str] = None,
- 62        key: Optional[str] = None,
- 63        service_account_email: Optional[str] = None,
- 64        project: Optional[str] = None,
- 65        session: Optional[Session] = None,
- 66        timeout: int = 10,
- 67    ) -> Dict[str, str]:
- 68        service_account_email = (
- 69            service_account_email
- 70            or self.service_account_email
- 71        )
- 72        project = project or await self.token.get_project()
- 73
- 74        if not key_id and not key:
- 75            raise ValueError('get_public_key must have either key_id or key')
- 76
- 77        if not key:
- 78            key = (
- 79                f'projects/{project}/serviceAccounts/'
- 80                f'{service_account_email}/keys/{key_id}'
- 81            )
- 82
- 83        url = f'{API_ROOT_IAM}/{key}?publicKeyType=TYPE_X509_PEM_FILE'
- 84        headers = await self.headers()
- 85
- 86        s = AioSession(session) if session else self.session
- 87
- 88        resp = await s.get(url=url, headers=headers, timeout=timeout)
- 89
- 90        data: Dict[str, str] = await resp.json()
- 91        return data
- 92
- 93    # https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts.keys/list
- 94    async def list_public_keys(
- 95            self, service_account_email: Optional[str] = None,
- 96            project: Optional[str] = None,
- 97            session: Optional[Session] = None,
- 98            timeout: int = 10,
- 99    ) -> List[Dict[str, str]]:
-100        service_account_email = (
-101            service_account_email
-102            or self.service_account_email
-103        )
-104        project = project or await self.token.get_project()
-105
-106        url = (
-107            f'{API_ROOT_IAM}/projects/{project}/'
-108            f'serviceAccounts/{service_account_email}/keys'
-109        )
-110
-111        headers = await self.headers()
-112
-113        s = AioSession(session) if session else self.session
-114
-115        resp = await s.get(url=url, headers=headers, timeout=timeout)
-116
-117        data: List[Dict[str, Any]] = (await resp.json()).get('keys', [])
-118        return data
-119
-120    # https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/signBlob
-121    async def sign_blob(
-122        self, payload: Optional[Union[str, bytes]],
-123        service_account_email: Optional[str] = None,
-124        delegates: Optional[List[str]] = None,
-125        session: Optional[Session] = None,
-126        timeout: int = 10,
-127    ) -> Dict[str, str]:
-128        service_account_email = (
-129            service_account_email
-130            or self.service_account_email
-131        )
-132        if not service_account_email:
-133            raise TypeError(
-134                'sign_blob must have a valid '
-135                'service_account_email',
-136            )
-137
-138        resource_name = f'projects/-/serviceAccounts/{service_account_email}'
-139        url = f'{API_ROOT_IAM_CREDENTIALS}/{resource_name}:signBlob'
-140
-141        json_str = json.dumps({
-142            'delegates': delegates or [resource_name],
-143            'payload': encode(payload or '').decode('utf-8'),
-144        })
-145
-146        headers = await self.headers()
-147        headers.update({
-148            'Content-Length': str(len(json_str)),
-149            'Content-Type': 'application/json',
-150        })
-151
-152        s = AioSession(session) if session else self.session
-153
-154        resp = await s.post(
-155            url=url, data=json_str, headers=headers,
-156            timeout=timeout,
-157        )
-158        data: Dict[str, Any] = await resp.json()
-159        return data
-160
-161    async def close(self) -> None:
-162        await self.session.close()
-163
-164    async def __aenter__(self) -> 'IamClient':
-165        return self
-166
-167    async def __aexit__(self, *args: Any) -> None:
-168        await self.close()
-
- - - - -
- -
- - IamClient( service_file: Union[str, IO[~AnyStr], NoneType] = None, session: Optional[aiohttp.client.ClientSession] = None, token: Optional[Token] = None) - - - -
- -
29    def __init__(
-30        self, service_file: Optional[Union[str, IO[AnyStr]]] = None,
-31        session: Optional[Session] = None,
-32        token: Optional[Token] = None,
-33    ) -> None:
-34        self.session = AioSession(session)
-35        self.token = token or Token(
-36            service_file=service_file, scopes=SCOPES,
-37            session=self.session.session,  # type: ignore[arg-type]
-38        )
-39
-40        if self.token.token_type not in {
-41            Type.GCE_METADATA,
-42            Type.SERVICE_ACCOUNT,
-43        }:
-44            raise TypeError(
-45                'IAM Credentials Client is only valid for use '
-46                'with Service Accounts or GCE Metadata',
-47            )
-
- - - - -
-
-
- session - - -
- - - - -
-
-
- token - - -
- - - - -
-
- -
- - async def - headers(self) -> Dict[str, str]: - - - -
- -
49    async def headers(self) -> Dict[str, str]:
-50        token = await self.token.get()
-51        return {
-52            'Authorization': f'Bearer {token}',
-53        }
-
- - - - -
-
-
- service_account_email: Optional[str] - - -
- - - - -
-
- -
- - async def - get_public_key( self, key_id: Optional[str] = None, key: Optional[str] = None, service_account_email: Optional[str] = None, project: Optional[str] = None, session: Optional[aiohttp.client.ClientSession] = None, timeout: int = 10) -> Dict[str, str]: - - - -
- -
60    async def get_public_key(
-61        self, key_id: Optional[str] = None,
-62        key: Optional[str] = None,
-63        service_account_email: Optional[str] = None,
-64        project: Optional[str] = None,
-65        session: Optional[Session] = None,
-66        timeout: int = 10,
-67    ) -> Dict[str, str]:
-68        service_account_email = (
-69            service_account_email
-70            or self.service_account_email
-71        )
-72        project = project or await self.token.get_project()
-73
-74        if not key_id and not key:
-75            raise ValueError('get_public_key must have either key_id or key')
-76
-77        if not key:
-78            key = (
-79                f'projects/{project}/serviceAccounts/'
-80                f'{service_account_email}/keys/{key_id}'
-81            )
-82
-83        url = f'{API_ROOT_IAM}/{key}?publicKeyType=TYPE_X509_PEM_FILE'
-84        headers = await self.headers()
-85
-86        s = AioSession(session) if session else self.session
-87
-88        resp = await s.get(url=url, headers=headers, timeout=timeout)
-89
-90        data: Dict[str, str] = await resp.json()
-91        return data
-
- - - - -
-
- -
- - async def - list_public_keys( self, service_account_email: Optional[str] = None, project: Optional[str] = None, session: Optional[aiohttp.client.ClientSession] = None, timeout: int = 10) -> List[Dict[str, str]]: - - - -
- -
 94    async def list_public_keys(
- 95            self, service_account_email: Optional[str] = None,
- 96            project: Optional[str] = None,
- 97            session: Optional[Session] = None,
- 98            timeout: int = 10,
- 99    ) -> List[Dict[str, str]]:
-100        service_account_email = (
-101            service_account_email
-102            or self.service_account_email
-103        )
-104        project = project or await self.token.get_project()
-105
-106        url = (
-107            f'{API_ROOT_IAM}/projects/{project}/'
-108            f'serviceAccounts/{service_account_email}/keys'
-109        )
-110
-111        headers = await self.headers()
-112
-113        s = AioSession(session) if session else self.session
-114
-115        resp = await s.get(url=url, headers=headers, timeout=timeout)
-116
-117        data: List[Dict[str, Any]] = (await resp.json()).get('keys', [])
-118        return data
-
- - - - -
-
- -
- - async def - sign_blob( self, payload: Union[bytes, str, NoneType], service_account_email: Optional[str] = None, delegates: Optional[List[str]] = None, session: Optional[aiohttp.client.ClientSession] = None, timeout: int = 10) -> Dict[str, str]: - - - -
- -
121    async def sign_blob(
-122        self, payload: Optional[Union[str, bytes]],
-123        service_account_email: Optional[str] = None,
-124        delegates: Optional[List[str]] = None,
-125        session: Optional[Session] = None,
-126        timeout: int = 10,
-127    ) -> Dict[str, str]:
-128        service_account_email = (
-129            service_account_email
-130            or self.service_account_email
-131        )
-132        if not service_account_email:
-133            raise TypeError(
-134                'sign_blob must have a valid '
-135                'service_account_email',
-136            )
-137
-138        resource_name = f'projects/-/serviceAccounts/{service_account_email}'
-139        url = f'{API_ROOT_IAM_CREDENTIALS}/{resource_name}:signBlob'
-140
-141        json_str = json.dumps({
-142            'delegates': delegates or [resource_name],
-143            'payload': encode(payload or '').decode('utf-8'),
-144        })
-145
-146        headers = await self.headers()
-147        headers.update({
-148            'Content-Length': str(len(json_str)),
-149            'Content-Type': 'application/json',
-150        })
-151
-152        s = AioSession(session) if session else self.session
-153
-154        resp = await s.post(
-155            url=url, data=json_str, headers=headers,
-156            timeout=timeout,
-157        )
-158        data: Dict[str, Any] = await resp.json()
-159        return data
-
- - - - -
-
- -
- - async def - close(self) -> None: - - - -
- -
161    async def close(self) -> None:
-162        await self.session.close()
-
- - - - -
-
-
- -
- - class - Token: - - - -
- -
136class Token:
-137    # pylint: disable=too-many-instance-attributes
-138    def __init__(
-139        self, service_file: Optional[Union[str, IO[AnyStr]]] = None,
-140        session: Optional[Session] = None,
-141        scopes: Optional[List[str]] = None,
-142    ) -> None:
-143        self.service_data = get_service_data(service_file)
-144        if self.service_data:
-145            self.token_type = Type(self.service_data['type'])
-146            self.token_uri = self.service_data.get(
-147                'token_uri', 'https://oauth2.googleapis.com/token',
-148            )
-149        else:
-150            # At this point, all we can do is assume we're running somewhere
-151            # with default credentials, eg. GCE.
-152            self.token_type = Type.GCE_METADATA
-153            self.token_uri = GCE_ENDPOINT_TOKEN
-154
-155        self.session = AioSession(session)
-156        self.scopes = ' '.join(scopes or [])
-157        if self.token_type == Type.SERVICE_ACCOUNT and not self.scopes:
-158            raise Exception(
-159                'scopes must be provided when token type is '
-160                'service account',
-161            )
-162
-163        self.access_token: Optional[str] = None
-164        self.access_token_duration = 0
-165        self.access_token_acquired_at = datetime.datetime(1970, 1, 1)
-166
-167        self.acquiring: Optional['asyncio.Future[Any]'] = None
-168
-169    async def get_project(self) -> Optional[str]:
-170        project = (
-171            os.environ.get('GOOGLE_CLOUD_PROJECT')
-172            or os.environ.get('GCLOUD_PROJECT')
-173            or os.environ.get('APPLICATION_ID')
-174        )
-175
-176        if self.token_type == Type.GCE_METADATA:
-177            await self.ensure_token()
-178            resp = await self.session.get(
-179                GCE_ENDPOINT_PROJECT, timeout=10,
-180                headers=GCE_METADATA_HEADERS,
-181            )
-182
-183            if not project:
-184                try:
-185                    project = await resp.text()
-186                except (AttributeError, TypeError):
-187                    project = str(resp.text)
-188
-189        elif self.token_type == Type.SERVICE_ACCOUNT:
-190            project = project or self.service_data.get('project_id')
-191
-192        return project
-193
-194    async def get(self) -> Optional[str]:
-195        await self.ensure_token()
-196        return self.access_token
-197
-198    async def ensure_token(self) -> None:
-199        if self.acquiring and not self.acquiring.done():
-200            await self.acquiring
-201            return
-202
-203        if self.access_token:
-204            now = datetime.datetime.utcnow()
-205            delta = (now - self.access_token_acquired_at).total_seconds()
-206            if delta <= self.access_token_duration / 2:
-207                return
-208
-209        self.acquiring = asyncio.ensure_future(self.acquire_access_token())
-210        await self.acquiring
-211
-212    async def _refresh_authorized_user(self, timeout: int) -> Response:
-213        payload = urlencode({
-214            'grant_type': 'refresh_token',
-215            'client_id': self.service_data['client_id'],
-216            'client_secret': self.service_data['client_secret'],
-217            'refresh_token': self.service_data['refresh_token'],
-218        })
-219
-220        resp: Response = await self.session.post(  # type: ignore[assignment]
-221            url=self.token_uri, data=payload, headers=REFRESH_HEADERS,
-222            timeout=timeout,
-223        )
-224        return resp
-225
-226    async def _refresh_gce_metadata(self, timeout: int) -> Response:
-227        resp: Response = await self.session.get(  # type: ignore[assignment]
-228            url=self.token_uri, headers=GCE_METADATA_HEADERS, timeout=timeout,
-229        )
-230        return resp
-231
-232    async def _refresh_service_account(self, timeout: int) -> Response:
-233        now = int(time.time())
-234        assertion_payload = {
-235            'aud': self.token_uri,
-236            'exp': now + GCLOUD_TOKEN_DURATION,
-237            'iat': now,
-238            'iss': self.service_data['client_email'],
-239            'scope': self.scopes,
-240        }
-241
-242        # N.B. algorithm='RS256' requires an extra 240MB in dependencies...
-243        assertion = jwt.encode(
-244            assertion_payload,
-245            self.service_data['private_key'],
-246            algorithm='RS256',
-247        )
-248        payload = urlencode({
-249            'assertion': assertion,
-250            'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer',
-251        })
-252
-253        resp: Response = await self.session.post(  # type: ignore[assignment]
-254            self.token_uri, data=payload, headers=REFRESH_HEADERS,
-255            timeout=timeout,
-256        )
-257        return resp
-258
-259    @backoff.on_exception(backoff.expo, Exception, max_tries=5)
-260    async def acquire_access_token(self, timeout: int = 10) -> None:
-261        if self.token_type == Type.AUTHORIZED_USER:
-262            resp = await self._refresh_authorized_user(timeout=timeout)
-263        elif self.token_type == Type.GCE_METADATA:
-264            resp = await self._refresh_gce_metadata(timeout=timeout)
-265        elif self.token_type == Type.SERVICE_ACCOUNT:
-266            resp = await self._refresh_service_account(timeout=timeout)
-267        else:
-268            raise Exception(f'unsupported token type {self.token_type}')
-269
-270        content = await resp.json()
-271
-272        self.access_token = str(content['access_token'])
-273        self.access_token_duration = int(content['expires_in'])
-274        self.access_token_acquired_at = datetime.datetime.utcnow()
-275        self.acquiring = None
-276
-277    async def close(self) -> None:
-278        await self.session.close()
-279
-280    async def __aenter__(self) -> 'Token':
-281        return self
-282
-283    async def __aexit__(self, *args: Any) -> None:
-284        await self.close()
-
- - - - -
- -
- - Token( service_file: Union[str, IO[~AnyStr], NoneType] = None, session: Optional[aiohttp.client.ClientSession] = None, scopes: Optional[List[str]] = None) - - - -
- -
138    def __init__(
-139        self, service_file: Optional[Union[str, IO[AnyStr]]] = None,
-140        session: Optional[Session] = None,
-141        scopes: Optional[List[str]] = None,
-142    ) -> None:
-143        self.service_data = get_service_data(service_file)
-144        if self.service_data:
-145            self.token_type = Type(self.service_data['type'])
-146            self.token_uri = self.service_data.get(
-147                'token_uri', 'https://oauth2.googleapis.com/token',
-148            )
-149        else:
-150            # At this point, all we can do is assume we're running somewhere
-151            # with default credentials, eg. GCE.
-152            self.token_type = Type.GCE_METADATA
-153            self.token_uri = GCE_ENDPOINT_TOKEN
-154
-155        self.session = AioSession(session)
-156        self.scopes = ' '.join(scopes or [])
-157        if self.token_type == Type.SERVICE_ACCOUNT and not self.scopes:
-158            raise Exception(
-159                'scopes must be provided when token type is '
-160                'service account',
-161            )
-162
-163        self.access_token: Optional[str] = None
-164        self.access_token_duration = 0
-165        self.access_token_acquired_at = datetime.datetime(1970, 1, 1)
-166
-167        self.acquiring: Optional['asyncio.Future[Any]'] = None
-
- - - - -
-
-
- service_data - - -
- - - - -
-
-
- session - - -
- - - - -
-
-
- scopes - - -
- - - - -
-
-
- access_token: Optional[str] - - -
- - - - -
-
-
- access_token_duration - - -
- - - - -
-
-
- access_token_acquired_at - - -
- - - - -
-
-
- acquiring: Optional[_asyncio.Future[Any]] - - -
- - - - -
-
- -
- - async def - get_project(self) -> Optional[str]: - - - -
- -
169    async def get_project(self) -> Optional[str]:
-170        project = (
-171            os.environ.get('GOOGLE_CLOUD_PROJECT')
-172            or os.environ.get('GCLOUD_PROJECT')
-173            or os.environ.get('APPLICATION_ID')
-174        )
-175
-176        if self.token_type == Type.GCE_METADATA:
-177            await self.ensure_token()
-178            resp = await self.session.get(
-179                GCE_ENDPOINT_PROJECT, timeout=10,
-180                headers=GCE_METADATA_HEADERS,
-181            )
-182
-183            if not project:
-184                try:
-185                    project = await resp.text()
-186                except (AttributeError, TypeError):
-187                    project = str(resp.text)
-188
-189        elif self.token_type == Type.SERVICE_ACCOUNT:
-190            project = project or self.service_data.get('project_id')
-191
-192        return project
-
- - - - -
-
- -
- - async def - get(self) -> Optional[str]: - - - -
- -
194    async def get(self) -> Optional[str]:
-195        await self.ensure_token()
-196        return self.access_token
-
- - - - -
-
- -
- - async def - ensure_token(self) -> None: - - - -
- -
198    async def ensure_token(self) -> None:
-199        if self.acquiring and not self.acquiring.done():
-200            await self.acquiring
-201            return
-202
-203        if self.access_token:
-204            now = datetime.datetime.utcnow()
-205            delta = (now - self.access_token_acquired_at).total_seconds()
-206            if delta <= self.access_token_duration / 2:
-207                return
-208
-209        self.acquiring = asyncio.ensure_future(self.acquire_access_token())
-210        await self.acquiring
-
- - - - -
-
- -
-
@backoff.on_exception(backoff.expo, Exception, max_tries=5)
- - async def - acquire_access_token(self, timeout: int = 10) -> None: - - - -
- -
259    @backoff.on_exception(backoff.expo, Exception, max_tries=5)
-260    async def acquire_access_token(self, timeout: int = 10) -> None:
-261        if self.token_type == Type.AUTHORIZED_USER:
-262            resp = await self._refresh_authorized_user(timeout=timeout)
-263        elif self.token_type == Type.GCE_METADATA:
-264            resp = await self._refresh_gce_metadata(timeout=timeout)
-265        elif self.token_type == Type.SERVICE_ACCOUNT:
-266            resp = await self._refresh_service_account(timeout=timeout)
-267        else:
-268            raise Exception(f'unsupported token type {self.token_type}')
-269
-270        content = await resp.json()
-271
-272        self.access_token = str(content['access_token'])
-273        self.access_token_duration = int(content['expires_in'])
-274        self.access_token_acquired_at = datetime.datetime.utcnow()
-275        self.acquiring = None
-
- - - - -
-
- -
- - async def - close(self) -> None: - - - -
- -
277    async def close(self) -> None:
-278        await self.session.close()
-
- - - - -
-
-
-
- __version__ = -'4.2.3' - - -
- - - - -
-
- -
- - def - decode(payload: str) -> bytes: - - - -
- -
 6def decode(payload: str) -> bytes:
- 7    """
- 8    Modified Base64 for URL variants exist, where the + and / characters of
- 9    standard Base64 are respectively replaced by - and _.
-10
-11    See https://en.wikipedia.org/wiki/Base64#URL_applications
-12    """
-13    return base64.b64decode(payload, altchars=b'-_')
-
- - -

Modified Base64 for URL variants exist, where the + and / characters of -standard Base64 are respectively replaced by - and _.

- -

See https://en.wikipedia.org/wiki/Base64#URL_applications

-
- - -
-
- -
- - def - encode(payload: Union[bytes, str]) -> bytes: - - - -
- -
16def encode(payload: Union[bytes, str]) -> bytes:
-17    """
-18    Modified Base64 for URL variants exist, where the + and / characters of
-19    standard Base64 are respectively replaced by - and _.
-20
-21    See https://en.wikipedia.org/wiki/Base64#URL_applications
-22    """
-23    if isinstance(payload, str):
-24        payload = payload.encode('utf-8')
-25
-26    return base64.b64encode(payload, altchars=b'-_')
-
- - -

Modified Base64 for URL variants exist, where the + and / characters of -standard Base64 are respectively replaced by - and _.

- -

See https://en.wikipedia.org/wiki/Base64#URL_applications

-
- - -
-
- - \ No newline at end of file diff --git a/gcloud/rest.html b/gcloud/rest.html deleted file mode 100644 index 36e193a8c..000000000 --- a/gcloud/rest.html +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - gcloud.rest API documentation - - - - - - - - - -
-
-

-gcloud.rest

- -

-
- - - - - -
1"""
-2.. include:: ../../../../docs/rest.md
-3"""
-4try:
-5    import pkg_resources
-6    pkg_resources.declare_namespace(__name__)
-7except ImportError:
-8    import pkgutil
-9    __path__ = pkgutil.extend_path(__path__, __name__)
-
- - -
-
- - \ No newline at end of file diff --git a/gcloud/rest/auth.html b/gcloud/rest/auth.html deleted file mode 100644 index ad2be75d7..000000000 --- a/gcloud/rest/auth.html +++ /dev/null @@ -1,1751 +0,0 @@ - - - - - - - gcloud.rest.auth API documentation - - - - - - - - - -
-
-

-gcloud.rest.auth

- -

This library implements various methods for working with the Google IAM / auth -APIs. This includes authenticating for the purpose of using other Google APIs, -managing service accounts and public keys, URL-signing blobs, etc.

- -

Installation

- -
-
$ pip install --upgrade gcloud-rest-auth
-
-
- -

Usage

- -
-
from gcloud.rest.auth import IamClient
-from gcloud.rest.auth import Token
-
-
-client = IamClient()
-pubkeys = client.list_public_keys()
-
-token = Token()
-print(token.get())
-
-
- -

Additionally, the Token constructor accepts the following optional arguments:

- -
    -
  • service_file: path to a service account authorized user -file, or any other application credentials. Alternatively, you can pass a -file-like object, like an io.StringIO instance, in case your credentials -are not stored in a file but in memory. If omitted, will attempt to find one -on your path or fallback to generating a token from GCE metadata.
  • -
  • session: an aiohttp.ClientSession instance to be used for all requests. -If omitted, a default session will be created. If you use the default -session, you may be interested in using Token() as a context manager -(with Token(..) as token:) or explicitly calling the Token.close() -method to ensure the session is cleaned up appropriately.
  • -
  • scopes: an optional list of GCP scopes_ for which to generate our token. -Only valid (and required!) for service account -authentication.
  • -
-
- - - - - -
 1"""
- 2This library implements various methods for working with the Google IAM / auth
- 3APIs. This includes authenticating for the purpose of using other Google APIs,
- 4managing service accounts and public keys, URL-signing blobs, etc.
- 5
- 6## Installation
- 7
- 8```console
- 9$ pip install --upgrade gcloud-rest-auth
-10```
-11
-12## Usage
-13
-14```python
-15from gcloud.rest.auth import IamClient
-16from gcloud.rest.auth import Token
-17
-18
-19client = IamClient()
-20pubkeys = client.list_public_keys()
-21
-22token = Token()
-23print(token.get())
-24```
-25
-26Additionally, the `Token` constructor accepts the following optional arguments:
-27
-28* `service_file`: path to a [service account][service-account] authorized user
-29  file, or any other application credentials. Alternatively, you can pass a
-30  file-like object, like an `io.StringIO` instance, in case your credentials
-31  are not stored in a file but in memory. If omitted, will attempt to find one
-32  on your path or fallback to generating a token from GCE metadata.
-33* `session`: an `aiohttp.ClientSession` instance to be used for all requests.
-34  If omitted, a default session will be created. If you use the default
-35  session, you may be interested in using `Token()` as a context manager
-36  (`with Token(..) as token:`) or explicitly calling the `Token.close()`
-37  method to ensure the session is cleaned up appropriately.
-38* `scopes`: an optional list of GCP `scopes`_ for which to generate our token.
-39  Only valid (and required!) for [service account][service-account]
-40  authentication.
-41
-42[service-account]: https://console.cloud.google.com/iam-admin/serviceaccounts
-43"""
-44from pkg_resources import get_distribution
-45
-46__version__ = get_distribution('gcloud-rest-auth').version
-47
-48from gcloud.rest.auth.build_constants import BUILD_GCLOUD_REST
-49from gcloud.rest.auth.iam import IamClient
-50from gcloud.rest.auth.session import SyncSession
-51from gcloud.rest.auth.token import Token
-52from gcloud.rest.auth.utils import decode, encode
-53
-54__all__ = [
-55    'SyncSession',
-56    'BUILD_GCLOUD_REST',
-57    'IamClient',
-58    'Token',
-59    '__version__',
-60    'decode',
-61    'encode',
-62]
-
- - -
-
- -
- - class - SyncSession(gcloud.rest.auth.session.BaseSession): - - - -
- -
242    class SyncSession(BaseSession):
-243        _google_api_lock = threading.RLock()
-244
-245        @property
-246        def google_api_lock(self) -> threading.RLock:
-247            return SyncSession._google_api_lock  # pylint: disable=protected-access
-248
-249        @property
-250        def session(self) -> Session:
-251            if not self._session:
-252                self._session = Session()
-253                self._session.verify = self._ssl
-254            return self._session
-255
-256        # N.B.: none of these will be `async` in compiled form, but adding the
-257        # symbol ensures we match the base class's definition for static
-258        # analysis.
-259        def post(
-260            self, url: str, headers: Mapping[str, str],
-261            data: Optional[Union[bytes, str, IO[AnyStr]]] = None,
-262            timeout: float = 10,
-263            params: Optional[Mapping[str, Union[int, str]]] = None,
-264        ) -> Response:
-265            with self.google_api_lock:
-266                resp = self.session.post(
-267                    url, data=data, headers=headers,
-268                    timeout=timeout, params=params,
-269                )
-270            resp.raise_for_status()
-271            return resp
-272
-273        def get(
-274            self, url: str, headers: Optional[Mapping[str, str]] = None,
-275            timeout: float = 10,
-276            params: Optional[Mapping[str, Union[int, str]]] = None,
-277            stream: bool = False,
-278        ) -> Response:
-279            with self.google_api_lock:
-280                resp = self.session.get(
-281                    url, headers=headers, timeout=timeout,
-282                    params=params, stream=stream,
-283                )
-284            resp.raise_for_status()
-285            return resp
-286
-287        def patch(
-288            self, url: str, headers: Mapping[str, str],
-289            data: Optional[Union[bytes, str]] = None, timeout: float = 10,
-290            params: Optional[Mapping[str, Union[int, str]]] = None,
-291        ) -> Response:
-292            with self.google_api_lock:
-293                resp = self.session.patch(
-294                    url, data=data, headers=headers,
-295                    timeout=timeout, params=params,
-296                )
-297            resp.raise_for_status()
-298            return resp
-299
-300        def put(
-301            self, url: str, headers: Mapping[str, str],
-302            data: Union[bytes, str, IO[Any]], timeout: float = 10,
-303        ) -> Response:
-304            with self.google_api_lock:
-305                resp = self.session.put(
-306                    url, data=data, headers=headers,
-307                    timeout=timeout,
-308                )
-309            resp.raise_for_status()
-310            return resp
-311
-312        def delete(
-313            self, url: str, headers: Mapping[str, str],
-314            params: Optional[Mapping[str, Union[int, str]]] = None,
-315            timeout: float = 10,
-316        ) -> Response:
-317            with self.google_api_lock:
-318                resp = self.session.delete(
-319                    url, params=params, headers=headers,
-320                    timeout=timeout,
-321                )
-322            resp.raise_for_status()
-323            return resp
-324
-325        def request(
-326            self, method: str, url: str, headers: Mapping[str, str],
-327            auto_raise_for_status: bool = True, **kwargs: Any,
-328        ) -> Response:
-329            with self.google_api_lock:
-330                resp = self.session.request(
-331                    method, url, headers=headers, **kwargs,
-332                )
-333            if auto_raise_for_status:
-334                resp.raise_for_status()
-335            return resp
-336
-337        def close(self) -> None:
-338            if not self._shared_session and self._session:
-339                self._session.close()
-
- - - - -
-
- google_api_lock: <function RLock at 0x7f5241c51300> - - -
- - - - -
-
-
- session: requests.sessions.Session - - -
- - - - -
-
- -
- - def - post( self, url: str, headers: Mapping[str, str], data: Union[bytes, str, IO[~AnyStr], NoneType] = None, timeout: float = 10, params: Optional[Mapping[str, Union[int, str]]] = None) -> requests.models.Response: - - - -
- -
259        def post(
-260            self, url: str, headers: Mapping[str, str],
-261            data: Optional[Union[bytes, str, IO[AnyStr]]] = None,
-262            timeout: float = 10,
-263            params: Optional[Mapping[str, Union[int, str]]] = None,
-264        ) -> Response:
-265            with self.google_api_lock:
-266                resp = self.session.post(
-267                    url, data=data, headers=headers,
-268                    timeout=timeout, params=params,
-269                )
-270            resp.raise_for_status()
-271            return resp
-
- - - - -
-
- -
- - def - get( self, url: str, headers: Optional[Mapping[str, str]] = None, timeout: float = 10, params: Optional[Mapping[str, Union[int, str]]] = None, stream: bool = False) -> requests.models.Response: - - - -
- -
273        def get(
-274            self, url: str, headers: Optional[Mapping[str, str]] = None,
-275            timeout: float = 10,
-276            params: Optional[Mapping[str, Union[int, str]]] = None,
-277            stream: bool = False,
-278        ) -> Response:
-279            with self.google_api_lock:
-280                resp = self.session.get(
-281                    url, headers=headers, timeout=timeout,
-282                    params=params, stream=stream,
-283                )
-284            resp.raise_for_status()
-285            return resp
-
- - - - -
-
- -
- - def - patch( self, url: str, headers: Mapping[str, str], data: Union[bytes, str, NoneType] = None, timeout: float = 10, params: Optional[Mapping[str, Union[int, str]]] = None) -> requests.models.Response: - - - -
- -
287        def patch(
-288            self, url: str, headers: Mapping[str, str],
-289            data: Optional[Union[bytes, str]] = None, timeout: float = 10,
-290            params: Optional[Mapping[str, Union[int, str]]] = None,
-291        ) -> Response:
-292            with self.google_api_lock:
-293                resp = self.session.patch(
-294                    url, data=data, headers=headers,
-295                    timeout=timeout, params=params,
-296                )
-297            resp.raise_for_status()
-298            return resp
-
- - - - -
-
- -
- - def - put( self, url: str, headers: Mapping[str, str], data: Union[bytes, str, IO[Any]], timeout: float = 10) -> requests.models.Response: - - - -
- -
300        def put(
-301            self, url: str, headers: Mapping[str, str],
-302            data: Union[bytes, str, IO[Any]], timeout: float = 10,
-303        ) -> Response:
-304            with self.google_api_lock:
-305                resp = self.session.put(
-306                    url, data=data, headers=headers,
-307                    timeout=timeout,
-308                )
-309            resp.raise_for_status()
-310            return resp
-
- - - - -
-
- -
- - def - delete( self, url: str, headers: Mapping[str, str], params: Optional[Mapping[str, Union[int, str]]] = None, timeout: float = 10) -> requests.models.Response: - - - -
- -
312        def delete(
-313            self, url: str, headers: Mapping[str, str],
-314            params: Optional[Mapping[str, Union[int, str]]] = None,
-315            timeout: float = 10,
-316        ) -> Response:
-317            with self.google_api_lock:
-318                resp = self.session.delete(
-319                    url, params=params, headers=headers,
-320                    timeout=timeout,
-321                )
-322            resp.raise_for_status()
-323            return resp
-
- - - - -
-
- -
- - def - request( self, method: str, url: str, headers: Mapping[str, str], auto_raise_for_status: bool = True, **kwargs: Any) -> requests.models.Response: - - - -
- -
325        def request(
-326            self, method: str, url: str, headers: Mapping[str, str],
-327            auto_raise_for_status: bool = True, **kwargs: Any,
-328        ) -> Response:
-329            with self.google_api_lock:
-330                resp = self.session.request(
-331                    method, url, headers=headers, **kwargs,
-332                )
-333            if auto_raise_for_status:
-334                resp.raise_for_status()
-335            return resp
-
- - - - -
-
- -
- - def - close(self) -> None: - - - -
- -
337        def close(self) -> None:
-338            if not self._shared_session and self._session:
-339                self._session.close()
-
- - - - -
-
-
Inherited Members
-
-
gcloud.rest.auth.session.BaseSession
-
BaseSession
- -
-
-
-
-
-
- BUILD_GCLOUD_REST = -True - - -
- - - - -
-
- -
- - class - IamClient: - - - -
- -
 28class IamClient:
- 29    def __init__(
- 30        self, service_file: Optional[Union[str, IO[AnyStr]]] = None,
- 31        session: Optional[Session] = None,
- 32        token: Optional[Token] = None,
- 33    ) -> None:
- 34        self.session = SyncSession(session)
- 35        self.token = token or Token(
- 36            service_file=service_file, scopes=SCOPES,
- 37            session=self.session.session,  # type: ignore[arg-type]
- 38        )
- 39
- 40        if self.token.token_type not in {
- 41            Type.GCE_METADATA,
- 42            Type.SERVICE_ACCOUNT,
- 43        }:
- 44            raise TypeError(
- 45                'IAM Credentials Client is only valid for use '
- 46                'with Service Accounts or GCE Metadata',
- 47            )
- 48
- 49    def headers(self) -> Dict[str, str]:
- 50        token = self.token.get()
- 51        return {
- 52            'Authorization': f'Bearer {token}',
- 53        }
- 54
- 55    @property
- 56    def service_account_email(self) -> Optional[str]:
- 57        return self.token.service_data.get('client_email')
- 58
- 59    # https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts.keys/get
- 60    def get_public_key(
- 61        self, key_id: Optional[str] = None,
- 62        key: Optional[str] = None,
- 63        service_account_email: Optional[str] = None,
- 64        project: Optional[str] = None,
- 65        session: Optional[Session] = None,
- 66        timeout: int = 10,
- 67    ) -> Dict[str, str]:
- 68        service_account_email = (
- 69            service_account_email
- 70            or self.service_account_email
- 71        )
- 72        project = project or self.token.get_project()
- 73
- 74        if not key_id and not key:
- 75            raise ValueError('get_public_key must have either key_id or key')
- 76
- 77        if not key:
- 78            key = (
- 79                f'projects/{project}/serviceAccounts/'
- 80                f'{service_account_email}/keys/{key_id}'
- 81            )
- 82
- 83        url = f'{API_ROOT_IAM}/{key}?publicKeyType=TYPE_X509_PEM_FILE'
- 84        headers = self.headers()
- 85
- 86        s = SyncSession(session) if session else self.session
- 87
- 88        resp = s.get(url=url, headers=headers, timeout=timeout)
- 89
- 90        data: Dict[str, str] = resp.json()
- 91        return data
- 92
- 93    # https://cloud.google.com/iam/reference/rest/v1/projects.serviceAccounts.keys/list
- 94    def list_public_keys(
- 95            self, service_account_email: Optional[str] = None,
- 96            project: Optional[str] = None,
- 97            session: Optional[Session] = None,
- 98            timeout: int = 10,
- 99    ) -> List[Dict[str, str]]:
-100        service_account_email = (
-101            service_account_email
-102            or self.service_account_email
-103        )
-104        project = project or self.token.get_project()
-105
-106        url = (
-107            f'{API_ROOT_IAM}/projects/{project}/'
-108            f'serviceAccounts/{service_account_email}/keys'
-109        )
-110
-111        headers = self.headers()
-112
-113        s = SyncSession(session) if session else self.session
-114
-115        resp = s.get(url=url, headers=headers, timeout=timeout)
-116
-117        data: List[Dict[str, Any]] = (resp.json()).get('keys', [])
-118        return data
-119
-120    # https://cloud.google.com/iam/credentials/reference/rest/v1/projects.serviceAccounts/signBlob
-121    def sign_blob(
-122        self, payload: Optional[Union[str, bytes]],
-123        service_account_email: Optional[str] = None,
-124        delegates: Optional[List[str]] = None,
-125        session: Optional[Session] = None,
-126        timeout: int = 10,
-127    ) -> Dict[str, str]:
-128        service_account_email = (
-129            service_account_email
-130            or self.service_account_email
-131        )
-132        if not service_account_email:
-133            raise TypeError(
-134                'sign_blob must have a valid '
-135                'service_account_email',
-136            )
-137
-138        resource_name = f'projects/-/serviceAccounts/{service_account_email}'
-139        url = f'{API_ROOT_IAM_CREDENTIALS}/{resource_name}:signBlob'
-140
-141        json_str = json.dumps({
-142            'delegates': delegates or [resource_name],
-143            'payload': encode(payload or '').decode('utf-8'),
-144        })
-145
-146        headers = self.headers()
-147        headers.update({
-148            'Content-Length': str(len(json_str)),
-149            'Content-Type': 'application/json',
-150        })
-151
-152        s = SyncSession(session) if session else self.session
-153
-154        resp = s.post(
-155            url=url, data=json_str, headers=headers,
-156            timeout=timeout,
-157        )
-158        data: Dict[str, Any] = resp.json()
-159        return data
-160
-161    def close(self) -> None:
-162        self.session.close()
-163
-164    def __enter__(self) -> 'IamClient':
-165        return self
-166
-167    def __exit__(self, *args: Any) -> None:
-168        self.close()
-
- - - - -
- -
- - IamClient( service_file: Union[str, IO[~AnyStr], NoneType] = None, session: Optional[requests.sessions.Session] = None, token: Optional[Token] = None) - - - -
- -
29    def __init__(
-30        self, service_file: Optional[Union[str, IO[AnyStr]]] = None,
-31        session: Optional[Session] = None,
-32        token: Optional[Token] = None,
-33    ) -> None:
-34        self.session = SyncSession(session)
-35        self.token = token or Token(
-36            service_file=service_file, scopes=SCOPES,
-37            session=self.session.session,  # type: ignore[arg-type]
-38        )
-39
-40        if self.token.token_type not in {
-41            Type.GCE_METADATA,
-42            Type.SERVICE_ACCOUNT,
-43        }:
-44            raise TypeError(
-45                'IAM Credentials Client is only valid for use '
-46                'with Service Accounts or GCE Metadata',
-47            )
-
- - - - -
-
-
- session - - -
- - - - -
-
-
- token - - -
- - - - -
-
- -
- - def - headers(self) -> Dict[str, str]: - - - -
- -
49    def headers(self) -> Dict[str, str]:
-50        token = self.token.get()
-51        return {
-52            'Authorization': f'Bearer {token}',
-53        }
-
- - - - -
-
-
- service_account_email: Optional[str] - - -
- - - - -
-
- -
- - def - get_public_key( self, key_id: Optional[str] = None, key: Optional[str] = None, service_account_email: Optional[str] = None, project: Optional[str] = None, session: Optional[requests.sessions.Session] = None, timeout: int = 10) -> Dict[str, str]: - - - -
- -
60    def get_public_key(
-61        self, key_id: Optional[str] = None,
-62        key: Optional[str] = None,
-63        service_account_email: Optional[str] = None,
-64        project: Optional[str] = None,
-65        session: Optional[Session] = None,
-66        timeout: int = 10,
-67    ) -> Dict[str, str]:
-68        service_account_email = (
-69            service_account_email
-70            or self.service_account_email
-71        )
-72        project = project or self.token.get_project()
-73
-74        if not key_id and not key:
-75            raise ValueError('get_public_key must have either key_id or key')
-76
-77        if not key:
-78            key = (
-79                f'projects/{project}/serviceAccounts/'
-80                f'{service_account_email}/keys/{key_id}'
-81            )
-82
-83        url = f'{API_ROOT_IAM}/{key}?publicKeyType=TYPE_X509_PEM_FILE'
-84        headers = self.headers()
-85
-86        s = SyncSession(session) if session else self.session
-87
-88        resp = s.get(url=url, headers=headers, timeout=timeout)
-89
-90        data: Dict[str, str] = resp.json()
-91        return data
-
- - - - -
-
- -
- - def - list_public_keys( self, service_account_email: Optional[str] = None, project: Optional[str] = None, session: Optional[requests.sessions.Session] = None, timeout: int = 10) -> List[Dict[str, str]]: - - - -
- -
 94    def list_public_keys(
- 95            self, service_account_email: Optional[str] = None,
- 96            project: Optional[str] = None,
- 97            session: Optional[Session] = None,
- 98            timeout: int = 10,
- 99    ) -> List[Dict[str, str]]:
-100        service_account_email = (
-101            service_account_email
-102            or self.service_account_email
-103        )
-104        project = project or self.token.get_project()
-105
-106        url = (
-107            f'{API_ROOT_IAM}/projects/{project}/'
-108            f'serviceAccounts/{service_account_email}/keys'
-109        )
-110
-111        headers = self.headers()
-112
-113        s = SyncSession(session) if session else self.session
-114
-115        resp = s.get(url=url, headers=headers, timeout=timeout)
-116
-117        data: List[Dict[str, Any]] = (resp.json()).get('keys', [])
-118        return data
-
- - - - -
-
- -
- - def - sign_blob( self, payload: Union[bytes, str, NoneType], service_account_email: Optional[str] = None, delegates: Optional[List[str]] = None, session: Optional[requests.sessions.Session] = None, timeout: int = 10) -> Dict[str, str]: - - - -
- -
121    def sign_blob(
-122        self, payload: Optional[Union[str, bytes]],
-123        service_account_email: Optional[str] = None,
-124        delegates: Optional[List[str]] = None,
-125        session: Optional[Session] = None,
-126        timeout: int = 10,
-127    ) -> Dict[str, str]:
-128        service_account_email = (
-129            service_account_email
-130            or self.service_account_email
-131        )
-132        if not service_account_email:
-133            raise TypeError(
-134                'sign_blob must have a valid '
-135                'service_account_email',
-136            )
-137
-138        resource_name = f'projects/-/serviceAccounts/{service_account_email}'
-139        url = f'{API_ROOT_IAM_CREDENTIALS}/{resource_name}:signBlob'
-140
-141        json_str = json.dumps({
-142            'delegates': delegates or [resource_name],
-143            'payload': encode(payload or '').decode('utf-8'),
-144        })
-145
-146        headers = self.headers()
-147        headers.update({
-148            'Content-Length': str(len(json_str)),
-149            'Content-Type': 'application/json',
-150        })
-151
-152        s = SyncSession(session) if session else self.session
-153
-154        resp = s.post(
-155            url=url, data=json_str, headers=headers,
-156            timeout=timeout,
-157        )
-158        data: Dict[str, Any] = resp.json()
-159        return data
-
- - - - -
-
- -
- - def - close(self) -> None: - - - -
- -
161    def close(self) -> None:
-162        self.session.close()
-
- - - - -
-
-
- -
- - class - Token: - - - -
- -
136class Token:
-137    # pylint: disable=too-many-instance-attributes
-138    def __init__(
-139        self, service_file: Optional[Union[str, IO[AnyStr]]] = None,
-140        session: Optional[Session] = None,
-141        scopes: Optional[List[str]] = None,
-142    ) -> None:
-143        self.service_data = get_service_data(service_file)
-144        if self.service_data:
-145            self.token_type = Type(self.service_data['type'])
-146            self.token_uri = self.service_data.get(
-147                'token_uri', 'https://oauth2.googleapis.com/token',
-148            )
-149        else:
-150            # At this point, all we can do is assume we're running somewhere
-151            # with default credentials, eg. GCE.
-152            self.token_type = Type.GCE_METADATA
-153            self.token_uri = GCE_ENDPOINT_TOKEN
-154
-155        self.session = SyncSession(session)
-156        self.scopes = ' '.join(scopes or [])
-157        if self.token_type == Type.SERVICE_ACCOUNT and not self.scopes:
-158            raise Exception(
-159                'scopes must be provided when token type is '
-160                'service account',
-161            )
-162
-163        self.access_token: Optional[str] = None
-164        self.access_token_duration = 0
-165        self.access_token_acquired_at = datetime.datetime(1970, 1, 1)
-166
-167        self.acquiring: Optional['asyncio.Future[Any]'] = None
-168
-169    def get_project(self) -> Optional[str]:
-170        project = (
-171            os.environ.get('GOOGLE_CLOUD_PROJECT')
-172            or os.environ.get('GCLOUD_PROJECT')
-173            or os.environ.get('APPLICATION_ID')
-174        )
-175
-176        if self.token_type == Type.GCE_METADATA:
-177            self.ensure_token()
-178            resp = self.session.get(
-179                GCE_ENDPOINT_PROJECT, timeout=10,
-180                headers=GCE_METADATA_HEADERS,
-181            )
-182
-183            if not project:
-184                try:
-185                    project = resp.text()
-186                except (AttributeError, TypeError):
-187                    project = str(resp.text)
-188
-189        elif self.token_type == Type.SERVICE_ACCOUNT:
-190            project = project or self.service_data.get('project_id')
-191
-192        return project
-193
-194    def get(self) -> Optional[str]:
-195        self.ensure_token()
-196        return self.access_token
-197
-198    def ensure_token(self) -> None:
-199        if self.acquiring and not self.acquiring.done():
-200            self.acquiring
-201            return
-202
-203        if self.access_token:
-204            now = datetime.datetime.utcnow()
-205            delta = (now - self.access_token_acquired_at).total_seconds()
-206            if delta <= self.access_token_duration / 2:
-207                return
-208
-209        self.acquiring = (self.acquire_access_token())
-210        self.acquiring
-211
-212    def _refresh_authorized_user(self, timeout: int) -> Response:
-213        payload = urlencode({
-214            'grant_type': 'refresh_token',
-215            'client_id': self.service_data['client_id'],
-216            'client_secret': self.service_data['client_secret'],
-217            'refresh_token': self.service_data['refresh_token'],
-218        })
-219
-220        resp: Response = self.session.post(  # type: ignore[assignment]
-221            url=self.token_uri, data=payload, headers=REFRESH_HEADERS,
-222            timeout=timeout,
-223        )
-224        return resp
-225
-226    def _refresh_gce_metadata(self, timeout: int) -> Response:
-227        resp: Response = self.session.get(  # type: ignore[assignment]
-228            url=self.token_uri, headers=GCE_METADATA_HEADERS, timeout=timeout,
-229        )
-230        return resp
-231
-232    def _refresh_service_account(self, timeout: int) -> Response:
-233        now = int(time.time())
-234        assertion_payload = {
-235            'aud': self.token_uri,
-236            'exp': now + GCLOUD_TOKEN_DURATION,
-237            'iat': now,
-238            'iss': self.service_data['client_email'],
-239            'scope': self.scopes,
-240        }
-241
-242        # N.B. algorithm='RS256' requires an extra 240MB in dependencies...
-243        assertion = jwt.encode(
-244            assertion_payload,
-245            self.service_data['private_key'],
-246            algorithm='RS256',
-247        )
-248        payload = urlencode({
-249            'assertion': assertion,
-250            'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer',
-251        })
-252
-253        resp: Response = self.session.post(  # type: ignore[assignment]
-254            self.token_uri, data=payload, headers=REFRESH_HEADERS,
-255            timeout=timeout,
-256        )
-257        return resp
-258
-259    @backoff.on_exception(backoff.expo, Exception, max_tries=5)
-260    def acquire_access_token(self, timeout: int = 10) -> None:
-261        if self.token_type == Type.AUTHORIZED_USER:
-262            resp = self._refresh_authorized_user(timeout=timeout)
-263        elif self.token_type == Type.GCE_METADATA:
-264            resp = self._refresh_gce_metadata(timeout=timeout)
-265        elif self.token_type == Type.SERVICE_ACCOUNT:
-266            resp = self._refresh_service_account(timeout=timeout)
-267        else:
-268            raise Exception(f'unsupported token type {self.token_type}')
-269
-270        content = resp.json()
-271
-272        self.access_token = str(content['access_token'])
-273        self.access_token_duration = int(content['expires_in'])
-274        self.access_token_acquired_at = datetime.datetime.utcnow()
-275        self.acquiring = None
-276
-277    def close(self) -> None:
-278        self.session.close()
-279
-280    def __enter__(self) -> 'Token':
-281        return self
-282
-283    def __exit__(self, *args: Any) -> None:
-284        self.close()
-
- - - - -
- -
- - Token( service_file: Union[str, IO[~AnyStr], NoneType] = None, session: Optional[requests.sessions.Session] = None, scopes: Optional[List[str]] = None) - - - -
- -
138    def __init__(
-139        self, service_file: Optional[Union[str, IO[AnyStr]]] = None,
-140        session: Optional[Session] = None,
-141        scopes: Optional[List[str]] = None,
-142    ) -> None:
-143        self.service_data = get_service_data(service_file)
-144        if self.service_data:
-145            self.token_type = Type(self.service_data['type'])
-146            self.token_uri = self.service_data.get(
-147                'token_uri', 'https://oauth2.googleapis.com/token',
-148            )
-149        else:
-150            # At this point, all we can do is assume we're running somewhere
-151            # with default credentials, eg. GCE.
-152            self.token_type = Type.GCE_METADATA
-153            self.token_uri = GCE_ENDPOINT_TOKEN
-154
-155        self.session = SyncSession(session)
-156        self.scopes = ' '.join(scopes or [])
-157        if self.token_type == Type.SERVICE_ACCOUNT and not self.scopes:
-158            raise Exception(
-159                'scopes must be provided when token type is '
-160                'service account',
-161            )
-162
-163        self.access_token: Optional[str] = None
-164        self.access_token_duration = 0
-165        self.access_token_acquired_at = datetime.datetime(1970, 1, 1)
-166
-167        self.acquiring: Optional['asyncio.Future[Any]'] = None
-
- - - - -
-
-
- service_data - - -
- - - - -
-
-
- session - - -
- - - - -
-
-
- scopes - - -
- - - - -
-
-
- access_token: Optional[str] - - -
- - - - -
-
-
- access_token_duration - - -
- - - - -
-
-
- access_token_acquired_at - - -
- - - - -
-
-
- acquiring: Optional[_asyncio.Future[Any]] - - -
- - - - -
-
- -
- - def - get_project(self) -> Optional[str]: - - - -
- -
169    def get_project(self) -> Optional[str]:
-170        project = (
-171            os.environ.get('GOOGLE_CLOUD_PROJECT')
-172            or os.environ.get('GCLOUD_PROJECT')
-173            or os.environ.get('APPLICATION_ID')
-174        )
-175
-176        if self.token_type == Type.GCE_METADATA:
-177            self.ensure_token()
-178            resp = self.session.get(
-179                GCE_ENDPOINT_PROJECT, timeout=10,
-180                headers=GCE_METADATA_HEADERS,
-181            )
-182
-183            if not project:
-184                try:
-185                    project = resp.text()
-186                except (AttributeError, TypeError):
-187                    project = str(resp.text)
-188
-189        elif self.token_type == Type.SERVICE_ACCOUNT:
-190            project = project or self.service_data.get('project_id')
-191
-192        return project
-
- - - - -
-
- -
- - def - get(self) -> Optional[str]: - - - -
- -
194    def get(self) -> Optional[str]:
-195        self.ensure_token()
-196        return self.access_token
-
- - - - -
-
- -
- - def - ensure_token(self) -> None: - - - -
- -
198    def ensure_token(self) -> None:
-199        if self.acquiring and not self.acquiring.done():
-200            self.acquiring
-201            return
-202
-203        if self.access_token:
-204            now = datetime.datetime.utcnow()
-205            delta = (now - self.access_token_acquired_at).total_seconds()
-206            if delta <= self.access_token_duration / 2:
-207                return
-208
-209        self.acquiring = (self.acquire_access_token())
-210        self.acquiring
-
- - - - -
-
- -
-
@backoff.on_exception(backoff.expo, Exception, max_tries=5)
- - def - acquire_access_token(self, timeout: int = 10) -> None: - - - -
- -
259    @backoff.on_exception(backoff.expo, Exception, max_tries=5)
-260    def acquire_access_token(self, timeout: int = 10) -> None:
-261        if self.token_type == Type.AUTHORIZED_USER:
-262            resp = self._refresh_authorized_user(timeout=timeout)
-263        elif self.token_type == Type.GCE_METADATA:
-264            resp = self._refresh_gce_metadata(timeout=timeout)
-265        elif self.token_type == Type.SERVICE_ACCOUNT:
-266            resp = self._refresh_service_account(timeout=timeout)
-267        else:
-268            raise Exception(f'unsupported token type {self.token_type}')
-269
-270        content = resp.json()
-271
-272        self.access_token = str(content['access_token'])
-273        self.access_token_duration = int(content['expires_in'])
-274        self.access_token_acquired_at = datetime.datetime.utcnow()
-275        self.acquiring = None
-
- - - - -
-
- -
- - def - close(self) -> None: - - - -
- -
277    def close(self) -> None:
-278        self.session.close()
-
- - - - -
-
-
-
- __version__ = -'4.2.3' - - -
- - - - -
-
- -
- - def - decode(payload: str) -> bytes: - - - -
- -
 6def decode(payload: str) -> bytes:
- 7    """
- 8    Modified Base64 for URL variants exist, where the + and / characters of
- 9    standard Base64 are respectively replaced by - and _.
-10
-11    See https://en.wikipedia.org/wiki/Base64#URL_applications
-12    """
-13    return base64.b64decode(payload, altchars=b'-_')
-
- - -

Modified Base64 for URL variants exist, where the + and / characters of -standard Base64 are respectively replaced by - and _.

- -

See https://en.wikipedia.org/wiki/Base64#URL_applications

-
- - -
-
- -
- - def - encode(payload: Union[bytes, str]) -> bytes: - - - -
- -
16def encode(payload: Union[bytes, str]) -> bytes:
-17    """
-18    Modified Base64 for URL variants exist, where the + and / characters of
-19    standard Base64 are respectively replaced by - and _.
-20
-21    See https://en.wikipedia.org/wiki/Base64#URL_applications
-22    """
-23    if isinstance(payload, str):
-24        payload = payload.encode('utf-8')
-25
-26    return base64.b64encode(payload, altchars=b'-_')
-
- - -

Modified Base64 for URL variants exist, where the + and / characters of -standard Base64 are respectively replaced by - and _.

- -

See https://en.wikipedia.org/wiki/Base64#URL_applications

-
- - -
-
- - \ No newline at end of file diff --git a/search.js b/search.js index 525310ed0..24a328e54 100644 --- a/search.js +++ b/search.js @@ -1,6 +1,6 @@ window.pdocSearch = (function(){ /** elasticlunr - http://weixsong.github.io * Copyright (C) 2017 Oliver Nightingale * Copyright (C) 2017 Wei Song * MIT Licensed */!function(){function e(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.9.5",lunr=t,t.utils={},t.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),t.utils.toString=function(e){return void 0===e||null===e?"":e.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},t.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);-1!==n&&(this.events[e].splice(n,1),0==this.events[e].length&&delete this.events[e])}},t.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},t.EventEmitter.prototype.hasHandler=function(e){return e in this.events},t.tokenizer=function(e){if(!arguments.length||null===e||void 0===e)return[];if(Array.isArray(e)){var n=e.filter(function(e){return null===e||void 0===e?!1:!0});n=n.map(function(e){return t.utils.toString(e).toLowerCase()});var i=[];return n.forEach(function(e){var n=e.split(t.tokenizer.seperator);i=i.concat(n)},this),i}return e.toString().trim().toLowerCase().split(t.tokenizer.seperator)},t.tokenizer.defaultSeperator=/[\s\-]+/,t.tokenizer.seperator=t.tokenizer.defaultSeperator,t.tokenizer.setSeperator=function(e){null!==e&&void 0!==e&&"object"==typeof e&&(t.tokenizer.seperator=e)},t.tokenizer.resetSeperator=function(){t.tokenizer.seperator=t.tokenizer.defaultSeperator},t.tokenizer.getSeperator=function(){return t.tokenizer.seperator},t.Pipeline=function(){this._queue=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in t.Pipeline.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[n]=e},t.Pipeline.getRegisteredFunction=function(e){return e in t.Pipeline.registeredFunctions!=!0?null:t.Pipeline.registeredFunctions[e]},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.getRegisteredFunction(e);if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i+1,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i,0,n)},t.Pipeline.prototype.remove=function(e){var t=this._queue.indexOf(e);-1!==t&&this._queue.splice(t,1)},t.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,i=this._queue.length,o=0;n>o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},t.Pipeline.prototype.reset=function(){this._queue=[]},t.Pipeline.prototype.get=function(){return this._queue},t.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.DocumentStore,this.index={},this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},t.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;n._fields=e.fields,n._ref=e.ref,n.documentStore=t.DocumentStore.load(e.documentStore),n.pipeline=t.Pipeline.load(e.pipeline),n.index={};for(var i in e.index)n.index[i]=t.InvertedIndex.load(e.index[i]);return n},t.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new t.InvertedIndex,this},t.Index.prototype.setRef=function(e){return this._ref=e,this},t.Index.prototype.saveDocument=function(e){return this.documentStore=new t.DocumentStore(e),this},t.Index.prototype.addDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.addDoc(i,e),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",e,this)}},t.Index.prototype.removeDocByRef=function(e){if(e&&this.documentStore.isDocStored()!==!1&&this.documentStore.hasDoc(e)){var t=this.documentStore.getDoc(e);this.removeDoc(t,!1)}},t.Index.prototype.removeDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",e,this))}},t.Index.prototype.updateDoc=function(e,t){var t=void 0===t?!0:t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},t.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},t.Index.prototype.getFields=function(){return this._fields.slice()},t.Index.prototype.search=function(e,n){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var i=null;null!=n&&(i=JSON.stringify(n));for(var o=new t.Configuration(i,this.getFields()).get(),r={},s=Object.keys(e),u=0;u0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},t.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},t.Configuration=function(e,n){var e=e||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(e),this.buildUserConfig(i,n)}catch(o){t.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},t.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},t.Configuration.prototype.buildUserConfig=function(e,n){var i="OR",o=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(o=e.expand||o),"fields"in e)for(var r in e.fields)if(n.indexOf(r)>-1){var s=e.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||0===s.boost?s.boost:1,bool:s.bool||i,expand:u}}else t.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},t.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},t.Configuration.prototype.get=function(){return this.config},t.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){var e,t;for(e=0;e1;){if(r===e)return o;e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o]}return r===e?o:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;)e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o];return r>e?o:e>r?o+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,i=0,o=this.length,r=e.length,s=this.elements,u=e.elements;;){if(n>o-1||i>r-1)break;s[n]!==u[i]?s[n]u[i]&&i++:(t.add(s[n]),n++,i++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,i;this.length>=e.length?(t=this,n=e):(t=e,n=this),i=t.clone();for(var o=0,r=n.toArray();o

\n"}, {"fullname": "gcloud.aio", "modulename": "gcloud.aio", "kind": "module", "doc": "

\n"}, {"fullname": "gcloud.aio.auth", "modulename": "gcloud.aio.auth", "kind": "module", "doc": "

This library implements various methods for working with the Google IAM / auth\nAPIs. This includes authenticating for the purpose of using other Google APIs,\nmanaging service accounts and public keys, URL-signing blobs, etc.

\n\n

Installation

\n\n
\n
$ pip install --upgrade gcloud-aio-auth\n
\n
\n\n

Usage

\n\n
\n
from gcloud.aio.auth import IamClient\nfrom gcloud.aio.auth import Token\n\n\nclient = IamClient()\npubkeys = await client.list_public_keys()\n\ntoken = Token()\nprint(await token.get())\n
\n
\n\n

Additionally, the Token constructor accepts the following optional arguments:

\n\n
    \n
  • service_file: path to a service account authorized user\nfile, or any other application credentials. Alternatively, you can pass a\nfile-like object, like an io.StringIO instance, in case your credentials\nare not stored in a file but in memory. If omitted, will attempt to find one\non your path or fallback to generating a token from GCE metadata.
  • \n
  • session: an aiohttp.ClientSession instance to be used for all requests.\nIf omitted, a default session will be created. If you use the default\nsession, you may be interested in using Token() as a context manager\n(async with Token(..) as token:) or explicitly calling the Token.close()\nmethod to ensure the session is cleaned up appropriately.
  • \n
  • scopes: an optional list of GCP scopes_ for which to generate our token.\nOnly valid (and required!) for service account\nauthentication.
  • \n
\n"}, {"fullname": "gcloud.aio.auth.AioSession", "modulename": "gcloud.aio.auth", "qualname": "AioSession", "kind": "class", "doc": "

\n", "bases": "gcloud.aio.auth.session.BaseSession"}, {"fullname": "gcloud.aio.auth.AioSession.session", "modulename": "gcloud.aio.auth", "qualname": "AioSession.session", "kind": "variable", "doc": "

\n", "annotation": ": aiohttp.client.ClientSession"}, {"fullname": "gcloud.aio.auth.AioSession.post", "modulename": "gcloud.aio.auth", "qualname": "AioSession.post", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Mapping[str, str],\tdata: Union[bytes, str, IO[~AnyStr], NoneType] = None,\ttimeout: Union[aiohttp.client.ClientTimeout, float] = 10,\tparams: Optional[Mapping[str, Union[int, str]]] = None) -> aiohttp.client_reqrep.ClientResponse:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.AioSession.get", "modulename": "gcloud.aio.auth", "qualname": "AioSession.get", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Optional[Mapping[str, str]] = None,\ttimeout: Union[aiohttp.client.ClientTimeout, float] = 10,\tparams: Optional[Mapping[str, Union[int, str]]] = None,\tstream: Optional[bool] = None) -> aiohttp.client_reqrep.ClientResponse:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.AioSession.patch", "modulename": "gcloud.aio.auth", "qualname": "AioSession.patch", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Mapping[str, str],\tdata: Union[bytes, str, NoneType] = None,\ttimeout: Union[aiohttp.client.ClientTimeout, float] = 10,\tparams: Optional[Mapping[str, Union[int, str]]] = None) -> aiohttp.client_reqrep.ClientResponse:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.AioSession.put", "modulename": "gcloud.aio.auth", "qualname": "AioSession.put", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Mapping[str, str],\tdata: Union[bytes, str, IO[Any]],\ttimeout: Union[aiohttp.client.ClientTimeout, float] = 10) -> aiohttp.client_reqrep.ClientResponse:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.AioSession.delete", "modulename": "gcloud.aio.auth", "qualname": "AioSession.delete", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Mapping[str, str],\tparams: Optional[Mapping[str, Union[int, str]]] = None,\ttimeout: Union[aiohttp.client.ClientTimeout, float] = 10) -> aiohttp.client_reqrep.ClientResponse:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.AioSession.request", "modulename": "gcloud.aio.auth", "qualname": "AioSession.request", "kind": "function", "doc": "

\n", "signature": "(\tself,\tmethod: str,\turl: str,\theaders: Mapping[str, str],\tauto_raise_for_status: bool = True,\t**kwargs: Any) -> aiohttp.client_reqrep.ClientResponse:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.AioSession.close", "modulename": "gcloud.aio.auth", "qualname": "AioSession.close", "kind": "function", "doc": "

\n", "signature": "(self) -> None:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.BUILD_GCLOUD_REST", "modulename": "gcloud.aio.auth", "qualname": "BUILD_GCLOUD_REST", "kind": "variable", "doc": "

\n", "default_value": "False"}, {"fullname": "gcloud.aio.auth.IamClient", "modulename": "gcloud.aio.auth", "qualname": "IamClient", "kind": "class", "doc": "

\n"}, {"fullname": "gcloud.aio.auth.IamClient.__init__", "modulename": "gcloud.aio.auth", "qualname": "IamClient.__init__", "kind": "function", "doc": "

\n", "signature": "(\tservice_file: Union[str, IO[~AnyStr], NoneType] = None,\tsession: Optional[aiohttp.client.ClientSession] = None,\ttoken: Optional[gcloud.aio.auth.token.Token] = None)"}, {"fullname": "gcloud.aio.auth.IamClient.session", "modulename": "gcloud.aio.auth", "qualname": "IamClient.session", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.aio.auth.IamClient.token", "modulename": "gcloud.aio.auth", "qualname": "IamClient.token", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.aio.auth.IamClient.headers", "modulename": "gcloud.aio.auth", "qualname": "IamClient.headers", "kind": "function", "doc": "

\n", "signature": "(self) -> Dict[str, str]:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.IamClient.service_account_email", "modulename": "gcloud.aio.auth", "qualname": "IamClient.service_account_email", "kind": "variable", "doc": "

\n", "annotation": ": Optional[str]"}, {"fullname": "gcloud.aio.auth.IamClient.get_public_key", "modulename": "gcloud.aio.auth", "qualname": "IamClient.get_public_key", "kind": "function", "doc": "

\n", "signature": "(\tself,\tkey_id: Optional[str] = None,\tkey: Optional[str] = None,\tservice_account_email: Optional[str] = None,\tproject: Optional[str] = None,\tsession: Optional[aiohttp.client.ClientSession] = None,\ttimeout: int = 10) -> Dict[str, str]:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.IamClient.list_public_keys", "modulename": "gcloud.aio.auth", "qualname": "IamClient.list_public_keys", "kind": "function", "doc": "

\n", "signature": "(\tself,\tservice_account_email: Optional[str] = None,\tproject: Optional[str] = None,\tsession: Optional[aiohttp.client.ClientSession] = None,\ttimeout: int = 10) -> List[Dict[str, str]]:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.IamClient.sign_blob", "modulename": "gcloud.aio.auth", "qualname": "IamClient.sign_blob", "kind": "function", "doc": "

\n", "signature": "(\tself,\tpayload: Union[bytes, str, NoneType],\tservice_account_email: Optional[str] = None,\tdelegates: Optional[List[str]] = None,\tsession: Optional[aiohttp.client.ClientSession] = None,\ttimeout: int = 10) -> Dict[str, str]:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.IamClient.close", "modulename": "gcloud.aio.auth", "qualname": "IamClient.close", "kind": "function", "doc": "

\n", "signature": "(self) -> None:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.Token", "modulename": "gcloud.aio.auth", "qualname": "Token", "kind": "class", "doc": "

\n"}, {"fullname": "gcloud.aio.auth.Token.__init__", "modulename": "gcloud.aio.auth", "qualname": "Token.__init__", "kind": "function", "doc": "

\n", "signature": "(\tservice_file: Union[str, IO[~AnyStr], NoneType] = None,\tsession: Optional[aiohttp.client.ClientSession] = None,\tscopes: Optional[List[str]] = None)"}, {"fullname": "gcloud.aio.auth.Token.service_data", "modulename": "gcloud.aio.auth", "qualname": "Token.service_data", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.aio.auth.Token.session", "modulename": "gcloud.aio.auth", "qualname": "Token.session", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.aio.auth.Token.scopes", "modulename": "gcloud.aio.auth", "qualname": "Token.scopes", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.aio.auth.Token.access_token", "modulename": "gcloud.aio.auth", "qualname": "Token.access_token", "kind": "variable", "doc": "

\n", "annotation": ": Optional[str]"}, {"fullname": "gcloud.aio.auth.Token.access_token_duration", "modulename": "gcloud.aio.auth", "qualname": "Token.access_token_duration", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.aio.auth.Token.access_token_acquired_at", "modulename": "gcloud.aio.auth", "qualname": "Token.access_token_acquired_at", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.aio.auth.Token.acquiring", "modulename": "gcloud.aio.auth", "qualname": "Token.acquiring", "kind": "variable", "doc": "

\n", "annotation": ": Optional[_asyncio.Future[Any]]"}, {"fullname": "gcloud.aio.auth.Token.get_project", "modulename": "gcloud.aio.auth", "qualname": "Token.get_project", "kind": "function", "doc": "

\n", "signature": "(self) -> Optional[str]:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.Token.get", "modulename": "gcloud.aio.auth", "qualname": "Token.get", "kind": "function", "doc": "

\n", "signature": "(self) -> Optional[str]:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.Token.ensure_token", "modulename": "gcloud.aio.auth", "qualname": "Token.ensure_token", "kind": "function", "doc": "

\n", "signature": "(self) -> None:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.Token.acquire_access_token", "modulename": "gcloud.aio.auth", "qualname": "Token.acquire_access_token", "kind": "function", "doc": "

\n", "signature": "(self, timeout: int = 10) -> None:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.Token.close", "modulename": "gcloud.aio.auth", "qualname": "Token.close", "kind": "function", "doc": "

\n", "signature": "(self) -> None:", "funcdef": "async def"}, {"fullname": "gcloud.aio.auth.decode", "modulename": "gcloud.aio.auth", "qualname": "decode", "kind": "function", "doc": "

Modified Base64 for URL variants exist, where the + and / characters of\nstandard Base64 are respectively replaced by - and _.

\n\n

See https://en.wikipedia.org/wiki/Base64#URL_applications

\n", "signature": "(payload: str) -> bytes:", "funcdef": "def"}, {"fullname": "gcloud.aio.auth.encode", "modulename": "gcloud.aio.auth", "qualname": "encode", "kind": "function", "doc": "

Modified Base64 for URL variants exist, where the + and / characters of\nstandard Base64 are respectively replaced by - and _.

\n\n

See https://en.wikipedia.org/wiki/Base64#URL_applications

\n", "signature": "(payload: Union[bytes, str]) -> bytes:", "funcdef": "def"}, {"fullname": "gcloud.rest", "modulename": "gcloud.rest", "kind": "module", "doc": "

\n"}, {"fullname": "gcloud.rest.auth", "modulename": "gcloud.rest.auth", "kind": "module", "doc": "

This library implements various methods for working with the Google IAM / auth\nAPIs. This includes authenticating for the purpose of using other Google APIs,\nmanaging service accounts and public keys, URL-signing blobs, etc.

\n\n

Installation

\n\n
\n
$ pip install --upgrade gcloud-rest-auth\n
\n
\n\n

Usage

\n\n
\n
from gcloud.rest.auth import IamClient\nfrom gcloud.rest.auth import Token\n\n\nclient = IamClient()\npubkeys = client.list_public_keys()\n\ntoken = Token()\nprint(token.get())\n
\n
\n\n

Additionally, the Token constructor accepts the following optional arguments:

\n\n
    \n
  • service_file: path to a service account authorized user\nfile, or any other application credentials. Alternatively, you can pass a\nfile-like object, like an io.StringIO instance, in case your credentials\nare not stored in a file but in memory. If omitted, will attempt to find one\non your path or fallback to generating a token from GCE metadata.
  • \n
  • session: an aiohttp.ClientSession instance to be used for all requests.\nIf omitted, a default session will be created. If you use the default\nsession, you may be interested in using Token() as a context manager\n(with Token(..) as token:) or explicitly calling the Token.close()\nmethod to ensure the session is cleaned up appropriately.
  • \n
  • scopes: an optional list of GCP scopes_ for which to generate our token.\nOnly valid (and required!) for service account\nauthentication.
  • \n
\n"}, {"fullname": "gcloud.rest.auth.SyncSession", "modulename": "gcloud.rest.auth", "qualname": "SyncSession", "kind": "class", "doc": "

\n", "bases": "gcloud.rest.auth.session.BaseSession"}, {"fullname": "gcloud.rest.auth.SyncSession.google_api_lock", "modulename": "gcloud.rest.auth", "qualname": "SyncSession.google_api_lock", "kind": "variable", "doc": "

\n", "annotation": ": <function RLock at 0x7f5241c51300>"}, {"fullname": "gcloud.rest.auth.SyncSession.session", "modulename": "gcloud.rest.auth", "qualname": "SyncSession.session", "kind": "variable", "doc": "

\n", "annotation": ": requests.sessions.Session"}, {"fullname": "gcloud.rest.auth.SyncSession.post", "modulename": "gcloud.rest.auth", "qualname": "SyncSession.post", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Mapping[str, str],\tdata: Union[bytes, str, IO[~AnyStr], NoneType] = None,\ttimeout: float = 10,\tparams: Optional[Mapping[str, Union[int, str]]] = None) -> requests.models.Response:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.SyncSession.get", "modulename": "gcloud.rest.auth", "qualname": "SyncSession.get", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Optional[Mapping[str, str]] = None,\ttimeout: float = 10,\tparams: Optional[Mapping[str, Union[int, str]]] = None,\tstream: bool = False) -> requests.models.Response:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.SyncSession.patch", "modulename": "gcloud.rest.auth", "qualname": "SyncSession.patch", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Mapping[str, str],\tdata: Union[bytes, str, NoneType] = None,\ttimeout: float = 10,\tparams: Optional[Mapping[str, Union[int, str]]] = None) -> requests.models.Response:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.SyncSession.put", "modulename": "gcloud.rest.auth", "qualname": "SyncSession.put", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Mapping[str, str],\tdata: Union[bytes, str, IO[Any]],\ttimeout: float = 10) -> requests.models.Response:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.SyncSession.delete", "modulename": "gcloud.rest.auth", "qualname": "SyncSession.delete", "kind": "function", "doc": "

\n", "signature": "(\tself,\turl: str,\theaders: Mapping[str, str],\tparams: Optional[Mapping[str, Union[int, str]]] = None,\ttimeout: float = 10) -> requests.models.Response:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.SyncSession.request", "modulename": "gcloud.rest.auth", "qualname": "SyncSession.request", "kind": "function", "doc": "

\n", "signature": "(\tself,\tmethod: str,\turl: str,\theaders: Mapping[str, str],\tauto_raise_for_status: bool = True,\t**kwargs: Any) -> requests.models.Response:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.SyncSession.close", "modulename": "gcloud.rest.auth", "qualname": "SyncSession.close", "kind": "function", "doc": "

\n", "signature": "(self) -> None:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.BUILD_GCLOUD_REST", "modulename": "gcloud.rest.auth", "qualname": "BUILD_GCLOUD_REST", "kind": "variable", "doc": "

\n", "default_value": "True"}, {"fullname": "gcloud.rest.auth.IamClient", "modulename": "gcloud.rest.auth", "qualname": "IamClient", "kind": "class", "doc": "

\n"}, {"fullname": "gcloud.rest.auth.IamClient.__init__", "modulename": "gcloud.rest.auth", "qualname": "IamClient.__init__", "kind": "function", "doc": "

\n", "signature": "(\tservice_file: Union[str, IO[~AnyStr], NoneType] = None,\tsession: Optional[requests.sessions.Session] = None,\ttoken: Optional[gcloud.rest.auth.token.Token] = None)"}, {"fullname": "gcloud.rest.auth.IamClient.session", "modulename": "gcloud.rest.auth", "qualname": "IamClient.session", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.rest.auth.IamClient.token", "modulename": "gcloud.rest.auth", "qualname": "IamClient.token", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.rest.auth.IamClient.headers", "modulename": "gcloud.rest.auth", "qualname": "IamClient.headers", "kind": "function", "doc": "

\n", "signature": "(self) -> Dict[str, str]:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.IamClient.service_account_email", "modulename": "gcloud.rest.auth", "qualname": "IamClient.service_account_email", "kind": "variable", "doc": "

\n", "annotation": ": Optional[str]"}, {"fullname": "gcloud.rest.auth.IamClient.get_public_key", "modulename": "gcloud.rest.auth", "qualname": "IamClient.get_public_key", "kind": "function", "doc": "

\n", "signature": "(\tself,\tkey_id: Optional[str] = None,\tkey: Optional[str] = None,\tservice_account_email: Optional[str] = None,\tproject: Optional[str] = None,\tsession: Optional[requests.sessions.Session] = None,\ttimeout: int = 10) -> Dict[str, str]:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.IamClient.list_public_keys", "modulename": "gcloud.rest.auth", "qualname": "IamClient.list_public_keys", "kind": "function", "doc": "

\n", "signature": "(\tself,\tservice_account_email: Optional[str] = None,\tproject: Optional[str] = None,\tsession: Optional[requests.sessions.Session] = None,\ttimeout: int = 10) -> List[Dict[str, str]]:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.IamClient.sign_blob", "modulename": "gcloud.rest.auth", "qualname": "IamClient.sign_blob", "kind": "function", "doc": "

\n", "signature": "(\tself,\tpayload: Union[bytes, str, NoneType],\tservice_account_email: Optional[str] = None,\tdelegates: Optional[List[str]] = None,\tsession: Optional[requests.sessions.Session] = None,\ttimeout: int = 10) -> Dict[str, str]:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.IamClient.close", "modulename": "gcloud.rest.auth", "qualname": "IamClient.close", "kind": "function", "doc": "

\n", "signature": "(self) -> None:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.Token", "modulename": "gcloud.rest.auth", "qualname": "Token", "kind": "class", "doc": "

\n"}, {"fullname": "gcloud.rest.auth.Token.__init__", "modulename": "gcloud.rest.auth", "qualname": "Token.__init__", "kind": "function", "doc": "

\n", "signature": "(\tservice_file: Union[str, IO[~AnyStr], NoneType] = None,\tsession: Optional[requests.sessions.Session] = None,\tscopes: Optional[List[str]] = None)"}, {"fullname": "gcloud.rest.auth.Token.service_data", "modulename": "gcloud.rest.auth", "qualname": "Token.service_data", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.rest.auth.Token.session", "modulename": "gcloud.rest.auth", "qualname": "Token.session", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.rest.auth.Token.scopes", "modulename": "gcloud.rest.auth", "qualname": "Token.scopes", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.rest.auth.Token.access_token", "modulename": "gcloud.rest.auth", "qualname": "Token.access_token", "kind": "variable", "doc": "

\n", "annotation": ": Optional[str]"}, {"fullname": "gcloud.rest.auth.Token.access_token_duration", "modulename": "gcloud.rest.auth", "qualname": "Token.access_token_duration", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.rest.auth.Token.access_token_acquired_at", "modulename": "gcloud.rest.auth", "qualname": "Token.access_token_acquired_at", "kind": "variable", "doc": "

\n"}, {"fullname": "gcloud.rest.auth.Token.acquiring", "modulename": "gcloud.rest.auth", "qualname": "Token.acquiring", "kind": "variable", "doc": "

\n", "annotation": ": Optional[_asyncio.Future[Any]]"}, {"fullname": "gcloud.rest.auth.Token.get_project", "modulename": "gcloud.rest.auth", "qualname": "Token.get_project", "kind": "function", "doc": "

\n", "signature": "(self) -> Optional[str]:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.Token.get", "modulename": "gcloud.rest.auth", "qualname": "Token.get", "kind": "function", "doc": "

\n", "signature": "(self) -> Optional[str]:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.Token.ensure_token", "modulename": "gcloud.rest.auth", "qualname": "Token.ensure_token", "kind": "function", "doc": "

\n", "signature": "(self) -> None:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.Token.acquire_access_token", "modulename": "gcloud.rest.auth", "qualname": "Token.acquire_access_token", "kind": "function", "doc": "

\n", "signature": "(self, timeout: int = 10) -> None:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.Token.close", "modulename": "gcloud.rest.auth", "qualname": "Token.close", "kind": "function", "doc": "

\n", "signature": "(self) -> None:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.decode", "modulename": "gcloud.rest.auth", "qualname": "decode", "kind": "function", "doc": "

Modified Base64 for URL variants exist, where the + and / characters of\nstandard Base64 are respectively replaced by - and _.

\n\n

See https://en.wikipedia.org/wiki/Base64#URL_applications

\n", "signature": "(payload: str) -> bytes:", "funcdef": "def"}, {"fullname": "gcloud.rest.auth.encode", "modulename": "gcloud.rest.auth", "qualname": "encode", "kind": "function", "doc": "

Modified Base64 for URL variants exist, where the + and / characters of\nstandard Base64 are respectively replaced by - and _.

\n\n

See https://en.wikipedia.org/wiki/Base64#URL_applications

\n", "signature": "(payload: Union[bytes, str]) -> bytes:", "funcdef": "def"}]; + /** pdoc search index */const docs = [{"fullname": "gcloud", "modulename": "gcloud", "kind": "module", "doc": "

\n"}]; // mirrored in build-search-index.js (part 1) // Also split on html tags. this is a cheap heuristic, but good enough.