|
| 1 | +### Ruby SDK V1 Migration guide |
| 2 | + |
| 3 | +#### Authentication |
| 4 | + |
| 5 | +##### v0.x.x |
| 6 | + |
| 7 | +Previously different parameters were passed into the service constructor for authentication. |
| 8 | + |
| 9 | +```ruby |
| 10 | +def example |
| 11 | + service = IBMWatson::AssistantV1.new( |
| 12 | + iam_apikey: "{iam_apikey}", |
| 13 | + url: "{service_endpoint}", |
| 14 | + version: "{version_date}" |
| 15 | + ); |
| 16 | + service.url = "{service_endpoint}"; |
| 17 | +end |
| 18 | +``` |
| 19 | + |
| 20 | +##### v1.x.x |
| 21 | + |
| 22 | +Now we use an `Authenticator` to authenticate the service. Available authentication schemes include `IamAuthenticator`, `BasicAuthenticator`, `CloudPakForDataAuthenticator` and `BearerTokenAuthenticator` |
| 23 | + |
| 24 | +###### IamAuthenticator |
| 25 | + |
| 26 | +```ruby |
| 27 | +def example |
| 28 | + authenticator = IBMWatson::Authenticators::IamAuthenticator.new( |
| 29 | + apikey: "{apikey}" |
| 30 | + ) |
| 31 | + service = IBMWatson::AssistantV1.new( |
| 32 | + authenticator: authenticator, |
| 33 | + version: "{version_date}" |
| 34 | + ); |
| 35 | + service.service_url = "{serviceUrl}"; |
| 36 | +end |
| 37 | +``` |
| 38 | + |
| 39 | +##### BasicAuthenticator |
| 40 | + |
| 41 | +```ruby |
| 42 | +def example |
| 43 | + authenticator = IBMWatson::Authenticators::BasicAuthenticator.new( |
| 44 | + username: "{username}", |
| 45 | + password: "{password}" |
| 46 | + ) |
| 47 | + service = IBMWatson::AssistantV1.new( |
| 48 | + authenticator: authenticator, |
| 49 | + version: "{version_date}" |
| 50 | + ); |
| 51 | + service.service_url = "{serviceUrl}"; |
| 52 | +end |
| 53 | +``` |
| 54 | + |
| 55 | +###### BearerTokenAuthenticator |
| 56 | + |
| 57 | +```ruby |
| 58 | + authenticator = IBMWatson::Authenticators::BearerTokenAuthenticator.new( |
| 59 | + bearer_token: "{bearerToken}" |
| 60 | + ) |
| 61 | + service = IBMWatson::AssistantV1.new( |
| 62 | + authenticator: authenticator, |
| 63 | + version: "{version_date}" |
| 64 | + ); |
| 65 | + service.service_url = "{serviceUrl}"; |
| 66 | +``` |
| 67 | + |
| 68 | +###### CloudPakForDataAuthenticator |
| 69 | + |
| 70 | +```ruby |
| 71 | + authenticator = IBMWatson::Authenticators::CloudPakForDataAuthenticator.new( |
| 72 | + url: "https://{cp4d_cluster_host}{:port}", |
| 73 | + username: "{username}", |
| 74 | + password: "{password}" |
| 75 | + ) |
| 76 | + service = IBMWatson::AssistantV1.new( |
| 77 | + authenticator: authenticator, |
| 78 | + version: "{version_date}" |
| 79 | + ); |
| 80 | + service.service_url = "{serviceUrl}"; |
| 81 | +``` |
| 82 | + |
| 83 | +#### Supplying credentials |
| 84 | + |
| 85 | +You can supply credentials to your service using external `ibm-credentials.env` files. |
| 86 | + |
| 87 | +```ruby |
| 88 | + service = IBMWatson::AssistantV1.new( |
| 89 | + version: "{version_date}" |
| 90 | + ); |
| 91 | + response = service.list_workspaces.result |
| 92 | + puts JSON.pretty_generate(response) |
| 93 | +``` |
| 94 | + |
| 95 | +##### v0.x.x |
| 96 | + |
| 97 | +Previously we would look for these files first in the system `home` directory, followed by the current project directory. |
| 98 | + |
| 99 | +##### v1.x.x |
| 100 | +Now in order to allow developers to have different configurations for each project we look first in the current project directory, followed by the home directory. |
| 101 | + |
| 102 | +#### Setting the service url |
| 103 | + |
| 104 | +##### v0.x.x |
| 105 | + |
| 106 | +Previously we set the service url by setting url. |
| 107 | + |
| 108 | +```ruby |
| 109 | +def example |
| 110 | + service = IBMWatson::AssistantV1.new( |
| 111 | + iam_apikey: "{iam_apikey}", |
| 112 | + url: "{service_endpoint}", |
| 113 | + version: "{version_date}" |
| 114 | + ); |
| 115 | + service.url = "{service_endpoint}"; |
| 116 | +end |
| 117 | +``` |
| 118 | + |
| 119 | +##### v1.x.x |
| 120 | + |
| 121 | +Now we set the service url by calling the `service_url` setter. |
| 122 | + |
| 123 | +```ruby |
| 124 | +def example |
| 125 | + authenticator = IBMWatson::Authenticators::IamAuthenticator.new( |
| 126 | + apikey: "{apikey}" |
| 127 | + ) |
| 128 | + service = IBMWatson::AssistantV1.new( |
| 129 | + authenticator: authenticator, |
| 130 | + version: "{version_date}" |
| 131 | + ); |
| 132 | + service.service_url = "{serviceUrl}"; |
| 133 | +end |
| 134 | +``` |
| 135 | + |
| 136 | +#### Service changes |
| 137 | + |
| 138 | +##### Assistant v1 |
| 139 | + |
| 140 | +* `include_count` is no longer a parameter of the `list_workspaces()` method |
| 141 | +* `include_count` is no longer a parameter of the `list_intents()` method |
| 142 | +* `include_count` is no longer a parameter of the `list_examples()` method |
| 143 | +* `include_count` is no longer a parameter of the `list_counterexamples()` method |
| 144 | +* `include_count` is no longer a parameter of the `list_entities()` method |
| 145 | +* `include_count` is no longer a parameter of the `list_values()` method |
| 146 | +* `include_count` is no longer a parameter of the `list_synonyms()` method |
| 147 | +* `include_count` is no longer a parameter of the `list_dialogNodes()` method |
| 148 | +* `value_type` was renamed to `type` in the `calue()` method |
| 149 | +* `new_value_type` was renamed to `newType` in the `update_value()` method |
| 150 | +* `node_type` was renamed to `type` in the `create_dialog_node()` method |
| 151 | +* `node_type` was renamed to `type` in the `create_dialog_node()` method |
| 152 | +* `new_node_type` was renamed to `new_type` in the `update_dialog_node()` method |
| 153 | + |
| 154 | +##### Compare Comply v1 |
| 155 | + |
| 156 | +* `convert_to_html()` method does not require a `filename` parameter |
| 157 | + |
| 158 | +##### Discovery v1 |
| 159 | + |
| 160 | +* `return_fields` was renamed to `_return` in the `query()` method |
| 161 | +* `logging_optOut` was renamed to `x_watson_logging_optOut` in the `query()` method |
| 162 | +* `spelling_suggestions` was added to the `query()` method |
| 163 | +* `collection_ids` is no longer a parameter of the `query()` method |
| 164 | +* `return_fields` was renamed to `_return` in the `QueryNotices()` method |
| 165 | +* `logging_optOut` was renamed to `x_watson_logging_optOut` in the `federated_query()` method |
| 166 | +* `collection_ids` is now required in the `federated_query()` method |
| 167 | +* `collection_ids` changed position in the `federated_query()` method |
| 168 | +* `return_fields` was renamed to `_return` in the `federated_query()` method |
| 169 | +* `return_fields` was renamed to `_return` in the `federated_query_notices()` method |
| 170 | +* `test_configuration_in_environment()` method was removed |
| 171 | +* `query_entities()` method was removed |
| 172 | +* `query_relations()` method was removed |
| 173 | + |
| 174 | +##### Language Translator v3 |
| 175 | + |
| 176 | +* `default_models` was renamed to `_default` in the `list_models()` method |
| 177 | + |
| 178 | +##### Natural Language Classifier v1 |
| 179 | + |
| 180 | +* `metadata` was renamed to `training_metadata` in the `create_classifier()` method |
| 181 | + |
| 182 | +##### Speech to Text v1 |
| 183 | + |
| 184 | +* `strict` is no longer a parameter of the `train_acoustic_model()` method |
| 185 | +* `recognize_with_websocket()` method was removed |
| 186 | + |
| 187 | +##### Visual Recognition v3 |
| 188 | + |
| 189 | +* `detect_faces()` method was removed |
| 190 | + |
| 191 | +##### Visual Recognition v4 |
| 192 | + |
| 193 | +* New service! |
0 commit comments