14
14
@click .pass_context
15
15
def subscriptions (ctx ):
16
16
'''Commands for interacting with the Subscriptions API'''
17
- pass
17
+ # None means that order of precedence is 1) environment variable,
18
+ # 2) secret file.
19
+ ctx .obj ['AUTH' ] = None
18
20
19
21
20
22
# We want our command to be known as "list" on the command line but
@@ -38,7 +40,7 @@ def subscriptions(ctx):
38
40
@coro
39
41
async def list_subscriptions_cmd (ctx , status , limit , pretty ):
40
42
"""Prints a sequence of JSON-encoded Subscription descriptions."""
41
- async with CliSession () as session :
43
+ async with CliSession (auth = ctx . obj [ 'AUTH' ] ) as session :
42
44
client = SubscriptionsClient (session )
43
45
subs_aiter = client .list_subscriptions_aiter (status = status ,
44
46
limit = limit )
@@ -75,7 +77,7 @@ def parse_request(ctx, param, value: str) -> dict:
75
77
@coro
76
78
async def create_subscription_cmd (ctx , request , pretty ):
77
79
"""Submits a subscription request and prints the API response."""
78
- async with CliSession () as session :
80
+ async with CliSession (auth = ctx . obj [ 'AUTH' ] ) as session :
79
81
client = SubscriptionsClient (session )
80
82
sub = await client .create_subscription (request )
81
83
echo_json (sub , pretty )
@@ -89,7 +91,7 @@ async def create_subscription_cmd(ctx, request, pretty):
89
91
@coro
90
92
async def cancel_subscription_cmd (ctx , subscription_id , pretty ):
91
93
"""Cancels a subscription and prints the API response."""
92
- async with CliSession () as session :
94
+ async with CliSession (auth = ctx . obj [ 'AUTH' ] ) as session :
93
95
client = SubscriptionsClient (session )
94
96
sub = await client .cancel_subscription (subscription_id )
95
97
echo_json (sub , pretty )
@@ -104,7 +106,7 @@ async def cancel_subscription_cmd(ctx, subscription_id, pretty):
104
106
@coro
105
107
async def update_subscription_cmd (ctx , subscription_id , request , pretty ):
106
108
"""Updates a subscription and prints the API response."""
107
- async with CliSession () as session :
109
+ async with CliSession (auth = ctx . obj [ 'AUTH' ] ) as session :
108
110
client = SubscriptionsClient (session )
109
111
sub = await client .update_subscription (subscription_id , request )
110
112
echo_json (sub , pretty )
@@ -118,7 +120,7 @@ async def update_subscription_cmd(ctx, subscription_id, request, pretty):
118
120
@coro
119
121
async def describe_subscription_cmd (ctx , subscription_id , pretty ):
120
122
"""Gets the description of a subscription and prints the API response."""
121
- async with CliSession () as session :
123
+ async with CliSession (auth = ctx . obj [ 'AUTH' ] ) as session :
122
124
client = SubscriptionsClient (session )
123
125
sub = await client .get_subscription (subscription_id )
124
126
echo_json (sub , pretty )
@@ -154,7 +156,7 @@ async def list_subscription_results_cmd(ctx,
154
156
status ,
155
157
limit ):
156
158
"""Gets results of a subscription and prints the API response."""
157
- async with CliSession () as session :
159
+ async with CliSession (auth = ctx . obj [ 'AUTH' ] ) as session :
158
160
client = SubscriptionsClient (session )
159
161
results_aiter = client .get_results_aiter (subscription_id ,
160
162
status = status ,
0 commit comments