Python client library for IBM Cloud VPC Services
Project description
IBM Cloud Virtual Private Cloud (VPC) Python SDK Version 0.19.1
Python client library to interact with various IBM Cloud Virtual Private Cloud (VPC) Service APIs.
This SDK uses Semantic Versioning, and as such there may be backward-incompatible changes for any new 0.y.z
version.
Table of Contents
- Overview
- Prerequisites
- Installation
- Using the SDK
- Setting up VPC service
- Questions
- Issues
- Open source @ IBM
- Contributing
- License
Overview
The IBM Cloud Virtual Private Cloud (VPC) Python SDK allows developers to programmatically interact with the following IBM Cloud services:
Service Name | Imported Class Name |
---|---|
VPC | VpcV1 |
Prerequisites
- An IBM Cloud account.
- An IAM API key to allow the SDK to access your account. Create an apikey here.
- Python version 3.7.6 or above.
Installation
To install, use pip
or easy_install
:
pip install --upgrade "ibm-vpc>=0.19.1"
or
easy_install --upgrade "ibm-vpc>=0.19.1"
Using the SDK
For general SDK usage information, see the IBM Cloud SDK Common README.
Setting up VPC service
from ibm_vpc import VpcV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
from ibm_cloud_sdk_core import ApiException
authenticator = IAMAuthenticator('apikey')
service = VpcV1(authenticator=authenticator)
# Listing VPCs
print("List VPCs")
try:
vpcs = service.list_vpcs().get_result()['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().get_result()['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'])
# Listing Instances
print("List Instances")
try:
instances = service.list_instances().get_result()['instances']
except ApiException as e:
print("List instances failed with status code " + str(e.code) + ": " + e.message)
for instance in instances:
print(instance['id'], "\t", instance['name'])
instanceId = instances[0]['id']
instanceName = instances[0]['name']
# Updating Instance
print("Updated Instance")
try:
newInstanceName = instanceName + "-1"
instance = service.update_instance(
id=instanceId,
name=newInstanceName,
).get_result()
except ApiException as e:
print("Update instance failed with status code " + str(e.code) + ": " + e.message)
print(instance['id'], "\t", instance['name'])
Questions
If you have difficulties using this SDK or you have a question about the IBM Cloud services, ask a question at Stack Overflow.
Issues
If you encounter an issue with the project, you are welcome to submit a bug report. Before you create a new issue, search for similar issues. It's possible that someone has already reported the problem.
Open source @ IBM
Find more open source projects on the IBM GitHub Page.
Contributing
See CONTRIBUTING.
License
This SDK is released under the Apache 2.0 license. The license's full text can be found in LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ibm-vpc-0.19.1.tar.gz
.
File metadata
- Download URL: ibm-vpc-0.19.1.tar.gz
- Upload date:
- Size: 366.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e9a7c04d61b4f90f084e1ec452b682685b07a35eb2b55904820cca23a3e4d60 |
|
MD5 | b7d09e2b6cf2a278f14584b728fd47b0 |
|
BLAKE2b-256 | bab4365d7fac6b8a3bb8fea9e34036e52111712d3254665ac1f9c90891de8c7c |