|
| 1 | +Here are simple steps to move from `v3.0.0` to `v4.0.0`. Note that `v4.0,0` supports only python `3.5` and above |
| 2 | + |
| 3 | +## AUTHENTICATION MECHANISM |
| 4 | +The constructor no longer accepts individual credentials like `iam_apikey`, etc. We initialize authenticators from the [core](https://github.com/IBM/python-sdk-core). The core supports various authentication mechanisms, choose the one appropriate to your instance and use case. |
| 5 | + |
| 6 | +For example, to pass a IAM apikey: |
| 7 | +#### Before |
| 8 | +```python |
| 9 | +from ibm_watson import MyService |
| 10 | + |
| 11 | +service = MyService( |
| 12 | + iam_apikey='{apikey}', |
| 13 | + url='{url}' |
| 14 | +) |
| 15 | +``` |
| 16 | + |
| 17 | +#### After(V4.0) |
| 18 | +```python |
| 19 | +from ibm_watson import MyService |
| 20 | +from ibm_cloud_sdk_core.authenticators import IAMAuthenticator |
| 21 | + |
| 22 | +authenticator = IAMAuthenticator('{apikey}') |
| 23 | +service = MyService( |
| 24 | + authenticator=authenticator |
| 25 | +) |
| 26 | +service.set_service_url('{url}') |
| 27 | +``` |
| 28 | + |
| 29 | +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. |
| 30 | + |
| 31 | +#### BasicAuthenticator |
| 32 | +```python |
| 33 | +from ibm_cloud_sdk_core.authenticators import BasicAuthenticator |
| 34 | + |
| 35 | +authenticator = BasicAuthenticator(<your_username>, <your_password>) |
| 36 | +service = MyService(authenticator=authenticator) |
| 37 | +``` |
| 38 | + |
| 39 | +#### BearerTokenAuthenticator |
| 40 | +```python |
| 41 | +from ibm_cloud_sdk_core.authenticators import BearerTokenAuthenticator |
| 42 | + |
| 43 | +authenticator = BearerTokenAuthenticator(<your_bearer_token>) |
| 44 | +service = MyService(authenticator=authenticator) |
| 45 | + |
| 46 | +# can set bearer token |
| 47 | +service.get_authenticator().set_bearer_token('xxx'); |
| 48 | +``` |
| 49 | + |
| 50 | +#### CloudPakForDataAuthenticator |
| 51 | +```python |
| 52 | +from ibm_cloud_sdk_core.authenticators import CloudPakForDataAuthenticator |
| 53 | + |
| 54 | +authenticator = CloudPakForDataAuthenticator( |
| 55 | + 'my_username', |
| 56 | + 'my_password', |
| 57 | + 'https://my-cp4d-url', |
| 58 | + disable_ssl_verification=True) |
| 59 | +service = MyService(authenticator=authenticator) |
| 60 | +``` |
| 61 | + |
| 62 | +#### IAMAuthenticator |
| 63 | +```python |
| 64 | +from ibm_cloud_sdk_core.authenticators import IAMAuthenticator |
| 65 | + |
| 66 | +authenticator = IAMAuthenticator('my_apikey') |
| 67 | +service = MyService(authenticator=authenticator) |
| 68 | +``` |
| 69 | + |
| 70 | +#### NoAuthAuthenticator |
| 71 | +```python |
| 72 | +from ibm_cloud_sdk_core.authenticators import NoAuthAuthenticator |
| 73 | + |
| 74 | +authenticator = NoAuthAuthenticator() |
| 75 | +service = MyService(authenticator=authenticator) |
| 76 | +``` |
| 77 | + |
| 78 | +#### Creating an Authenticator from Environmental Configuration |
| 79 | +```python |
| 80 | +from ibm_cloud_sdk_core import get_authenticator_from_environment |
| 81 | + |
| 82 | +authenticator = get_authenticator_from_environment('Assistant') |
| 83 | +service = MyService(authenticator=authenticator) |
| 84 | +``` |
| 85 | + |
| 86 | +## SETTING THE SERVICE URL |
| 87 | +We can set the service url using `set_service_url()` or from external configurations. |
| 88 | + |
| 89 | +#### Before |
| 90 | +```python |
| 91 | +service = MyService( |
| 92 | + iam_apikey='{apikey}', |
| 93 | + url='{url}' # <= here |
| 94 | +) |
| 95 | +``` |
| 96 | + |
| 97 | +#### After(V4.0) |
| 98 | +```python |
| 99 | +service = MyService( |
| 100 | + authenticator=authenticator, |
| 101 | +) |
| 102 | +service.set_service_url('{url}') |
| 103 | +``` |
| 104 | + |
| 105 | +OR, pass from external configurations like environment variable |
| 106 | +```bash |
| 107 | +export MY_SERVICE_URL="<your url>" |
| 108 | +``` |
| 109 | + |
| 110 | +## METHOD OPTIONAL PARAM |
| 111 | +The method params which are optional would need to be specified by name rather than position. For example |
| 112 | + |
| 113 | +#### Before |
| 114 | +The list_workspaces with page_limit as 10 was: |
| 115 | + |
| 116 | +```python |
| 117 | +assistant_service.list_workspaces(10) |
| 118 | +``` |
| 119 | + |
| 120 | +#### After(V4.0) |
| 121 | +We need to specify the optional param name: |
| 122 | + |
| 123 | +```python |
| 124 | +assistant_service.list_workspaces(page_limit=10) |
| 125 | +``` |
| 126 | + |
| 127 | +## DISABLING SSL VERIFICATION |
| 128 | +#### Before |
| 129 | +```python |
| 130 | +service.disable_ssl_verification(True) |
| 131 | +``` |
| 132 | + |
| 133 | +#### After(v4.0) |
| 134 | +```python |
| 135 | +service.set_disable_ssl_verification(True) |
| 136 | +``` |
| 137 | + |
| 138 | +## SUPPORT FOR CONSTANTS |
| 139 | +Constants for methods and models are shown in the form of Enums |
| 140 | + |
| 141 | +## SUPPORT FOR PYTHON 2.7 and 3.4 AND BELOW DROPPED |
| 142 | +The SDK no longer supports Pyhton versions 2.7 and <=3.4. |
| 143 | + |
| 144 | +## SERVICE CHANGES |
| 145 | +#### AssistantV1 |
| 146 | +* `include_count` is no longer a parameter of the list_workspaces() method |
| 147 | +* `include_count` is no longer a parameter of the list_intents() method |
| 148 | +* `include_count` is no longer a parameter of the list_examples() method |
| 149 | +* `include_count` is no longer a parameter of the list_counterexamples() method |
| 150 | +* `include_count` is no longer a parameter of the list_entities() method |
| 151 | +* `include_count` is no longer a parameter of the list_values() method |
| 152 | +* `include_count` is no longer a parameter of the list_synonyms() method |
| 153 | +* `include_count` is no longer a parameter of the list_dialog_nodes() method |
| 154 | +* `value_type` was renamed to `type` in the create_value() method |
| 155 | +* `new_value_type` was renamed to `new_type` in the update_value() method |
| 156 | +* `node_type` was renamed to `type` in the create_dialog_node() method |
| 157 | +* `new_node_type` was renamed to `new_type` in the update_dialog_node() method |
| 158 | +* `value_type` was renamed to `type` in the CreateValue model |
| 159 | +* `node_type` was renamed to `type` in the DialogNode model |
| 160 | +* `action_type` was renamed to `type` in the DialogNodeAction model |
| 161 | +* `query_type` property was added to the DialogNodeOutputGeneric model |
| 162 | +* `query` property was added to the DialogNodeOutputGeneric model |
| 163 | +* `filter` property was added to the DialogNodeOutputGeneric model |
| 164 | +* `discovery_version` property was added to the DialogNodeOutputGeneric model |
| 165 | +* LogMessage model no longer has `_additionalProperties` |
| 166 | +* `DialogRuntimeResponseGeneric` was renamed to `RuntimeResponseGeneric` |
| 167 | +* RuntimeEntity model no longer has `_additionalProperties` |
| 168 | +* RuntimeIntent model no longer has `_additionalProperties` |
| 169 | +* `value_type` was renamed to `type` in the Value model |
| 170 | + |
| 171 | +#### AssistantV2 |
| 172 | +* `action_type` was renamed to `type` in the DialogNodeAction model |
| 173 | +* DialogRuntimeResponseGeneric was renamed to RuntimeResponseGeneric |
| 174 | + |
| 175 | +#### Compare and Comply |
| 176 | +* `convert_to_html()` method does not require a filename parameter |
| 177 | + |
| 178 | +#### DiscoveryV1 |
| 179 | +* `return_fields` was renamed to `return_` in the query() method |
| 180 | +* `logging_opt_out` was renamed to `x_watson_logging_opt_out` in the query() method |
| 181 | +* `spelling_suggestions` was added to the query() method |
| 182 | +* `collection_ids` is no longer a parameter of the query() method |
| 183 | +* `return_fields` was renamed to `return_` in the QueryNotices() method |
| 184 | +* `logging_opt_out` was renamed to `x_watson_logging_opt_out` in the federated_query() method |
| 185 | +* `collection_ids` is now required in the federated_query() method |
| 186 | +* `collection_ids` changed position in the federated_query() method |
| 187 | +* `return_fields` was renamed to `return_` in the federated_query() method |
| 188 | +* `return_fields` was renamed to `return_` in the federated_query_notices() method |
| 189 | +* `enrichment_name` was renamed to `enrichment` in the Enrichment model |
| 190 | +* `field_type` was renamed to `type` in the Field model |
| 191 | +* `field_name` was renamed to `field` in the Field model |
| 192 | +* test_configuration_in_environment() method was removed |
| 193 | +* query_entities() method was removed |
| 194 | +* query_relations() method was removed |
| 195 | + |
| 196 | +#### Language Translator V3 |
| 197 | +* `default_models` was renamed to `default` in the list_models() method |
| 198 | +* `translation_output` was renamed to `translation` in the Translation model |
| 199 | + |
| 200 | +#### Natural Language Classifier V1 |
| 201 | +* `metadata` was renamed to `training_metadata` in the `create_classifier()` method |
| 202 | + |
| 203 | +#### Speech to Text V1 |
| 204 | +* `final_results` was renamed to `final` in the SpeakerLabelsResult model |
| 205 | +* `final_results` was renamed to `final` in the SpeechRecognitionResult model |
| 206 | + |
| 207 | +#### Visual Recognition V3 |
| 208 | +* `detect_faces()` method was removed |
| 209 | +* `class_name` was renamed to `class_` in the ClassResult model |
| 210 | +* `class_name` was renamed to `class_` in the ModelClass model |
| 211 | + |
| 212 | +#### Visual Recognition V4 |
| 213 | +* New Service! |
| 214 | + |
| 215 | + |
0 commit comments