[![PyPi](https://img.shields.io/pypi/v/ibmcloud-python-sdk.svg)](https://pypi.org/project/ibmcloud-python-sdk)
[![Downloads](https://static.pepy.tech/personalized-badge/ibmcloud-python-sdk?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pepy.tech/project/ibmcloud-python-sdk)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
[![codecov](https://codecov.io/gh/goldyfruit/ibmcloud-python-sdk/branch/main/graph/badge.svg?token=UW2HGIIV11)](https://codecov.io/gh/goldyfruit/ibmcloud-python-sdk)
- [IBM Cloud Python SDK](#ibm-cloud-python-sdk)
- [Environment variables](#environment-variables)
- [Documentation](#documentation)
- [Supported features](#supported-features)
- [Installation](#installation)
- [Caching](#caching)
- [Podman](#podman)
- [Docker](#docker)
- [Examples](#examples)
- [List VPCs](#list-vpcs)
- [Create a VPC instance](#create-a-vpc-instance)
- [FAQ](#faq)
# IBM Cloud Python SDK
`ibmcloud-python-sdk` aims to talk to IBM Cloud. To do this, it requires a configuration file. `ibmcloud-python-sdk` favours `clouds.yaml` file, but can also use environment variables *(see [below](#environment-variables))*. An example:
```yaml
---
clouds:
default: demo-acc
demo-acc:
profile: demo
description: Credentials from my IBM Cloud demo account
key: XxX1234567890XxX
region: us-south
version: 2021-06-15
generation: 2
cis_username: 000000_sponge.bob@sink.com
cis_apikey: abc123def456ghi789klm0n
prod-acc:
profile: prod
description: Credentials from my IBM Cloud production account
key: zZz1234567890zZz
region: us-south
version: 2021-06-15
generation: 2
cis_username: 999999_sponge.bob@sink.com
cis_apikey: @@abc123def456ghi789klm0n@@
```
The `clouds.yaml` file will be searched at first into `~/.ibmcloud` directory but this behavior could be overrided by an environment variable.
## Environment variables
| Variable | Description | Example | Mandatory |
| ------------------ | ----------- | ------- | --------- |
| `IC_CONFIG_FILE` | Absolute path to the `clouds.yaml` file | `~/vault/ibm.yaml` | [ ] |
| `IC_CONFIG_NAME` | Name of the default cloud configuration | `demo` | [ ] |
| `IC_REGION` | Region were to connect | `us-south` | [x] |
| `IC_VERSION` | Requests the version of the API | `2021-06-15` | [x] |
| `IC_GENERATION` | The infrastructure generation for the request | `2` | [x] |
| `IC_SDK_CONFIG_FILE` | Absolute path to the `sdk.yaml` file | `~/.config/ibmcloud/sdk.yaml` | [ ] |
| `IC_API_KEY` | API key created via the IBM Cloud IAM system | `XxX1234567890XxX` | [x] |
| `SL_USERNAME` | SoftLayer user | `goldyfruit` | [ ] |
| `SL_API_KEY` | SoftLayer API key | `abc123def456ghi789klm0n` | [ ] |
## Documentation
Documentation for the IBM Cloud Python SDK is available [here](https://goldyfruit.github.io/ibmcloud-python-sdk).
IBM Cloud Python SDK leverages existing Python SDKs such as:
- [SoftLayer](https://github.com/softlayer/softlayer-python)
- [IBM Cloud Object Storage](https://github.com/IBM/ibm-cos-sdk-python)
## Supported features
Only VPC Gen 2 is supported by this SDK.
| Service | Feature |
| -------- | ------- |
| CIS | *Baremetal, Object Storage* |
| DNS | *Public Zone, Private Zone* |
| EM | *Get Account, Get Enterprise* |
| IAM | *Policies, Roles* |
| POWER | *Power System* |
| RESOURCE | *Binding, Group, Instance, Key* |
| VPC | *ACL, FIP, Gateway, Geo, Image, Instance, Key, Load Balancer, Security, Subnet, Volume, VPC, VPN* |
## Installation
Install from PyPi via `pip`:
```shell
python -m venv ~/virtualenvs/ibmcloud-python-sdk
source ~/virtualenvs/ibmcloud-python-sdk/bin/activate
pip install ibmcloud-python-sdk
```
Or you can install from source:
```shell
cd ~/Git
git clone https://github.com/goldyfruit/ibmcloud-python-sdk.git
python -m venv ~/virtualenvs/ibmcloud-python-sdk
source ~/virtualenvs/ibmcloud-python-sdk/bin/activate
cd ~/Git/ibmcloud-python-sdk
pip install .
```
We recommend to use Python virtual environment to install the SDK.
## Caching
The SDK has caching capability *(`memcached` only for now)* to improve the HTTP requests speed. To enable this mechanisim please configure the SDK properly using `~/.ibmcloud/sdk.yaml` file.
```yaml
---
sdk:
cache_ttl: 60
memcached:
- 127.0.0.1:11211
```
Muttiple cache servers could be configured as well.
```yaml
---
sdk:
cache_ttl: 60
memcached:
- 127.0.0.1:11211
- 127.0.0.1:11212
- 127.0.0.1:11213
```
An easy way to deploy `memcached` server is to use container.
### Podman
```shell
podman run -dt -p 11211:11211 --name memcached -d memcached
```
### Docker
```shell
sudo docker run -dt -p 11211:11211 --name memcached -d memcached
```
## Examples
A list of examples on how to use this SDK can be found at [here](https://github.com/goldyfruit/ibmcloud-python-sdk/tree/main/examples).
### List VPCs
```python
from ibmcloud_python_sdk.vpc import vpc as ic
vpc = ic.Vpc()
vpc.get_vpc("ibmcloud-vpc-baby")
```
### Create a VPC instance
```python
from ibmcloud_python_sdk.vpc import vpc as icv
from ibmcloud_python_sdk.resource import resource_group as icr
import sys
# Variables
vpc_name = 'ibmcloud-vpc-baby'
resource_group_name = 'ibmcloud-resource-group-baby'
# Intentiate classes
vpc = icv.Vpc()
rg = icr.ResourceGroup()
# Retrieve resource group ID and check for error
resource_group_info = rg.get_resource_group(resource_group_name)
if 'errors' in resource_group_info:
print(resource_group_info['errors'])
sys.exit()
# Create the VPC based on variable and resource group ID
response = vpc.create_vpc(
name=vpc_name,
resource_group=resource_group_info['id'],
address_prefix_management='auto',
classic_access=True
)
# Check for error during the VPC creation process
if 'errors' in response:
print(response['errors'])
else:
print(response)
```
## FAQ
- `CRN` or `HREF` could not be used as ID to retrieve resources
- `PATCH` method *(update)* is not yet supported which means a resource cannot be updated
## Copyright
See the bundled [LICENSE](https://github.com/goldyfruit/ibmcloud-python-sdk/blob/main/LICENSE) file for more information.
Raw data
{
"_id": null,
"home_page": "https://github.com/goldyfruit/ibmcloud-python-sdk",
"name": "ibmcloud-python-sdk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "ibm, ibmcloud, sdk, api, rest",
"author": "Ga\u00ebtan Trellu (goldyfruit) & James R\u00e9gis",
"author_email": "gaetan.trellu@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/8d/65/c9ee33584b92001bbba39df7020ffb12ea920665110e1e44e3aef7c71651/ibmcloud-python-sdk-1.1.4.tar.gz",
"platform": "any",
"description": "[![PyPi](https://img.shields.io/pypi/v/ibmcloud-python-sdk.svg)](https://pypi.org/project/ibmcloud-python-sdk)\n[![Downloads](https://static.pepy.tech/personalized-badge/ibmcloud-python-sdk?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pepy.tech/project/ibmcloud-python-sdk)\n[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)\n[![codecov](https://codecov.io/gh/goldyfruit/ibmcloud-python-sdk/branch/main/graph/badge.svg?token=UW2HGIIV11)](https://codecov.io/gh/goldyfruit/ibmcloud-python-sdk)\n\n- [IBM Cloud Python SDK](#ibm-cloud-python-sdk)\n - [Environment variables](#environment-variables)\n - [Documentation](#documentation)\n - [Supported features](#supported-features)\n - [Installation](#installation)\n - [Caching](#caching)\n - [Podman](#podman)\n - [Docker](#docker)\n - [Examples](#examples)\n - [List VPCs](#list-vpcs)\n - [Create a VPC instance](#create-a-vpc-instance)\n - [FAQ](#faq)\n\n# IBM Cloud Python SDK\n\n`ibmcloud-python-sdk` aims to talk to IBM Cloud. To do this, it requires a configuration file. `ibmcloud-python-sdk` favours `clouds.yaml` file, but can also use environment variables *(see [below](#environment-variables))*. An example:\n\n```yaml\n---\nclouds:\n default: demo-acc\n demo-acc:\n profile: demo\n description: Credentials from my IBM Cloud demo account\n key: XxX1234567890XxX\n region: us-south\n version: 2021-06-15\n generation: 2\n cis_username: 000000_sponge.bob@sink.com\n cis_apikey: abc123def456ghi789klm0n\n prod-acc:\n profile: prod\n description: Credentials from my IBM Cloud production account\n key: zZz1234567890zZz\n region: us-south\n version: 2021-06-15\n generation: 2\n cis_username: 999999_sponge.bob@sink.com\n cis_apikey: @@abc123def456ghi789klm0n@@\n```\n\nThe `clouds.yaml` file will be searched at first into `~/.ibmcloud` directory but this behavior could be overrided by an environment variable.\n\n## Environment variables\n\n| Variable | Description | Example | Mandatory |\n| ------------------ | ----------- | ------- | --------- |\n| `IC_CONFIG_FILE` | Absolute path to the `clouds.yaml` file | `~/vault/ibm.yaml` | [ ] |\n| `IC_CONFIG_NAME` | Name of the default cloud configuration | `demo` | [ ] |\n| `IC_REGION` | Region were to connect | `us-south` | [x] |\n| `IC_VERSION` | Requests the version of the API | `2021-06-15` | [x] |\n| `IC_GENERATION` | The infrastructure generation for the request | `2` | [x] |\n| `IC_SDK_CONFIG_FILE` | Absolute path to the `sdk.yaml` file | `~/.config/ibmcloud/sdk.yaml` | [ ] |\n| `IC_API_KEY` | API key created via the IBM Cloud IAM system | `XxX1234567890XxX` | [x] |\n| `SL_USERNAME` | SoftLayer user | `goldyfruit` | [ ] |\n| `SL_API_KEY` | SoftLayer API key | `abc123def456ghi789klm0n` | [ ] |\n\n## Documentation\n\nDocumentation for the IBM Cloud Python SDK is available [here](https://goldyfruit.github.io/ibmcloud-python-sdk).\n\nIBM Cloud Python SDK leverages existing Python SDKs such as:\n\n- [SoftLayer](https://github.com/softlayer/softlayer-python)\n- [IBM Cloud Object Storage](https://github.com/IBM/ibm-cos-sdk-python)\n\n## Supported features\n\nOnly VPC Gen 2 is supported by this SDK.\n\n| Service | Feature |\n| -------- | ------- |\n| CIS | *Baremetal, Object Storage* |\n| DNS | *Public Zone, Private Zone* |\n| EM | *Get Account, Get Enterprise* |\n| IAM | *Policies, Roles* |\n| POWER | *Power System* |\n| RESOURCE | *Binding, Group, Instance, Key* |\n| VPC | *ACL, FIP, Gateway, Geo, Image, Instance, Key, Load Balancer, Security, Subnet, Volume, VPC, VPN* |\n\n## Installation\n\nInstall from PyPi via `pip`:\n\n```shell\npython -m venv ~/virtualenvs/ibmcloud-python-sdk\nsource ~/virtualenvs/ibmcloud-python-sdk/bin/activate\npip install ibmcloud-python-sdk\n```\n\nOr you can install from source:\n\n```shell\ncd ~/Git\ngit clone https://github.com/goldyfruit/ibmcloud-python-sdk.git\npython -m venv ~/virtualenvs/ibmcloud-python-sdk\nsource ~/virtualenvs/ibmcloud-python-sdk/bin/activate\ncd ~/Git/ibmcloud-python-sdk\npip install .\n```\n\nWe recommend to use Python virtual environment to install the SDK.\n\n## Caching\n\nThe SDK has caching capability *(`memcached` only for now)* to improve the HTTP requests speed. To enable this mechanisim please configure the SDK properly using `~/.ibmcloud/sdk.yaml` file.\n\n```yaml\n---\nsdk:\n cache_ttl: 60\n memcached:\n - 127.0.0.1:11211\n```\n\nMuttiple cache servers could be configured as well.\n\n```yaml\n---\nsdk:\n cache_ttl: 60\n memcached:\n - 127.0.0.1:11211\n - 127.0.0.1:11212\n - 127.0.0.1:11213\n```\n\nAn easy way to deploy `memcached` server is to use container.\n\n### Podman\n\n```shell\npodman run -dt -p 11211:11211 --name memcached -d memcached\n```\n\n### Docker\n\n```shell\nsudo docker run -dt -p 11211:11211 --name memcached -d memcached\n```\n\n## Examples\n\nA list of examples on how to use this SDK can be found at [here](https://github.com/goldyfruit/ibmcloud-python-sdk/tree/main/examples).\n\n### List VPCs\n\n```python\nfrom ibmcloud_python_sdk.vpc import vpc as ic\n\n\nvpc = ic.Vpc()\nvpc.get_vpc(\"ibmcloud-vpc-baby\")\n```\n\n### Create a VPC instance\n\n```python\nfrom ibmcloud_python_sdk.vpc import vpc as icv\nfrom ibmcloud_python_sdk.resource import resource_group as icr\nimport sys\n\n\n# Variables\nvpc_name = 'ibmcloud-vpc-baby'\nresource_group_name = 'ibmcloud-resource-group-baby'\n\n# Intentiate classes\nvpc = icv.Vpc()\nrg = icr.ResourceGroup()\n\n# Retrieve resource group ID and check for error\nresource_group_info = rg.get_resource_group(resource_group_name)\nif 'errors' in resource_group_info:\n print(resource_group_info['errors'])\n sys.exit()\n\n# Create the VPC based on variable and resource group ID\nresponse = vpc.create_vpc(\n name=vpc_name,\n resource_group=resource_group_info['id'],\n address_prefix_management='auto',\n classic_access=True\n )\n\n# Check for error during the VPC creation process\nif 'errors' in response:\n print(response['errors'])\nelse:\n print(response)\n\n```\n\n## FAQ\n\n- `CRN` or `HREF` could not be used as ID to retrieve resources\n- `PATCH` method *(update)* is not yet supported which means a resource cannot be updated\n\n## Copyright\n\nSee the bundled [LICENSE](https://github.com/goldyfruit/ibmcloud-python-sdk/blob/main/LICENSE) file for more information.\n",
"bugtrack_url": null,
"license": "Apache2",
"summary": "IBM Cloud Python SDK",
"version": "1.1.4",
"project_urls": {
"Documentation": "https://goldyfruit.github.io/ibmcloud-python-sdk",
"Homepage": "https://github.com/goldyfruit/ibmcloud-python-sdk",
"Issue": "https://github.com/goldyfruit/ibmcloud-python-sdk/issues",
"Source": "https://github.com/goldyfruit/ibmcloud-python-sdk"
},
"split_keywords": [
"ibm",
" ibmcloud",
" sdk",
" api",
" rest"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "63ba84ec75eef5a20716789a81fb2b6ae661a20c20fdc06c51f5d59b7d5563cc",
"md5": "73e0cd5b819a89d03c3add5cb19bcce9",
"sha256": "2d6bd0ce6aadf6933de2e40d0f2e829c238ec326853e63829355ac5e6740c8c3"
},
"downloads": -1,
"filename": "ibmcloud_python_sdk-1.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "73e0cd5b819a89d03c3add5cb19bcce9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 119071,
"upload_time": "2024-03-27T14:47:31",
"upload_time_iso_8601": "2024-03-27T14:47:31.336028Z",
"url": "https://files.pythonhosted.org/packages/63/ba/84ec75eef5a20716789a81fb2b6ae661a20c20fdc06c51f5d59b7d5563cc/ibmcloud_python_sdk-1.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8d65c9ee33584b92001bbba39df7020ffb12ea920665110e1e44e3aef7c71651",
"md5": "9944b5ab10202ee5366ae07eb12cd2e5",
"sha256": "75fd2bf22eb4bc576ade75c0b3744b449d19256dd7185397a6c7d74995a614ac"
},
"downloads": -1,
"filename": "ibmcloud-python-sdk-1.1.4.tar.gz",
"has_sig": false,
"md5_digest": "9944b5ab10202ee5366ae07eb12cd2e5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 79151,
"upload_time": "2024-03-27T14:47:34",
"upload_time_iso_8601": "2024-03-27T14:47:34.437927Z",
"url": "https://files.pythonhosted.org/packages/8d/65/c9ee33584b92001bbba39df7020ffb12ea920665110e1e44e3aef7c71651/ibmcloud-python-sdk-1.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-27 14:47:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "goldyfruit",
"github_project": "ibmcloud-python-sdk",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "PyYAML",
"specs": [
[
">=",
"3.12"
]
]
},
{
"name": "softlayer",
"specs": [
[
"==",
"5.8.7"
]
]
},
{
"name": "PyJWT",
"specs": [
[
"==",
"2.8.0"
]
]
},
{
"name": "ibm-cos-sdk",
"specs": [
[
"==",
"2.6.2"
]
]
},
{
"name": "botocore",
"specs": [
[
">=",
"1.16.9"
]
]
},
{
"name": "pymemcache",
"specs": [
[
"==",
"3.2.0"
]
]
},
{
"name": "cryptography",
"specs": [
[
"==",
"42.0.5"
]
]
}
],
"lcname": "ibmcloud-python-sdk"
}