Package: osc-sdk-python
Outscale Python SDKThis python SDK helps you to perform actions onOutscale API.You will need to have an Outscale account, please visitOutscale website.InstallationYou can install the pre-built python package through this command:$pipinstallosc-sdk-pythonBuildingTo build the package yourself:$makepackageYou can then install it with:$pipinstalldist/osc_sdk_python-0.27.0-py3-none-any.whlConfiguration & CredentialsWhen you use the cli you can choose a profile. Profiles can be set with environment variables or in a file.
It checks environment variables before loading the file.In the file, you can set a default profile, namingdefault. It will be used if you don't precise profile in command line.Environment variables$exportOSC_ACCESS_KEY=<ACCESS_KEY>
$exportOSC_SECRET_KEY=<SECRET_KEY>
$# optional$exportOSC_REGION=<REGION>(default:eu-west-2)Credentials files$cat~/.osc/config.json{"default":{"access_key":"<ACCESS_KEY>","secret_key":"<SECRET_KEY>","region":"<REGION>"},"profile_1":{"access_key":"<ACCESS_KEY>","secret_key":"<SECRET_KEY>","region":"<REGION>"},"profile_2":{"access_key":"<ACCESS_KEY>","secret_key":"<SECRET_KEY>","region":"<REGION>"}}Notes:if  ~/.osc/config.json is not found, ~/.oapi_credentials will be usedEnvironment variables have priority over Credentials files.Basic AuthenticationYou can also use osc-sdk-python with basic authentication mechanism using your account's email and password. Note that some calls may be blocked with this method.
More details inauthentication documentation.Example:gw=Gateway(email="your@email.com",password="youAccountPassword")keys=gw.ReadAccessKeys()ExampleA simple example which prints all your Virtual Machine and Volume ids.fromosc_sdk_pythonimportGatewayif__name__=='__main__':gw=Gateway()print("your virtual machines:")forvmingw.ReadVms()["Vms"]:print(vm["VmId"])print("\nyour volumes:")forvolumeingw.ReadVolumes()["Volumes"]:print(volume["VolumeId"])Usage example, checkOutscale API documentationfor more details.fromosc_sdk_pythonimportGatewayif__name__=='__main__':gw=Gateway(**{'profile':'profile_1'})# Calls with api Action as methodresult=gw.ReadSecurityGroups(Filters={'SecurityGroupNames':['default']})result=gw.CreateVms(ImageId='ami-3e158364',VmType='tinav4.c2r4')# Or raw calls:result=gw.raw('ReadVms')result=gw.raw('CreateVms',ImageId='ami-xx',BlockDeviceMappings=[{'/dev/sda1':{'Size':10}}],SecurityGroupIds=['sg-aaa','sg-bbb'],Wrong='wrong')Another example with logsfromosc_sdk_pythonimport*if__name__=='__main__':gw=Gateway(**{'profile':'profile_1'})# what can contain LOG_KEEP_ONLY_LAST_REQ or LOG_ALL# here we pront log in memory, in standard output and in satndard errorgw.log.config(type=LOG_MEMORY|LOG_STDIO|LOG_STDERR,what=LOG_KEEP_ONLY_LAST_REQ)# Or raw calls:result=gw.raw('ReadVms')last_request=gw.log.str()print(last_request)Known IssuesUTF-8Some people my encounter some issue with utf-8 which looks like thisProblemreading(…)osc_sdk_python/osc-api/outscale.yaml:'ascii'codeccan'tdecodebyte0xe2inposition14856:ordinalnotinrange(128)To avoid this issue, configure you locals as follow:LC_ALL=en_US.UTF-8if you don't want your locals to be set system wide you can proceed as follow:LC_ALL=en_US.UTF-8pipinstallosc-sdk-python