Skip to content

Commit 2ee9531

Browse files
committed
fix(discovery-v1): update status from string to StatusDetails
1 parent 1163183 commit 2ee9531

File tree

3 files changed

+55
-42
lines changed

3 files changed

+55
-42
lines changed

Scripts/Services/Discovery/V1/DiscoveryService.cs

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2019, 2021.
2+
* (C) Copyright IBM Corp. 2021.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -5141,12 +5141,10 @@ private void OnListCredentialsResponse(RESTConnector.Request req, RESTConnector.
51415141
/// <param name="credentialDetails">Object containing details of the stored credentials.
51425142
///
51435143
/// Obtain credentials for your source from the administrator of the source. (optional)</param>
5144-
/// <param name="status">The current status of this set of credentials. `connected` indicates that the
5145-
/// credentials are available to use with the source configuration of a collection. `invalid` refers to the
5146-
/// credentials (for example, the password provided has expired) and must be corrected before they can be used
5147-
/// with a collection. (optional)</param>
5144+
/// <param name="status">Object that contains details about the status of the authentication process.
5145+
/// (optional)</param>
51485146
/// <returns><see cref="ModelCredentials" />ModelCredentials</returns>
5149-
public bool CreateCredentials(Callback<ModelCredentials> callback, string environmentId, string sourceType = null, CredentialDetails credentialDetails = null, string status = null)
5147+
public bool CreateCredentials(Callback<ModelCredentials> callback, string environmentId, string sourceType = null, CredentialDetails credentialDetails = null, StatusDetails status = null)
51505148
{
51515149
if (callback == null)
51525150
throw new ArgumentNullException("`callback` is required for `CreateCredentials`");
@@ -5186,8 +5184,8 @@ public bool CreateCredentials(Callback<ModelCredentials> callback, string enviro
51865184
bodyObject["source_type"] = sourceType;
51875185
if (credentialDetails != null)
51885186
bodyObject["credential_details"] = JToken.FromObject(credentialDetails);
5189-
if (!string.IsNullOrEmpty(status))
5190-
bodyObject["status"] = status;
5187+
if (status != null)
5188+
bodyObject["status"] = JToken.FromObject(status);
51915189
req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject));
51925190

51935191
req.OnResponse = OnCreateCredentialsResponse;
@@ -5323,12 +5321,10 @@ private void OnGetCredentialsResponse(RESTConnector.Request req, RESTConnector.R
53235321
/// <param name="credentialDetails">Object containing details of the stored credentials.
53245322
///
53255323
/// Obtain credentials for your source from the administrator of the source. (optional)</param>
5326-
/// <param name="status">The current status of this set of credentials. `connected` indicates that the
5327-
/// credentials are available to use with the source configuration of a collection. `invalid` refers to the
5328-
/// credentials (for example, the password provided has expired) and must be corrected before they can be used
5329-
/// with a collection. (optional)</param>
5324+
/// <param name="status">Object that contains details about the status of the authentication process.
5325+
/// (optional)</param>
53305326
/// <returns><see cref="ModelCredentials" />ModelCredentials</returns>
5331-
public bool UpdateCredentials(Callback<ModelCredentials> callback, string environmentId, string credentialId, string sourceType = null, CredentialDetails credentialDetails = null, string status = null)
5327+
public bool UpdateCredentials(Callback<ModelCredentials> callback, string environmentId, string credentialId, string sourceType = null, CredentialDetails credentialDetails = null, StatusDetails status = null)
53325328
{
53335329
if (callback == null)
53345330
throw new ArgumentNullException("`callback` is required for `UpdateCredentials`");
@@ -5370,8 +5366,8 @@ public bool UpdateCredentials(Callback<ModelCredentials> callback, string enviro
53705366
bodyObject["source_type"] = sourceType;
53715367
if (credentialDetails != null)
53725368
bodyObject["credential_details"] = JToken.FromObject(credentialDetails);
5373-
if (!string.IsNullOrEmpty(status))
5374-
bodyObject["status"] = status;
5369+
if (status != null)
5370+
bodyObject["status"] = JToken.FromObject(status);
53755371
req.Send = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(bodyObject));
53765372

53775373
req.OnResponse = OnUpdateCredentialsResponse;

Scripts/Services/Discovery/V1/Model/ModelCredentials.cs

+6-27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018, 2019 IBM Corp. All Rights Reserved.
2+
* (C) Copyright IBM Corp. 2021.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,24 +57,6 @@ public class SourceTypeValue
5757

5858
}
5959

60-
/// <summary>
61-
/// The current status of this set of credentials. `connected` indicates that the credentials are available to
62-
/// use with the source configuration of a collection. `invalid` refers to the credentials (for example, the
63-
/// password provided has expired) and must be corrected before they can be used with a collection.
64-
/// </summary>
65-
public class StatusValue
66-
{
67-
/// <summary>
68-
/// Constant CONNECTED for connected
69-
/// </summary>
70-
public const string CONNECTED = "connected";
71-
/// <summary>
72-
/// Constant INVALID for invalid
73-
/// </summary>
74-
public const string INVALID = "invalid";
75-
76-
}
77-
7860
/// <summary>
7961
/// The source that this credentials object connects to.
8062
/// - `box` indicates the credentials are used to connect an instance of Enterprise Box.
@@ -87,14 +69,6 @@ public class StatusValue
8769
[JsonProperty("source_type", NullValueHandling = NullValueHandling.Ignore)]
8870
public string SourceType { get; set; }
8971
/// <summary>
90-
/// The current status of this set of credentials. `connected` indicates that the credentials are available to
91-
/// use with the source configuration of a collection. `invalid` refers to the credentials (for example, the
92-
/// password provided has expired) and must be corrected before they can be used with a collection.
93-
/// Constants for possible values can be found using ModelCredentials.StatusValue
94-
/// </summary>
95-
[JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)]
96-
public string Status { get; set; }
97-
/// <summary>
9872
/// Unique identifier for this set of credentials.
9973
/// </summary>
10074
[JsonProperty("credential_id", NullValueHandling = NullValueHandling.Ignore)]
@@ -106,5 +80,10 @@ public class StatusValue
10680
/// </summary>
10781
[JsonProperty("credential_details", NullValueHandling = NullValueHandling.Ignore)]
10882
public CredentialDetails CredentialDetails { get; set; }
83+
/// <summary>
84+
/// Object that contains details about the status of the authentication process.
85+
/// </summary>
86+
[JsonProperty("status", NullValueHandling = NullValueHandling.Ignore)]
87+
public StatusDetails Status { get; set; }
10988
}
11089
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2021.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using Newtonsoft.Json;
19+
20+
namespace IBM.Watson.Discovery.V1.Model
21+
{
22+
/// <summary>
23+
/// Object that contains details about the status of the authentication process.
24+
/// </summary>
25+
public class StatusDetails
26+
{
27+
/// <summary>
28+
/// Indicates whether the credential is accepted by the target data source.
29+
/// </summary>
30+
[JsonProperty("authentication", NullValueHandling = NullValueHandling.Ignore)]
31+
public bool? Authentication { get; set; }
32+
/// <summary>
33+
/// If `authentication` is `false`, a message describes why the authentication was unsuccessful.
34+
/// </summary>
35+
[JsonProperty("error_message", NullValueHandling = NullValueHandling.Ignore)]
36+
public string ErrorMessage { get; set; }
37+
}
38+
}

0 commit comments

Comments
 (0)