Skip to main content

Python client library for IBM Cloud ibm-vpc Services

Project description

Build Status License semantic-release

IBM Cloud Virtual Private Cloud (VPC) Python SDK Version 0.30.0

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

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.8 or above.

Installation

To install, use pip or easy_install:

pip install --upgrade "ibm-vpc>=0.30.0"

or

easy_install --upgrade "ibm-vpc>=0.30.0"

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("YOUR_IBMCLOUD_API_KEY")
service = VpcV1(authenticator=authenticator)

# to change the service URL to the United Kingdom region
service.set_service_url(VpcV1.get_service_url_for_region("eu-gb"))

#  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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ibm_vpc-0.30.0.tar.gz (531.1 kB view details)

Uploaded Source

Built Distribution

ibm_vpc-0.30.0-py3-none-any.whl (545.8 kB view details)

Uploaded Python 3

File details

Details for the file ibm_vpc-0.30.0.tar.gz.

File metadata

  • Download URL: ibm_vpc-0.30.0.tar.gz
  • Upload date:
  • Size: 531.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for ibm_vpc-0.30.0.tar.gz
Algorithm Hash digest
SHA256 0b50682166ec69d8ba3508e3abf56626088ce2df7405d76010177d0854b98f79
MD5 53baea48538297a2a01dfc4b1303bf78
BLAKE2b-256 883b8d9aaf5f56369b0cc1b5608ab9dcdd34b86be6d219bc7345b3d0d84c0a9f

See more details on using hashes here.

File details

Details for the file ibm_vpc-0.30.0-py3-none-any.whl.

File metadata

  • Download URL: ibm_vpc-0.30.0-py3-none-any.whl
  • Upload date:
  • Size: 545.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for ibm_vpc-0.30.0-py3-none-any.whl
Algorithm Hash digest
SHA256 62a44fd4c605f90e57368db512554617743fd529cdb279f9d123eac53438795c
MD5 847f62ce6aab5df4b779651f36452df5
BLAKE2b-256 7a042a72fb7fc4c4b501c7256d88c4334f11b9a7b3d7547446d3fbbae0dea3ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page