Skip to content

Commit 64de52e

Browse files
authored
feat(release): Update SDK to use API released on 2024-02-20 (#61)
Signed-off-by: Deepak Selvakumar <[email protected]>
1 parent badb557 commit 64de52e

File tree

4 files changed

+135406
-102708
lines changed

4 files changed

+135406
-102708
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Service Name | Imported Class Name
5151

5252
* An [IBM Cloud][ibm-cloud-onboarding] account.
5353
* An IAM API key to allow the SDK to access your account. Create an apikey [here](https://cloud.ibm.com/iam/apikeys).
54-
* Python version 3.7.6 or above.
54+
* Python version 3.8 or above.
5555

5656
## Installation
5757

examples/test_vpc_v1_examples.py

Lines changed: 260 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def test_create_hub_vpc_example(self):
164164

165165
except ApiException as e:
166166
pytest.fail(str(e))
167+
167168
@needscredentials
168169
def test_get_vpc_example(self):
169170
"""
@@ -2247,6 +2248,219 @@ def test_update_instance_volume_attachment_example(self):
22472248
except ApiException as e:
22482249
pytest.fail(str(e))
22492250

2251+
@needscredentials
2252+
def test_list_reservations_example(self):
2253+
"""
2254+
list_reservations request example
2255+
"""
2256+
try:
2257+
print('\nlist_reservations() result:')
2258+
# begin-list_reservations
2259+
2260+
reservation_collection = vpc_service.list_reservations().get_result()
2261+
2262+
# end-list_instance_profiles
2263+
assert reservation_collection is not None
2264+
except ApiException as e:
2265+
pytest.fail(str(e))
2266+
2267+
@needscredentials
2268+
def test_create_reservation_example(self):
2269+
"""
2270+
create_reservation request example
2271+
"""
2272+
try:
2273+
print('\ncreate_reservation() result:')
2274+
# begin-create_reservation
2275+
2276+
capacity_model = {}
2277+
capacity_model['total'] = 10
2278+
2279+
committed_use_model = {}
2280+
committed_use_model['term'] = 'one_year'
2281+
2282+
profile_model = {}
2283+
profile_model['name'] = 'ba2-2x8'
2284+
profile_model['resource_type'] = 'instance_profile'
2285+
2286+
zone_identity_model = {}
2287+
zone_identity_model['name'] = data['zone']
2288+
2289+
reservation = vpc_service.create_reservation(
2290+
capacity=capacity_model,
2291+
committed_use=committed_use_model,
2292+
profile=profile_model,
2293+
zone=zone_identity_model,
2294+
name='my-reservation').get_result()
2295+
2296+
# end-create_reservation
2297+
assert reservation['id'] is not None
2298+
data['reservationId']=reservation['id']
2299+
2300+
except ApiException as e:
2301+
pytest.fail(str(e))
2302+
2303+
@needscredentials
2304+
def test_update_reservation_example(self):
2305+
"""
2306+
update_reservation request example
2307+
"""
2308+
try:
2309+
print('\nupdate_reservation() result:')
2310+
# begin-update_reservation
2311+
2312+
reservation_patch_model = {}
2313+
reservation_patch_model['name'] ='my-reservation-updated'
2314+
2315+
reservation = vpc_service.update_reservation(
2316+
id=data['reservationId'], reservation_patch=reservation_patch_model).get_result()
2317+
2318+
# end-update_reservation
2319+
assert reservation is not None
2320+
2321+
except ApiException as e:
2322+
pytest.fail(str(e))
2323+
2324+
@needscredentials
2325+
def test_activate_reservation_example(self):
2326+
"""
2327+
activate_reservation request example
2328+
"""
2329+
try:
2330+
print('\nactivate_reservation() result:')
2331+
# begin-activate_reservation
2332+
2333+
response = vpc_service.activate_reservation(
2334+
id=data['reservationId']).get_result()
2335+
2336+
# end-activate_reservation
2337+
except ApiException as e:
2338+
pytest.fail(str(e))
2339+
2340+
@needscredentials
2341+
def test_get_reservation_example(self):
2342+
"""
2343+
get_reservation request example
2344+
"""
2345+
try:
2346+
print('\nget_reservation() result:')
2347+
# begin-activate_reservation
2348+
2349+
reservation = vpc_service.get_reservation(
2350+
id=data['reservationId']).get_result()
2351+
2352+
# end-get_reservation
2353+
assert reservation is not None
2354+
except ApiException as e:
2355+
pytest.fail(str(e))
2356+
2357+
@needscredentials
2358+
def test_create_instance_with_reservation_example(self):
2359+
"""
2360+
create_instance with reservation request example
2361+
"""
2362+
try:
2363+
print('\ncreate_instance_with_reservation() result:')
2364+
# begin-create_instance
2365+
2366+
subnet_identity_model = {}
2367+
subnet_identity_model['id'] = data['subnetId']
2368+
2369+
network_interface_prototype_model = {}
2370+
network_interface_prototype_model['name'] = 'my-network-interface'
2371+
network_interface_prototype_model['subnet'] = subnet_identity_model
2372+
2373+
instance_profile_identity_model = {}
2374+
instance_profile_identity_model['name'] = 'bx2-2x8'
2375+
2376+
vpc_identity_model = {}
2377+
vpc_identity_model['id'] = data['vpcID']
2378+
2379+
zone_identity_model = {}
2380+
zone_identity_model['name'] = data['zone']
2381+
2382+
reservation_identity_model = {}
2383+
reservation_identity_model['id'] = data['reservationId']
2384+
2385+
reservation_affinity_model = {}
2386+
reservation_affinity_model['policy'] = 'manual'
2387+
reservation_affinity_model['pool'] = [reservation_identity_model]
2388+
2389+
image_identity_model = {}
2390+
image_identity_model['id'] = data['imageId']
2391+
2392+
instance_prototype_model = {}
2393+
instance_prototype_model['name'] = 'my-instance-with-res'
2394+
instance_prototype_model['profile'] = instance_profile_identity_model
2395+
instance_prototype_model['vpc'] = vpc_identity_model
2396+
instance_prototype_model['primary_network_interface'] = network_interface_prototype_model
2397+
instance_prototype_model['zone'] = zone_identity_model
2398+
instance_prototype_model['image'] = image_identity_model
2399+
instance_prototype_model['reservation_affinity'] = reservation_affinity_model
2400+
2401+
instance = vpc_service.create_instance(
2402+
instance_prototype=instance_prototype_model).get_result()
2403+
2404+
# end-create_instance
2405+
2406+
assert instance is not None
2407+
data['instanceIdWithRes']=instance['id']
2408+
2409+
except ApiException as e:
2410+
pytest.fail(str(e))
2411+
2412+
@needscredentials
2413+
def test_update_instance_with_reservation_example(self):
2414+
"""
2415+
update_instance with reservation request example
2416+
"""
2417+
try:
2418+
print('\nupdate_instance_with_reservation() result:')
2419+
# begin-update_instance
2420+
2421+
reservation_identity_model = {}
2422+
reservation_identity_model['id'] = data['reservationId']
2423+
2424+
reservation_affinity_model = {}
2425+
reservation_affinity_model['policy'] = 'manual'
2426+
reservation_affinity_model['pool'] = [reservation_identity_model]
2427+
2428+
instance_patch_model = {}
2429+
instance_patch_model['name']='my-instance-updated'
2430+
instance_patch_model['reservation_affinity'] = reservation_affinity_model
2431+
2432+
instance = vpc_service.update_instance(
2433+
id=data['instanceId'],
2434+
instance_patch=instance_patch_model).get_result()
2435+
2436+
# end-update_instance
2437+
assert instance is not None
2438+
2439+
except ApiException as e:
2440+
pytest.fail(str(e))
2441+
2442+
2443+
@needscredentials
2444+
@pytest.mark.skip(reason="mock")
2445+
def test_delete_reservation_example(self):
2446+
"""
2447+
delete_reservation request example
2448+
"""
2449+
try:
2450+
# begin-delete_reservation
2451+
2452+
response = vpc_service.delete_reservation(
2453+
id=data['reservationId'])
2454+
2455+
assert response is not None
2456+
2457+
# end-delete_reservation
2458+
print('\ndelete_reservation() response status code: ',
2459+
response.get_status_code())
2460+
2461+
except ApiException as e:
2462+
pytest.fail(str(e))
2463+
22502464
@needscredentials
22512465
def test_list_instance_groups_example(self):
22522466
"""
@@ -4988,7 +5202,30 @@ def test_disconnect_vpn_client_example(self):
49885202
except ApiException as e:
49895203
pytest.fail(str(e))
49905204

5205+
5206+
@needscredentials
5207+
def test_create_vpn_server_route_example(self):
5208+
"""
5209+
create_vpn_server_route request example
5210+
"""
5211+
try:
5212+
print('\ncreate_vpn_server_route() result:')
5213+
# begin-create_vpn_server_route
5214+
5215+
vpn_server_route = vpc_service.create_vpn_server_route(
5216+
vpn_server_id=data['vpnserverId'],
5217+
destination='172.16.0.0/16',
5218+
name='my-vpn-server-route'
5219+
).get_result()
5220+
5221+
print(json.dumps(vpn_server_route, indent=2))
5222+
5223+
# end-create_vpn_server_route
5224+
data['vpnserverrouteId']=vpn_server_route['id']
5225+
except ApiException as e:
5226+
pytest.fail(str(e))
49915227
@needscredentials
5228+
@pytest.mark.skip(reason="mock")
49925229
def test_list_vpn_server_routes_example(self):
49935230
"""
49945231
list_vpn_server_routes request example
@@ -5016,28 +5253,6 @@ def test_list_vpn_server_routes_example(self):
50165253
except ApiException as e:
50175254
pytest.fail(str(e))
50185255

5019-
@needscredentials
5020-
def test_create_vpn_server_route_example(self):
5021-
"""
5022-
create_vpn_server_route request example
5023-
"""
5024-
try:
5025-
print('\ncreate_vpn_server_route() result:')
5026-
# begin-create_vpn_server_route
5027-
5028-
vpn_server_route = vpc_service.create_vpn_server_route(
5029-
vpn_server_id=data['vpnserverId'],
5030-
destination='172.16.0.0/16',
5031-
name='my-vpn-server-route'
5032-
).get_result()
5033-
5034-
print(json.dumps(vpn_server_route, indent=2))
5035-
5036-
# end-create_vpn_server_route
5037-
data['vpnserverrouteId']=vpn_server_route['id']
5038-
except ApiException as e:
5039-
pytest.fail(str(e))
5040-
50415256
@needscredentials
50425257
def test_get_vpn_server_route_example(self):
50435258
"""
@@ -6269,20 +6484,23 @@ def test_create_bare_metal_server_example(self):
62696484
'id': data['subnetId'],
62706485
},
62716486
}
6272-
6487+
bare_metal_server_profile_identity_model = {
6488+
'name': 'bmx2-48x768',
6489+
}
62736490
zone_identity_model = {
62746491
'name': data['zone'],
62756492
}
6276-
6277-
bare_metal_server = vpc_service.create_bare_metal_server(
6278-
initialization=bare_metal_server_initialization_prototype_model,
6279-
primary_network_interface=
6493+
bare_metal_server_prototype_model = {
6494+
'initialization': bare_metal_server_initialization_prototype_model,
6495+
'primary_network_interface':
62806496
bare_metal_server_primary_network_interface_prototype_model,
6281-
profile={
6282-
'name': 'bmx2-48x768'
6283-
},
6284-
name='my-baremetal-server',
6285-
zone=zone_identity_model).get_result()
6497+
'profile': bare_metal_server_profile_identity_model,
6498+
'name':'my-baremetal-server',
6499+
'zone':zone_identity_model
6500+
}
6501+
bare_metal_server = vpc_service.create_bare_metal_server(
6502+
bare_metal_server_prototype=bare_metal_server_prototype_model,
6503+
).get_result()
62866504

62876505
# end-create_bare_metal_server
62886506
assert bare_metal_server is not None
@@ -6807,12 +7025,14 @@ def test_create_backup_policy_example(self):
68077025
'deletion_trigger': backup_policy_plan_deletion_trigger_prototype_model,
68087026
'name': 'my-backup-policy-plan',
68097027
}
6810-
7028+
backup_policy_prototype = {
7029+
'match_user_tags': ['my-daily-backup-policy'],
7030+
'match_resource_type':['volume'],
7031+
'name':'my-backup-policy',
7032+
'plans':[backup_policy_plan_prototype_model],
7033+
}
68117034
backup_policy_response = vpc_service.create_backup_policy(
6812-
match_user_tags=['my-daily-backup-policy'],
6813-
match_resource_types=['volume'],
6814-
name='my-backup-policy',
6815-
plans=[backup_policy_plan_prototype_model],
7035+
backup_policy_prototype = backup_policy_prototype
68167036
)
68177037
backup_policy = backup_policy_response.get_result()
68187038
data['backupPolicyETag'] = backup_policy_response.get_headers()['ETag']
@@ -6951,6 +7171,7 @@ def test_update_backup_policy_plan_example(self):
69517171
pytest.fail(str(e))
69527172

69537173
@needscredentials
7174+
@pytest.mark.skip(reason="mock")
69547175
def test_list_backup_policy_jobs_example(self):
69557176
"""
69567177
list_backup_policy_jobs request example
@@ -6976,6 +7197,7 @@ def test_list_backup_policy_jobs_example(self):
69767197
data['backupPolicyJobID'] = all_results[0]['id']
69777198

69787199
@needscredentials
7200+
@pytest.mark.skip(reason="mock")
69797201
def test_get_backup_policy_job_example(self):
69807202
"""
69817203
get_backup_policy_job request example
@@ -7915,6 +8137,7 @@ def test_delete_vpc_dns_resolution_binding_example(self):
79158137

79168138
except ApiException as e:
79178139
pytest.fail(str(e))
8140+
79188141
@needscredentials
79198142
def test_delete_vpc_example(self):
79208143
"""

0 commit comments

Comments
 (0)