4.0.0rc1
Pre-release
Pre-release
Authentication is passed as an authenticator param when initializing the service
v4
Breaking changes
The v4 adds support only from python 3.5 and above. Major changes include:
Method optional param
The method params which are optional would need to be specified by name rather than position. For example:
The list_workspaces with page_limit
as 10
was:
assistant_service.list_workspaces(10)
Now, we need to specify the optional param name
assistant_service.list_workspaces(page_limit=10)
Authentication methods
There are 5 authentication variants supplied in the SDK (shown below), and it's possible now to create your own authentication implementation if you need something specific by implementing the Authenticator
implementation.
BasicAuthenticator
from ibm_cloud_sdk_core.authenticators import BasicAuthenticator
authenticator = BasicAuthenticator(<your_username>, <your_password>)
service = MyService(authenticator=authenticator)
BearerTokenAuthenticator
from ibm_cloud_sdk_core.authenticators import BearerTokenAuthenticator
authenticator = BearerTokenAuthenticator(<your_bearer_token>)
service = MyService(authenticator=authenticator)
# can set bearer token
service.get_authenticator().set_bearer_token('54321');
CloudPakForDataAuthenticator
from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator
authenticator = CloudPakForDataAuthenticator(
'my_username',
'my_password',
'https://my-cp4d-url',
disable_ssl_verification=True)
service = MyService(authenticator=authenticator)
IAMAuthenticator
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
authenticator = IAMAuthenticator('my_apikey')
service = MyService(authenticator=authenticator)
NoAuthAuthenticator
from ibm_cloud_sdk_core.authenticators import NoAuthAuthenticator
authenticator = NoAuthAuthenticator()
service = MyService(authenticator=authenticator)
Creating an Authenticator from Environmental Configuration
from ibm_cloud_sdk_core import get_authenticator_from_environment
authenticator = get_authenticator_from_environment('Assistant')
service = MyService(authenticator=authenticator)