Package: ibmcloud-python-sdk
IBM Cloud Python SDKEnvironment variablesDocumentationSupported featuresInstallationCachingPodmanDockerExamplesList VPCsCreate a VPC instanceFAQIBM Cloud Python SDKibmcloud-python-sdkaims to talk to IBM Cloud. To do this, it requires a configuration file.ibmcloud-python-sdkfavoursclouds.yamlfile, but can also use environment variables(seebelow). An example:---clouds:default:demo-accdemo-acc:profile:demodescription:Credentials from my IBM Cloud demo accountkey:XxX1234567890XxXregion:us-southversion:2021-06-15generation:2cis_username:000000_sponge.bob@sink.comcis_apikey:abc123def456ghi789klm0nprod-acc:profile:proddescription:Credentials from my IBM Cloud production accountkey:zZz1234567890zZzregion:us-southversion:2021-06-15generation:2cis_username:999999_sponge.bob@sink.comcis_apikey:@@abc123def456ghi789klm0n@@Theclouds.yamlfile will be searched at first into~/.ibmclouddirectory but this behavior could be overrided by an environment variable.Environment variablesVariableDescriptionExampleMandatoryIC_CONFIG_FILEAbsolute path to theclouds.yamlfile~/vault/ibm.yaml[ ]IC_CONFIG_NAMEName of the default cloud configurationdemo[ ]IC_REGIONRegion were to connectus-south[x]IC_VERSIONRequests the version of the API2021-06-15[x]IC_GENERATIONThe infrastructure generation for the request2[x]IC_SDK_CONFIG_FILEAbsolute path to thesdk.yamlfile~/.config/ibmcloud/sdk.yaml[ ]IC_API_KEYAPI key created via the IBM Cloud IAM systemXxX1234567890XxX[x]SL_USERNAMESoftLayer usergoldyfruit[ ]SL_API_KEYSoftLayer API keyabc123def456ghi789klm0n[ ]DocumentationDocumentation for the IBM Cloud Python SDK is availablehere.IBM Cloud Python SDK leverages existing Python SDKs such as:SoftLayerIBM Cloud Object StorageSupported featuresOnly VPC Gen 2 is supported by this SDK.ServiceFeatureCISBaremetal, Object StorageDNSPublic Zone, Private ZoneEMGet Account, Get EnterpriseIAMPolicies, RolesPOWERPower SystemRESOURCEBinding, Group, Instance, KeyVPCACL, FIP, Gateway, Geo, Image, Instance, Key, Load Balancer, Security, Subnet, Volume, VPC, VPNInstallationInstall from PyPi viapip:python-mvenv~/virtualenvs/ibmcloud-python-sdksource~/virtualenvs/ibmcloud-python-sdk/bin/activate
pipinstallibmcloud-python-sdkOr you can install from source:cd~/Git
gitclonehttps://github.com/goldyfruit/ibmcloud-python-sdk.git
python-mvenv~/virtualenvs/ibmcloud-python-sdksource~/virtualenvs/ibmcloud-python-sdk/bin/activatecd~/Git/ibmcloud-python-sdk
pipinstall.We recommend to use Python virtual environment to install the SDK.CachingThe SDK has caching capability(memcachedonly for now)to improve the HTTP requests speed. To enable this mechanisim please configure the SDK properly using~/.ibmcloud/sdk.yamlfile.---sdk:cache_ttl:60memcached:-127.0.0.1:11211Muttiple cache servers could be configured as well.---sdk:cache_ttl:60memcached:-127.0.0.1:11211-127.0.0.1:11212-127.0.0.1:11213An easy way to deploymemcachedserver is to use container.Podmanpodmanrun-dt-p11211:11211--namememcached-dmemcachedDockersudodockerrun-dt-p11211:11211--namememcached-dmemcachedExamplesA list of examples on how to use this SDK can be found athere.List VPCsfromibmcloud_python_sdk.vpcimportvpcasicvpc=ic.Vpc()vpc.get_vpc("ibmcloud-vpc-baby")Create a VPC instancefromibmcloud_python_sdk.vpcimportvpcasicvfromibmcloud_python_sdk.resourceimportresource_groupasicrimportsys# Variablesvpc_name='ibmcloud-vpc-baby'resource_group_name='ibmcloud-resource-group-baby'# Intentiate classesvpc=icv.Vpc()rg=icr.ResourceGroup()# Retrieve resource group ID and check for errorresource_group_info=rg.get_resource_group(resource_group_name)if'errors'inresource_group_info:print(resource_group_info['errors'])sys.exit()# Create the VPC based on variable and resource group IDresponse=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 processif'errors'inresponse:print(response['errors'])else:print(response)FAQCRNorHREFcould not be used as ID to retrieve resourcesPATCHmethod(update)is not yet supported which means a resource cannot be updatedCopyrightSee the bundledLICENSEfile for more information.