Skip to content

Conversation

@deepaksibm
Copy link
Contributor

No description provided.

Signed-off-by: Deepak Selvakumar <77007253+deepaksibm@users.noreply.github.com>
@deepaksibm deepaksibm force-pushed the release-2024-07-02 branch from fc847a3 to 3326abc Compare July 8, 2024 06:53
@deepaksibm
Copy link
Contributor Author

from ibm_vpc import VpcV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_cloud_sdk_core import ApiException
from ibm_vpc.vpc_v1 import *
authenticator = IAMAuthenticator("APIKEY")
service = VpcV1('2024-07-02', authenticator=authenticator)
import logging
logging.basicConfig(level=logging.DEBUG)
#  Listing VPCs
print("List VPCs")
try:
    vpcs = service.list_vpcs()
    print(vpcs)
except ApiException as e:
  print("List VPC failed with status code " + str(e.code) + ": " + e.message)
# for vpc in vpcs:
#     print(vpc['id'], "\t",  vpc['name'])

#  Listing Subnets
print("List Subnets")
try:
    subnets = service.list_subnets()
    print(subnets)
except ApiException as e:
  print("List subnets failed with status code " + str(e.code) + ": " + e.message)
# for subnet in subnets:
#     print(subnet['id'], "\t",  subnet['name'])
insPrototype = {'zone': {'name': 'us-south-2'}, 'resource_group': {'id': 'bdd96715c2a44f2bb60df4ff14a543f5'}, 'name': 'python-sdk-test-instance', 'vpc': {'id': 'r006-621147d8-798c-4dbc-948f-6c34a1e75d83'}, 'user_data': '', 'profile': {'name': 'bx2-2x8'}, 'keys': [{'id': 'r006-4304d82e-74a7-40bd-9b2a-68fceb219e20'}], 'volume_attachments': [], 'boot_volume_attachment': {'volume': {'name': 'b2091', 'capacity': 100, 'profile': {'name': 'general-purpose'}}, 'delete_volume_on_instance_delete': True}, 'metadata_service': {'enabled': False}, 'primary_network_interface': {'name': 'eth0', 'primary_ip': {'auto_delete': True}, 'allow_ip_spoofing': False, 'subnet': {'id': '0727-8bba335c-3559-4633-83ed-a4bb9d5bc5a6'}, 'security_groups': [{'id': 'r006-a4281eaa-023b-41bb-8060-247eb0bb5e68'}]}, 'network_attachments': [], 'image': {'id': 'r006-90c907bf-3555-4d05-84a1-7f2cca79f2b1'}}

ins_dict = service.create_instance(insPrototype).get_result()
print(ins_dict)
vpc_dict = service.create_vpc(name='python-sdk-test-vpc').get_result()
print(vpc_dict)
vpc_obj = VPC.from_dict(vpc_dict)
print(vpc_obj)

output.log

@deepaksibm deepaksibm merged commit 53194f7 into master Jul 8, 2024
ibm-vpc pushed a commit that referenced this pull request Jul 8, 2024
# [0.23.0](v0.22.0...v0.23.0) (2024-07-08)

### Features

* **release:** Update SDK to use API released on 2024-07-02 ([#64](#64)) ([53194f7](53194f7))
@ibm-vpc
Copy link
Collaborator

ibm-vpc commented Jul 8, 2024

🎉 This PR is included in version 0.23.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@deepaksibm deepaksibm deleted the release-2024-07-02 branch July 9, 2024 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants