Skip to content

Commit 5642db9

Browse files
committed
docs(Readme): Update readme
1 parent 9b4ed86 commit 5642db9

File tree

1 file changed

+34
-43
lines changed

1 file changed

+34
-43
lines changed

README.md

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ You supply either an IAM service **API key** or an **access token**:
7070
```cs
7171
void Example()
7272
{
73-
IamConfig iamConfig = new IamConfig(
74-
apikey: "{iam-apikey}"
75-
);
76-
service = new AssistantService("{versionDate}", iamConfig);
73+
IamAuthenticator authenticator = new IamAuthenticator(
74+
apikey: "{apikey}");
75+
var service = new AssistantService("{versionDate}", authenticator);
7776
service.SetEndpoint("{service-endpoint}");
7877
}
7978
```
@@ -82,10 +81,9 @@ void Example()
8281
```cs
8382
void Example()
8483
{
85-
IamConfig iamConfig = new IamConfig(
86-
userManagedAccessToken: "{iam-access-token}"
87-
);
88-
service = new AssistantService("{versionDate}", iamConfig);
84+
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator(
85+
bearerToken: "{bearerToken}");
86+
var service = new AssistantService("{versionDate}", authenticator);
8987
service.SetEndpoint("{service-endpoint}");
9088
}
9189
```
@@ -94,11 +92,10 @@ void Example()
9492
```cs
9593
void Example()
9694
{
97-
BasicAuthConfig basicAuthConfig = new BasicAuthConfig(
95+
BasicAuthenticator authenticator = new BasicAuthenticator(
9896
username: "{username}",
99-
password: "{password}"
100-
);
101-
service = new AssistantService("{versionDate}", basicAuthConfig);
97+
password: "{password}");
98+
var service = new AssistantService("{versionDate}", authenticator);
10299
service.SetEndpoint("{service-endpoint}");
103100
}
104101
```
@@ -110,28 +107,25 @@ Like IAM, you can pass in credentials to let the SDK manage an access token for
110107
```cs
111108
void Example()
112109
{
113-
Icp4dConfig icp4dConfig = new Icp4dConfig(
110+
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
111+
url: "https://{cp4d_cluster_host}{:port}",
114112
username: "{username}",
115-
password: "{password}",
116-
url: "https://{icp4d_cluster_host}{:port}"
117-
);
118-
AssistantService assistant = new AssistantService("{version-date}", icp4dConfig);
113+
password: "{password}");
114+
var service = new AssistantService("{version-date}", authenticator);
119115
service.SetEndpoint("{service-endpoint}");
120-
var results = assistant.Message("{workspace-id}", "{message-request}");
116+
var results = service.Message("{workspace-id}", "{message-request}");
121117
}
122118
```
123119

124120
##### Managing the token yourself
125121
```cs
126122
void Example()
127123
{
128-
Icp4dConfig icp4dConfig = new Icp4dConfig(
129-
userManagedAccessToken: "{access-token}",
130-
url: "https://{icp4d_cluster_host}{:port}"
131-
);
132-
AssistantService assistant = new AssistantService("{version-date}", icp4dConfig);
124+
BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator(
125+
bearerToken: "{bearerToken}");
126+
var service = new AssistantService("{version-date}", authenticator);
133127
service.SetEndpoint("{service-endpoint}");
134-
var results = assistant.Message("{workspace-id}", "{message-request}");
128+
var results = service.Message("{workspace-id}", "{message-request}");
135129
}
136130
```
137131
Be sure to both [disable SSL verification](#self-signed-certificates) when authenticating and set the endpoint explicitly to the URL given in ICP.
@@ -152,8 +146,8 @@ The file downloaded will be called `ibm-credentials.env`. This is the name the S
152146
As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Discovery instance, you just need to do the following:
153147

154148
```cs
155-
AssistantService assistantService = new AssistantService();
156-
var listWorkspacesResult = assistantService.ListWorkspaces();
149+
AssistantService service = new AssistantService();
150+
var listWorkspacesResult = service.ListWorkspaces();
157151
```
158152

159153
And that's it!
@@ -177,13 +171,12 @@ You can send custom request headers by adding them to the service using `.WithHe
177171
```cs
178172
void Example()
179173
{
180-
IamConfig iamConfig = new IamConfig(
181-
apikey: "{iam-apikey}"
182-
);
183-
AssistantService assistant = new AssistantService("{version-date}", iamConfig);
174+
IamAuthenticator authenticator = new IamAuthenticator(
175+
apikey: "{apikey}");
176+
var service = new AssistantService("{version-date}", authenticator);
184177
service.SetEndpoint("{service-endpoint}");
185-
assistant.WithHeader("X-Watson-Metadata", "customer_id=some-assistant-customer-id");
186-
var results = assistant.Message("{workspace-id}", "{message-request}");
178+
service.WithHeader("X-Watson-Metadata", "customer_id=some-assistant-customer-id");
179+
var results = service.Message("{workspace-id}", "{message-request}");
187180
}
188181
```
189182

@@ -192,12 +185,11 @@ You can get the response headers, status code and the raw json response in the r
192185
```cs
193186
void Example()
194187
{
195-
IamConfig iamConfig = new IamConfig(
196-
apikey: "{iam-apikey}"
197-
);
198-
AssistantService assistant = new AssistantService("{version-date}", iamConfig);
188+
IamAuthenticator authenticator = new IamAuthenticator(
189+
apikey: "{apikey}");
190+
var service = new AssistantService("{version-date}", authenticator);
199191
service.SetEndpoint("{service-endpoint}");
200-
var results = assistant.Message("{workspace-id}", "{message-request}");
192+
var results = service.Message("{workspace-id}", "{message-request}");
201193

202194
var responseHeaders = results.Headers; // The response headers
203195
var responseJson = results.Response; // The raw response json
@@ -210,15 +202,14 @@ You can disable SSL verification on calls to Watson (only do this if you really
210202
```cs
211203
void Example()
212204
{
213-
Icp4dConfig icp4dConfig = new Icp4dConfig(
205+
CloudPakForDataAuthenticator authenticator = new CloudPakForDataAuthenticator(
206+
url: "https://{cp4d_cluster_host}{:port}",
214207
username: "{username}",
215208
password: "{password}",
216-
url: "https://{icp4d_cluster_host}{:port}",
217-
disableSslVerification: true
218-
);
219-
AssistantService assistant = new AssistantService("{version-date}", icp4dConfig);
209+
disableSslVerification: true);
210+
var service = new AssistantService("{version-date}", authenticator);
220211
service.SetEndpoint("{service-endpoint}");
221-
var results = assistant.Message("{workspace-id}", "{message-request}");
212+
var results = service.Message("{workspace-id}", "{message-request}");
222213
}
223214
```
224215

0 commit comments

Comments
 (0)