Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,27 @@ async def generate_access_token(
r"""Generates an OAuth 2.0 access token for a service
account.


.. code-block::

from google.cloud import iam_credentials_v1

def sample_generate_access_token():
# Create a client
client = iam_credentials_v1.IAMCredentialsClient()

# Initialize request argument(s)
request = iam_credentials_v1.GenerateAccessTokenRequest(
name="name_value",
scope=['scope_value_1', 'scope_value_2'],
)

# Make the request
response = client.generate_access_token(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.iam_credentials_v1.types.GenerateAccessTokenRequest, dict]):
The request object.
Expand Down Expand Up @@ -362,6 +383,27 @@ async def generate_id_token(
r"""Generates an OpenID Connect ID token for a service
account.


.. code-block::

from google.cloud import iam_credentials_v1

def sample_generate_id_token():
# Create a client
client = iam_credentials_v1.IAMCredentialsClient()

# Initialize request argument(s)
request = iam_credentials_v1.GenerateIdTokenRequest(
name="name_value",
audience="audience_value",
)

# Make the request
response = client.generate_id_token(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.iam_credentials_v1.types.GenerateIdTokenRequest, dict]):
The request object.
Expand Down Expand Up @@ -487,6 +529,27 @@ async def sign_blob(
r"""Signs a blob using a service account's system-managed
private key.


.. code-block::

from google.cloud import iam_credentials_v1

def sample_sign_blob():
# Create a client
client = iam_credentials_v1.IAMCredentialsClient()

# Initialize request argument(s)
request = iam_credentials_v1.SignBlobRequest(
name="name_value",
payload=b'payload_blob',
)

# Make the request
response = client.sign_blob(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.iam_credentials_v1.types.SignBlobRequest, dict]):
The request object.
Expand Down Expand Up @@ -599,6 +662,27 @@ async def sign_jwt(
r"""Signs a JWT using a service account's system-managed
private key.


.. code-block::

from google.cloud import iam_credentials_v1

def sample_sign_jwt():
# Create a client
client = iam_credentials_v1.IAMCredentialsClient()

# Initialize request argument(s)
request = iam_credentials_v1.SignJwtRequest(
name="name_value",
payload="payload_value",
)

# Make the request
response = client.sign_jwt(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.iam_credentials_v1.types.SignJwtRequest, dict]):
The request object.
Expand Down
88 changes: 88 additions & 0 deletions google/cloud/iam_credentials_v1/services/iam_credentials/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,28 @@ def generate_access_token(
r"""Generates an OAuth 2.0 access token for a service
account.



.. code-block::

from google.cloud import iam_credentials_v1

def sample_generate_access_token():
# Create a client
client = iam_credentials_v1.IAMCredentialsClient()

# Initialize request argument(s)
request = iam_credentials_v1.GenerateAccessTokenRequest(
name="name_value",
scope=['scope_value_1', 'scope_value_2'],
)

# Make the request
response = client.generate_access_token(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.iam_credentials_v1.types.GenerateAccessTokenRequest, dict]):
The request object.
Expand Down Expand Up @@ -547,6 +569,28 @@ def generate_id_token(
r"""Generates an OpenID Connect ID token for a service
account.



.. code-block::

from google.cloud import iam_credentials_v1

def sample_generate_id_token():
# Create a client
client = iam_credentials_v1.IAMCredentialsClient()

# Initialize request argument(s)
request = iam_credentials_v1.GenerateIdTokenRequest(
name="name_value",
audience="audience_value",
)

# Make the request
response = client.generate_id_token(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.iam_credentials_v1.types.GenerateIdTokenRequest, dict]):
The request object.
Expand Down Expand Up @@ -662,6 +706,28 @@ def sign_blob(
r"""Signs a blob using a service account's system-managed
private key.



.. code-block::

from google.cloud import iam_credentials_v1

def sample_sign_blob():
# Create a client
client = iam_credentials_v1.IAMCredentialsClient()

# Initialize request argument(s)
request = iam_credentials_v1.SignBlobRequest(
name="name_value",
payload=b'payload_blob',
)

# Make the request
response = client.sign_blob(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.iam_credentials_v1.types.SignBlobRequest, dict]):
The request object.
Expand Down Expand Up @@ -764,6 +830,28 @@ def sign_jwt(
r"""Signs a JWT using a service account's system-managed
private key.



.. code-block::

from google.cloud import iam_credentials_v1

def sample_sign_jwt():
# Create a client
client = iam_credentials_v1.IAMCredentialsClient()

# Initialize request argument(s)
request = iam_credentials_v1.SignJwtRequest(
name="name_value",
payload="payload_value",
)

# Make the request
response = client.sign_jwt(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.iam_credentials_v1.types.SignJwtRequest, dict]):
The request object.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Generated code. DO NOT EDIT!
#
# Snippet for GenerateAccessToken
# NOTE: This snippet has been automatically generated for illustrative purposes only.
# It may require modifications to work in your environment.

# To install the latest published package dependency, execute the following:
# python3 -m pip install google-cloud-iam


# [START iamcredentials_generated_iam_credentials_v1_IAMCredentials_GenerateAccessToken_async]
from google.cloud import iam_credentials_v1


async def sample_generate_access_token():
# Create a client
client = iam_credentials_v1.IAMCredentialsAsyncClient()

# Initialize request argument(s)
request = iam_credentials_v1.GenerateAccessTokenRequest(
name="name_value",
scope=['scope_value_1', 'scope_value_2'],
)

# Make the request
response = await client.generate_access_token(request=request)

# Handle the response
print(response)

# [END iamcredentials_generated_iam_credentials_v1_IAMCredentials_GenerateAccessToken_async]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Generated code. DO NOT EDIT!
#
# Snippet for GenerateAccessToken
# NOTE: This snippet has been automatically generated for illustrative purposes only.
# It may require modifications to work in your environment.

# To install the latest published package dependency, execute the following:
# python3 -m pip install google-cloud-iam


# [START iamcredentials_generated_iam_credentials_v1_IAMCredentials_GenerateAccessToken_sync]
from google.cloud import iam_credentials_v1


def sample_generate_access_token():
# Create a client
client = iam_credentials_v1.IAMCredentialsClient()

# Initialize request argument(s)
request = iam_credentials_v1.GenerateAccessTokenRequest(
name="name_value",
scope=['scope_value_1', 'scope_value_2'],
)

# Make the request
response = client.generate_access_token(request=request)

# Handle the response
print(response)

# [END iamcredentials_generated_iam_credentials_v1_IAMCredentials_GenerateAccessToken_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Generated code. DO NOT EDIT!
#
# Snippet for GenerateIdToken
# NOTE: This snippet has been automatically generated for illustrative purposes only.
# It may require modifications to work in your environment.

# To install the latest published package dependency, execute the following:
# python3 -m pip install google-cloud-iam


# [START iamcredentials_generated_iam_credentials_v1_IAMCredentials_GenerateIdToken_async]
from google.cloud import iam_credentials_v1


async def sample_generate_id_token():
# Create a client
client = iam_credentials_v1.IAMCredentialsAsyncClient()

# Initialize request argument(s)
request = iam_credentials_v1.GenerateIdTokenRequest(
name="name_value",
audience="audience_value",
)

# Make the request
response = await client.generate_id_token(request=request)

# Handle the response
print(response)

# [END iamcredentials_generated_iam_credentials_v1_IAMCredentials_GenerateIdToken_async]
Loading