Skip to content

Commit b15781d

Browse files
authored
feat(Enterprise Billing Units): add start and limit parameters to billing unit list APIs (#189)
Signed-off-by: Jonathan Date-chong <[email protected]>
1 parent 962bd3c commit b15781d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+872
-498
lines changed

examples/test_enterprise_billing_units_v1_examples.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# (C) Copyright IBM Corp. 2020.
2+
# (C) Copyright IBM Corp. 2023.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -16,10 +16,10 @@
1616
Examples for EnterpriseBillingUnitsV1
1717
"""
1818

19+
from ibm_cloud_sdk_core import ApiException, read_external_sources
1920
import os
2021
import pytest
2122
import json
22-
from ibm_cloud_sdk_core import ApiException, read_external_sources
2323
from ibm_platform_services.enterprise_billing_units_v1 import *
2424

2525
#
@@ -44,9 +44,6 @@
4444

4545
config = None
4646

47-
enterprise_id = None
48-
billing_unit_id = None
49-
5047

5148
##############################################################################
5249
# Start of Examples for Service: EnterpriseBillingUnitsV1
@@ -116,11 +113,18 @@ def test_list_billing_units_example(self):
116113
print('\nlist_billing_units() result:')
117114
# begin-list_billing_units
118115

119-
billing_units_list = enterprise_billing_units_service.list_billing_units(
120-
enterprise_id=enterprise_id
121-
).get_result()
116+
all_results = []
117+
pager = BillingUnitsPager(
118+
client=enterprise_billing_units_service,
119+
enterprise_id=enterprise_id,
120+
limit=10,
121+
)
122+
while pager.has_next():
123+
next_page = pager.get_next()
124+
assert next_page is not None
125+
all_results.extend(next_page)
122126

123-
print(json.dumps(billing_units_list, indent=2))
127+
print(json.dumps(all_results, indent=2))
124128

125129
# end-list_billing_units
126130

@@ -137,11 +141,18 @@ def test_list_billing_options_example(self):
137141
print('\nlist_billing_options() result:')
138142
# begin-list_billing_options
139143

140-
billing_options_list = enterprise_billing_units_service.list_billing_options(
141-
billing_unit_id=billing_unit_id
142-
).get_result()
143-
144-
print(json.dumps(billing_options_list, indent=2))
144+
all_results = []
145+
pager = BillingOptionsPager(
146+
client=enterprise_billing_units_service,
147+
billing_unit_id=billing_unit_id,
148+
limit=10,
149+
)
150+
while pager.has_next():
151+
next_page = pager.get_next()
152+
assert next_page is not None
153+
all_results.extend(next_page)
154+
155+
print(json.dumps(all_results, indent=2))
145156

146157
# end-list_billing_options
147158

examples/test_enterprise_management_v1_examples.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ def test_get_account_group_example(self):
173173
assert account_group_id is not None
174174

175175
try:
176-
177176
print('\nget_account_group() result:')
178177
# begin-get_account_group
179178

examples/test_iam_policy_management_v1_examples.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ def test_update_policy_state_example(self):
188188
update_policy_state request example
189189
"""
190190
try:
191-
192191
print('\nupdate_policy_state() result:')
193192
# begin-update_policy_state
194193

@@ -209,7 +208,6 @@ def test_list_policies_example(self):
209208
list_policies request example
210209
"""
211210
try:
212-
213211
print('\nlist_policies() result:')
214212
# begin-list_policies
215213

@@ -230,7 +228,6 @@ def test_delete_policy_example(self):
230228
delete_policy request example
231229
"""
232230
try:
233-
234231
print('\ndelete_policy() result:')
235232
# begin-delete_policy
236233

@@ -338,7 +335,6 @@ def test_replace_v2_policy_example(self):
338335
replace_v2_policy request example
339336
"""
340337
try:
341-
342338
print('\nreplace_v2_policy() result:')
343339
# begin-replace_v2_policy
344340

@@ -404,7 +400,6 @@ def test_list_v2_policies_example(self):
404400
list_v2_policies request example
405401
"""
406402
try:
407-
408403
print('\nlist_v2_policies() result:')
409404
# begin-list_v2_policies
410405

@@ -425,7 +420,6 @@ def test_delete_v2_policy_example(self):
425420
delete_v2_policy request example
426421
"""
427422
try:
428-
429423
print('\ndelete_v2_policy() result:')
430424
# begin-delete_v2_policy
431425

@@ -495,7 +489,6 @@ def test_replace_role_example(self):
495489
replace_role request example
496490
"""
497491
try:
498-
499492
print('\nreplace_role() result:')
500493
# begin-replace_role
501494

@@ -520,7 +513,6 @@ def test_list_roles_example(self):
520513
list_roles request example
521514
"""
522515
try:
523-
524516
print('\nlist_roles() result:')
525517
# begin-list_roles
526518

@@ -539,7 +531,6 @@ def test_delete_role_example(self):
539531
delete_role request example
540532
"""
541533
try:
542-
543534
print('\ndelete_role() result:')
544535
# begin-delete_role
545536

examples/test_ibm_cloud_shell_v1_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
account_id = None
4646

47+
4748
##############################################################################
4849
# Start of Examples for Service: IbmCloudShellV1
4950
##############################################################################

examples/test_open_service_broker_v1_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
reasonCode = 'IBMCLOUD_ACCT_SUSPEND'
6363
operation = 'Provision_45'
6464

65+
6566
##############################################################################
6667
# Start of Examples for Service: OpenServiceBrokerV1
6768
##############################################################################
@@ -228,7 +229,6 @@ def test_list_catalog_example(self):
228229
list_catalog request example
229230
"""
230231
try:
231-
232232
print('\nlist_catalog() result:')
233233
# begin-list_catalog
234234

examples/test_resource_manager_v2_examples.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
resource_group_id = None
4949

50+
5051
##############################################################################
5152
# Start of Examples for Service: ResourceManagerV2
5253
##############################################################################
@@ -102,7 +103,6 @@ def test_create_resource_group_example(self):
102103
assert example_user_account_id is not None
103104

104105
try:
105-
106106
print('\ncreate_resource_group() result:')
107107
# begin-create_resource_group
108108

@@ -129,7 +129,6 @@ def test_get_resource_group_example(self):
129129
assert resource_group_id is not None
130130

131131
try:
132-
133132
print('\nget_resource_group() result:')
134133
# begin-get_resource_group
135134

@@ -152,7 +151,6 @@ def test_update_resource_group_example(self):
152151
assert resource_group_id is not None
153152

154153
try:
155-
156154
print('\nupdate_resource_group() result:')
157155
# begin-update_resource_group
158156

@@ -177,7 +175,6 @@ def test_list_resource_groups_example(self):
177175
assert example_user_account_id is not None
178176

179177
try:
180-
181178
print('\nlist_resource_groups() result:')
182179
# begin-list_resource_groups
183180

@@ -201,7 +198,6 @@ def test_delete_resource_group_example(self):
201198
assert resource_group_id is not None
202199

203200
try:
204-
205201
print('\ndelete_resource_group() result:')
206202
# begin-delete_resource_group
207203

@@ -224,7 +220,6 @@ def test_get_quota_definition_example(self):
224220
assert example_quota_id is not None
225221

226222
try:
227-
228223
print('\nget_quota_definition() result:')
229224
# begin-get_quota_definition
230225

@@ -245,7 +240,6 @@ def test_list_quota_definitions_example(self):
245240
list_quota_definitions request example
246241
"""
247242
try:
248-
249243
print('\nlist_quota_definitions() result:')
250244
# begin-list_quota_definitions
251245

examples/test_user_management_v1_examples.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262

6363
delete_user_id = None
6464

65+
6566
##############################################################################
6667
# Start of Examples for Service: UserManagementV1
6768
##############################################################################
@@ -128,7 +129,6 @@ def test_invite_users_example(self):
128129
assert access_group_id is not None
129130

130131
try:
131-
132132
print('\ninvite_users() result:')
133133
# begin-invite_users
134134

@@ -195,7 +195,6 @@ def test_remove_user_example(self):
195195
assert delete_user_id is not None
196196

197197
try:
198-
199198
print('\nremove_user() result:')
200199
# begin-remove_user
201200

@@ -220,7 +219,6 @@ def test_get_user_profile_example(self):
220219
assert user_id is not None
221220

222221
try:
223-
224222
print('\nget_user_profile() result:')
225223
# begin-get_user_profile
226224

@@ -245,7 +243,6 @@ def test_update_user_profile_example(self):
245243
assert user_id is not None
246244

247245
try:
248-
249246
print('\nupdate_user_profile() result:')
250247
# begin-update_user_profile
251248

@@ -271,7 +268,6 @@ def test_get_user_settings_example(self):
271268
assert user_id is not None
272269

273270
try:
274-
275271
print('\nget_user_settings() result:')
276272
# begin-get_user_settings
277273

@@ -296,7 +292,6 @@ def test_update_user_settings_example(self):
296292
assert user_id is not None
297293

298294
try:
299-
300295
print('\nupdate_user_settings() result:')
301296
# begin-update_user_settings
302297

0 commit comments

Comments
 (0)