16
16
from collections import OrderedDict
17
17
import functools
18
18
import re
19
- from typing import Dict , Optional , Sequence , Tuple , Type , Union
19
+ from typing import Dict , Mapping , Optional , Sequence , Tuple , Type , Union
20
20
import pkg_resources
21
21
22
22
from google .api_core .client_options import ClientOptions
@@ -236,7 +236,6 @@ async def list_functions(
236
236
r"""Returns a list of functions that belong to the
237
237
requested project.
238
238
239
-
240
239
.. code-block:: python
241
240
242
241
from google.cloud import functions_v1
@@ -333,7 +332,6 @@ async def get_function(
333
332
r"""Returns a function with the given name from the
334
333
requested project.
335
334
336
-
337
335
.. code-block:: python
338
336
339
337
from google.cloud import functions_v1
@@ -445,7 +443,6 @@ async def create_function(
445
443
already exists in the specified project, the long running
446
444
operation will return ``ALREADY_EXISTS`` error.
447
445
448
-
449
446
.. code-block:: python
450
447
451
448
from google.cloud import functions_v1
@@ -696,7 +693,6 @@ async def delete_function(
696
693
trigger, the trigger will be updated to remove this
697
694
function.
698
695
699
-
700
696
.. code-block:: python
701
697
702
698
from google.cloud import functions_v1
@@ -831,7 +827,6 @@ async def call_function(
831
827
information on the actual limits, refer to `Rate
832
828
Limits <https://cloud.google.com/functions/quotas#rate_limits>`__.
833
829
834
-
835
830
.. code-block:: python
836
831
837
832
from google.cloud import functions_v1
@@ -961,7 +956,6 @@ async def generate_upload_url(
961
956
962
957
- ``Authorization: Bearer YOUR_TOKEN``
963
958
964
-
965
959
.. code-block:: python
966
960
967
961
from google.cloud import functions_v1
@@ -1037,7 +1031,6 @@ async def generate_download_url(
1037
1031
For more information about the signed URL usage see:
1038
1032
https://cloud.google.com/storage/docs/access-control/signed-urls
1039
1033
1040
-
1041
1034
.. code-block:: python
1042
1035
1043
1036
from google.cloud import functions_v1
@@ -1109,17 +1102,17 @@ async def set_iam_policy(
1109
1102
r"""Sets the IAM access control policy on the specified
1110
1103
function. Replaces any existing policy.
1111
1104
1112
-
1113
1105
.. code-block:: python
1114
1106
1115
1107
from google.cloud import functions_v1
1108
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1116
1109
1117
1110
def sample_set_iam_policy():
1118
1111
# Create a client
1119
1112
client = functions_v1.CloudFunctionsServiceClient()
1120
1113
1121
1114
# Initialize request argument(s)
1122
- request = functions_v1 .SetIamPolicyRequest(
1115
+ request = iam_policy_pb2 .SetIamPolicyRequest(
1123
1116
resource="resource_value",
1124
1117
)
1125
1118
@@ -1141,21 +1134,26 @@ def sample_set_iam_policy():
1141
1134
1142
1135
Returns:
1143
1136
google.iam.v1.policy_pb2.Policy:
1144
- Defines an Identity and Access Management (IAM) policy. It is used to
1145
- specify access control policies for Cloud Platform
1146
- resources.
1137
+ An Identity and Access Management (IAM) policy, which specifies access
1138
+ controls for Google Cloud resources.
1147
1139
1148
1140
A Policy is a collection of bindings. A binding binds
1149
- one or more members to a single role. Members can be
1150
- user accounts, service accounts, Google groups, and
1151
- domains (such as G Suite). A role is a named list of
1152
- permissions (defined by IAM or configured by users).
1153
- A binding can optionally specify a condition, which
1154
- is a logic expression that further constrains the
1155
- role binding based on attributes about the request
1156
- and/or target resource.
1157
-
1158
- **JSON Example**
1141
+ one or more members, or principals, to a single role.
1142
+ Principals can be user accounts, service accounts,
1143
+ Google groups, and domains (such as G Suite). A role
1144
+ is a named list of permissions; each role can be an
1145
+ IAM predefined role or a user-created custom role.
1146
+
1147
+ For some types of Google Cloud resources, a binding
1148
+ can also specify a condition, which is a logical
1149
+ expression that allows access to a resource only if
1150
+ the expression evaluates to true. A condition can add
1151
+ constraints based on attributes of the request, the
1152
+ resource, or both. To learn which resources support
1153
+ conditions in their IAM policies, see the [IAM
1154
+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1155
+
1156
+ **JSON example:**
1159
1157
1160
1158
{
1161
1159
"bindings": [
@@ -1170,17 +1168,17 @@ def sample_set_iam_policy():
1170
1168
1171
1169
}, { "role":
1172
1170
"roles/resourcemanager.organizationViewer",
1173
- "members": ["user:[email protected] "],
1171
+ "members": [ "user:[email protected] " ],
1174
1172
"condition": { "title": "expirable access",
1175
1173
"description": "Does not grant access after
1176
1174
Sep 2020", "expression": "request.time <
1177
1175
timestamp('2020-10-01T00:00:00.000Z')", } }
1178
1176
1179
- ]
1177
+ ], "etag": "BwWWja0YfJA=", "version": 3
1180
1178
1181
1179
}
1182
1180
1183
- **YAML Example **
1181
+ **YAML example: **
1184
1182
1185
1183
bindings: - members: - user:\ [email protected] -
1186
1184
group:\ [email protected] - domain:google.com -
@@ -1191,11 +1189,12 @@ def sample_set_iam_policy():
1191
1189
condition: title: expirable access description:
1192
1190
Does not grant access after Sep 2020 expression:
1193
1191
request.time <
1194
- timestamp('2020-10-01T00:00:00.000Z')
1192
+ timestamp('2020-10-01T00:00:00.000Z') etag:
1193
+ BwWWja0YfJA= version: 3
1195
1194
1196
1195
For a description of IAM and its features, see the
1197
- [IAM developer's
1198
- guide ](\ https://cloud.google.com/iam/docs).
1196
+ [IAM
1197
+ documentation ](\ https://cloud.google.com/iam/docs/ ).
1199
1198
1200
1199
"""
1201
1200
# Create or coerce a protobuf request object.
@@ -1241,17 +1240,17 @@ async def get_iam_policy(
1241
1240
Returns an empty policy if the function exists and does
1242
1241
not have a policy set.
1243
1242
1244
-
1245
1243
.. code-block:: python
1246
1244
1247
1245
from google.cloud import functions_v1
1246
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1248
1247
1249
1248
def sample_get_iam_policy():
1250
1249
# Create a client
1251
1250
client = functions_v1.CloudFunctionsServiceClient()
1252
1251
1253
1252
# Initialize request argument(s)
1254
- request = functions_v1 .GetIamPolicyRequest(
1253
+ request = iam_policy_pb2 .GetIamPolicyRequest(
1255
1254
resource="resource_value",
1256
1255
)
1257
1256
@@ -1273,21 +1272,26 @@ def sample_get_iam_policy():
1273
1272
1274
1273
Returns:
1275
1274
google.iam.v1.policy_pb2.Policy:
1276
- Defines an Identity and Access Management (IAM) policy. It is used to
1277
- specify access control policies for Cloud Platform
1278
- resources.
1275
+ An Identity and Access Management (IAM) policy, which specifies access
1276
+ controls for Google Cloud resources.
1279
1277
1280
1278
A Policy is a collection of bindings. A binding binds
1281
- one or more members to a single role. Members can be
1282
- user accounts, service accounts, Google groups, and
1283
- domains (such as G Suite). A role is a named list of
1284
- permissions (defined by IAM or configured by users).
1285
- A binding can optionally specify a condition, which
1286
- is a logic expression that further constrains the
1287
- role binding based on attributes about the request
1288
- and/or target resource.
1289
-
1290
- **JSON Example**
1279
+ one or more members, or principals, to a single role.
1280
+ Principals can be user accounts, service accounts,
1281
+ Google groups, and domains (such as G Suite). A role
1282
+ is a named list of permissions; each role can be an
1283
+ IAM predefined role or a user-created custom role.
1284
+
1285
+ For some types of Google Cloud resources, a binding
1286
+ can also specify a condition, which is a logical
1287
+ expression that allows access to a resource only if
1288
+ the expression evaluates to true. A condition can add
1289
+ constraints based on attributes of the request, the
1290
+ resource, or both. To learn which resources support
1291
+ conditions in their IAM policies, see the [IAM
1292
+ documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies).
1293
+
1294
+ **JSON example:**
1291
1295
1292
1296
{
1293
1297
"bindings": [
@@ -1302,17 +1306,17 @@ def sample_get_iam_policy():
1302
1306
1303
1307
}, { "role":
1304
1308
"roles/resourcemanager.organizationViewer",
1305
- "members": ["user:[email protected] "],
1309
+ "members": [ "user:[email protected] " ],
1306
1310
"condition": { "title": "expirable access",
1307
1311
"description": "Does not grant access after
1308
1312
Sep 2020", "expression": "request.time <
1309
1313
timestamp('2020-10-01T00:00:00.000Z')", } }
1310
1314
1311
- ]
1315
+ ], "etag": "BwWWja0YfJA=", "version": 3
1312
1316
1313
1317
}
1314
1318
1315
- **YAML Example **
1319
+ **YAML example: **
1316
1320
1317
1321
bindings: - members: - user:\ [email protected] -
1318
1322
group:\ [email protected] - domain:google.com -
@@ -1323,11 +1327,12 @@ def sample_get_iam_policy():
1323
1327
condition: title: expirable access description:
1324
1328
Does not grant access after Sep 2020 expression:
1325
1329
request.time <
1326
- timestamp('2020-10-01T00:00:00.000Z')
1330
+ timestamp('2020-10-01T00:00:00.000Z') etag:
1331
+ BwWWja0YfJA= version: 3
1327
1332
1328
1333
For a description of IAM and its features, see the
1329
- [IAM developer's
1330
- guide ](\ https://cloud.google.com/iam/docs).
1334
+ [IAM
1335
+ documentation ](\ https://cloud.google.com/iam/docs/ ).
1331
1336
1332
1337
"""
1333
1338
# Create or coerce a protobuf request object.
@@ -1373,17 +1378,17 @@ async def test_iam_permissions(
1373
1378
policy for a function. If the function does not exist, this will
1374
1379
return an empty set of permissions, not a NOT_FOUND error.
1375
1380
1376
-
1377
1381
.. code-block:: python
1378
1382
1379
1383
from google.cloud import functions_v1
1384
+ from google.iam.v1 import iam_policy_pb2 # type: ignore
1380
1385
1381
1386
def sample_test_iam_permissions():
1382
1387
# Create a client
1383
1388
client = functions_v1.CloudFunctionsServiceClient()
1384
1389
1385
1390
# Initialize request argument(s)
1386
- request = functions_v1 .TestIamPermissionsRequest(
1391
+ request = iam_policy_pb2 .TestIamPermissionsRequest(
1387
1392
resource="resource_value",
1388
1393
permissions=['permissions_value_1', 'permissions_value_2'],
1389
1394
)
0 commit comments