Skip to content
Prev Previous commit
Next Next commit
chore: reorganize docstrings
  • Loading branch information
busunkim96 committed Jun 24, 2020
commit 4aade17be0914b8d8dd00bc5360fef23155ae444
4 changes: 1 addition & 3 deletions google/auth/_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ def default(scopes=None, request=None, quota_project_id=None):
for checker in checkers:
credentials, project_id = checker()
if credentials is not None:
credentials = with_scopes_if_required(credentials, scopes)
if quota_project_id:
credentials = credentials.with_quota_project_id(quota_project_id)
credentials = with_scopes_if_required(credentials, scopes).with_quota_project_id(quota_project_id)
effective_project_id = explicit_project_id or project_id
if not effective_project_id:
_LOGGER.warning(
Expand Down
5 changes: 2 additions & 3 deletions google/auth/app_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ def __init__(self, scopes=None, service_account_id=None, quota_project_id=None):
:func:`google.appengine.api.app_identity.get_access_token`.
If not specified, the default application service account
ID will be used.
quota_project_id (Optional[str]): The project ID used for quota and billing.
This project may be different from the project used to
create the credentials.
quota_project_id (Optional[str]): The project ID used for quota
and billing.

Raises:
EnvironmentError: If the App Engine APIs are unavailable.
Expand Down
11 changes: 4 additions & 7 deletions google/auth/compute_engine/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ def __init__(self, service_account_email="default", quota_project_id=None):
service_account_email (str): The service account email to use, or
'default'. A Compute Engine instance may have multiple service
accounts.
quota_project_id (Optional[str]): The project ID used for quota and billing.
This project may be different from the project used to
create the credentials.
quota_project_id (Optional[str]): The project ID used for quota and
billing.
"""
super(Credentials, self).__init__()
self._service_account_email = service_account_email
Expand Down Expand Up @@ -121,7 +120,6 @@ def requires_scopes(self):

@_helpers.copy_docstring(credentials.Credentials)
def with_quota_project(self, quota_project_id):

return self.__class__(
service_account=self._service_account_email,
quota_project_id=quota_project_id,
Expand Down Expand Up @@ -178,9 +176,8 @@ def __init__(
is False. If set to True, ``token_uri``, ``additional_claims``,
``service_account_email``, ``signer`` argument should not be set;
otherwise ValueError will be raised.
quota_project_id (Optional[str]): The project ID used for quota and billing.
This project may be different from the project used to
create the credentials.
quota_project_id (Optional[str]): The project ID used for quota and
billing.

Raises:
ValueError:
Expand Down
2 changes: 1 addition & 1 deletion google/auth/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def with_quota_project(self, quota_project_id):

Args:
quota_project_id (str): The project to use for quota and
billing purposes
billing purposes

Returns:
google.oauth2.credentials.Credentials: A new credentials instance.
Expand Down
9 changes: 7 additions & 2 deletions google/auth/impersonated_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,19 +339,24 @@ def __init__(

def from_credentials(self, target_credentials, target_audience=None):
return self.__class__(
target_credentials=self._target_credentials, target_audience=target_audience
target_credentials=self._target_credentials,
target_audience=target_audience,
quota_project_id=self._quota_project_id,
)

def with_target_audience(self, target_audience):
return self.__class__(
target_credentials=self._target_credentials, target_audience=target_audience
target_credentials=self._target_credentials,
target_audience=target_audience,
quota_project_id=self._quota_project_id,
)

def with_include_email(self, include_email):
return self.__class__(
target_credentials=self._target_credentials,
target_audience=self._target_audience,
include_email=include_email,
quota_project_id=self._quota_project_id,
)

@_helpers.copy_docstring(credentials.Credentials)
Expand Down
3 changes: 2 additions & 1 deletion google/auth/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def __init__(
the JWT payload.
token_lifetime (int): The amount of time in seconds for
which the token is valid. Defaults to 1 hour.
quota_project_id (Optional[str]): The project ID used for quota and billing.
quota_project_id (Optional[str]): The project ID used for quota
and billing.
"""
super(Credentials, self).__init__()
self._signer = signer
Expand Down
2 changes: 2 additions & 0 deletions google/oauth2/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ def with_account(self, account):

Args:
account (str): Account to get the access token for.
quota_project_id (Optional[str]): The project ID used for quota
and billing.

Returns:
google.oauth2.credentials.UserAccessTokenCredentials: The created
Expand Down
2 changes: 1 addition & 1 deletion tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def refresh(self, request):
self.token = request

def with_quota_project(self, quota_project_id):
self._quota_project_id = quota_project_id
pass


def test_credentials_constructor():
Expand Down