Skip to content

Commit c72b497

Browse files
committed
fix(discovery-v1): status is now deserialized as an object
1 parent 2971a3b commit c72b497

File tree

5 files changed

+131
-67
lines changed

5 files changed

+131
-67
lines changed

discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,7 +2673,10 @@ public ServiceCall<Credentials> createCredentials(
26732673
.toJsonTree(createCredentialsOptions.credentialDetails()));
26742674
}
26752675
if (createCredentialsOptions.status() != null) {
2676-
contentJson.addProperty("status", createCredentialsOptions.status());
2676+
contentJson.add(
2677+
"status",
2678+
com.ibm.cloud.sdk.core.util.GsonSingleton.getGson()
2679+
.toJsonTree(createCredentialsOptions.status()));
26772680
}
26782681
builder.bodyJson(contentJson);
26792682
ResponseConverter<Credentials> responseConverter =
@@ -2760,7 +2763,10 @@ public ServiceCall<Credentials> updateCredentials(
27602763
.toJsonTree(updateCredentialsOptions.credentialDetails()));
27612764
}
27622765
if (updateCredentialsOptions.status() != null) {
2763-
contentJson.addProperty("status", updateCredentialsOptions.status());
2766+
contentJson.add(
2767+
"status",
2768+
com.ibm.cloud.sdk.core.util.GsonSingleton.getGson()
2769+
.toJsonTree(updateCredentialsOptions.status()));
27642770
}
27652771
builder.bodyJson(contentJson);
27662772
ResponseConverter<Credentials> responseConverter =

discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptions.java

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,17 @@ public interface SourceType {
3838
String CLOUD_OBJECT_STORAGE = "cloud_object_storage";
3939
}
4040

41-
/**
42-
* The current status of this set of credentials. `connected` indicates that the credentials are
43-
* available to use with the source configuration of a collection. `invalid` refers to the
44-
* credentials (for example, the password provided has expired) and must be corrected before they
45-
* can be used with a collection.
46-
*/
47-
public interface Status {
48-
/** connected. */
49-
String CONNECTED = "connected";
50-
/** invalid. */
51-
String INVALID = "invalid";
52-
}
53-
5441
protected String environmentId;
5542
protected String sourceType;
5643
protected CredentialDetails credentialDetails;
57-
protected String status;
44+
protected StatusDetails status;
5845

5946
/** Builder. */
6047
public static class Builder {
6148
private String environmentId;
6249
private String sourceType;
6350
private CredentialDetails credentialDetails;
64-
private String status;
51+
private StatusDetails status;
6552

6653
private Builder(CreateCredentialsOptions createCredentialsOptions) {
6754
this.environmentId = createCredentialsOptions.environmentId;
@@ -130,7 +117,7 @@ public Builder credentialDetails(CredentialDetails credentialDetails) {
130117
* @param status the status
131118
* @return the CreateCredentialsOptions builder
132119
*/
133-
public Builder status(String status) {
120+
public Builder status(StatusDetails status) {
134121
this.status = status;
135122
return this;
136123
}
@@ -210,14 +197,11 @@ public CredentialDetails credentialDetails() {
210197
/**
211198
* Gets the status.
212199
*
213-
* <p>The current status of this set of credentials. `connected` indicates that the credentials
214-
* are available to use with the source configuration of a collection. `invalid` refers to the
215-
* credentials (for example, the password provided has expired) and must be corrected before they
216-
* can be used with a collection.
200+
* <p>Object that contains details about the status of the authentication process.
217201
*
218202
* @return the status
219203
*/
220-
public String status() {
204+
public StatusDetails status() {
221205
return status;
222206
}
223207
}

discovery/src/main/java/com/ibm/watson/discovery/v1/model/Credentials.java

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2018, 2020.
2+
* (C) Copyright IBM Corp. 2021.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -39,19 +39,6 @@ public interface SourceType {
3939
String CLOUD_OBJECT_STORAGE = "cloud_object_storage";
4040
}
4141

42-
/**
43-
* The current status of this set of credentials. `connected` indicates that the credentials are
44-
* available to use with the source configuration of a collection. `invalid` refers to the
45-
* credentials (for example, the password provided has expired) and must be corrected before they
46-
* can be used with a collection.
47-
*/
48-
public interface Status {
49-
/** connected. */
50-
String CONNECTED = "connected";
51-
/** invalid. */
52-
String INVALID = "invalid";
53-
}
54-
5542
@SerializedName("credential_id")
5643
protected String credentialId;
5744

@@ -61,13 +48,13 @@ public interface Status {
6148
@SerializedName("credential_details")
6249
protected CredentialDetails credentialDetails;
6350

64-
protected String status;
51+
protected StatusDetails status;
6552

6653
/** Builder. */
6754
public static class Builder {
6855
private String sourceType;
6956
private CredentialDetails credentialDetails;
70-
private String status;
57+
private StatusDetails status;
7158

7259
private Builder(Credentials credentials) {
7360
this.sourceType = credentials.sourceType;
@@ -115,7 +102,7 @@ public Builder credentialDetails(CredentialDetails credentialDetails) {
115102
* @param status the status
116103
* @return the Credentials builder
117104
*/
118-
public Builder status(String status) {
105+
public Builder status(StatusDetails status) {
119106
this.status = status;
120107
return this;
121108
}
@@ -179,14 +166,11 @@ public CredentialDetails credentialDetails() {
179166
/**
180167
* Gets the status.
181168
*
182-
* <p>The current status of this set of credentials. `connected` indicates that the credentials
183-
* are available to use with the source configuration of a collection. `invalid` refers to the
184-
* credentials (for example, the password provided has expired) and must be corrected before they
185-
* can be used with a collection.
169+
* <p>Object that contains details about the status of the authentication process.
186170
*
187171
* @return the status
188172
*/
189-
public String status() {
173+
public StatusDetails status() {
190174
return status;
191175
}
192176
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* (C) Copyright IBM Corp. 2021.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.discovery.v1.model;
14+
15+
import com.google.gson.annotations.SerializedName;
16+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
17+
18+
/** Object that contains details about the status of the authentication process. */
19+
public class StatusDetails extends GenericModel {
20+
21+
protected Boolean authentication;
22+
23+
@SerializedName("error_message")
24+
protected String errorMessage;
25+
26+
/** Builder. */
27+
public static class Builder {
28+
private Boolean authentication;
29+
private String errorMessage;
30+
31+
private Builder(StatusDetails statusDetails) {
32+
this.authentication = statusDetails.authentication;
33+
this.errorMessage = statusDetails.errorMessage;
34+
}
35+
36+
/** Instantiates a new builder. */
37+
public Builder() {}
38+
39+
/**
40+
* Builds a StatusDetails.
41+
*
42+
* @return the new StatusDetails instance
43+
*/
44+
public StatusDetails build() {
45+
return new StatusDetails(this);
46+
}
47+
48+
/**
49+
* Set the authentication.
50+
*
51+
* @param authentication the authentication
52+
* @return the StatusDetails builder
53+
*/
54+
public Builder authentication(Boolean authentication) {
55+
this.authentication = authentication;
56+
return this;
57+
}
58+
59+
/**
60+
* Set the errorMessage.
61+
*
62+
* @param errorMessage the errorMessage
63+
* @return the StatusDetails builder
64+
*/
65+
public Builder errorMessage(String errorMessage) {
66+
this.errorMessage = errorMessage;
67+
return this;
68+
}
69+
}
70+
71+
protected StatusDetails(Builder builder) {
72+
authentication = builder.authentication;
73+
errorMessage = builder.errorMessage;
74+
}
75+
76+
/**
77+
* New builder.
78+
*
79+
* @return a StatusDetails builder
80+
*/
81+
public Builder newBuilder() {
82+
return new Builder(this);
83+
}
84+
85+
/**
86+
* Gets the authentication.
87+
*
88+
* <p>Indicates whether the credential is accepted by the target data source.
89+
*
90+
* @return the authentication
91+
*/
92+
public Boolean authentication() {
93+
return authentication;
94+
}
95+
96+
/**
97+
* Gets the errorMessage.
98+
*
99+
* <p>If `authentication` is `false`, a message describes why the authentication was unsuccessful.
100+
*
101+
* @return the errorMessage
102+
*/
103+
public String errorMessage() {
104+
return errorMessage;
105+
}
106+
}

discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptions.java

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2018, 2020.
2+
* (C) Copyright IBM Corp. 2021.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -38,32 +38,19 @@ public interface SourceType {
3838
String CLOUD_OBJECT_STORAGE = "cloud_object_storage";
3939
}
4040

41-
/**
42-
* The current status of this set of credentials. `connected` indicates that the credentials are
43-
* available to use with the source configuration of a collection. `invalid` refers to the
44-
* credentials (for example, the password provided has expired) and must be corrected before they
45-
* can be used with a collection.
46-
*/
47-
public interface Status {
48-
/** connected. */
49-
String CONNECTED = "connected";
50-
/** invalid. */
51-
String INVALID = "invalid";
52-
}
53-
5441
protected String environmentId;
5542
protected String credentialId;
5643
protected String sourceType;
5744
protected CredentialDetails credentialDetails;
58-
protected String status;
45+
protected StatusDetails status;
5946

6047
/** Builder. */
6148
public static class Builder {
6249
private String environmentId;
6350
private String credentialId;
6451
private String sourceType;
6552
private CredentialDetails credentialDetails;
66-
private String status;
53+
private StatusDetails status;
6754

6855
private Builder(UpdateCredentialsOptions updateCredentialsOptions) {
6956
this.environmentId = updateCredentialsOptions.environmentId;
@@ -146,7 +133,7 @@ public Builder credentialDetails(CredentialDetails credentialDetails) {
146133
* @param status the status
147134
* @return the UpdateCredentialsOptions builder
148135
*/
149-
public Builder status(String status) {
136+
public Builder status(StatusDetails status) {
150137
this.status = status;
151138
return this;
152139
}
@@ -240,14 +227,11 @@ public CredentialDetails credentialDetails() {
240227
/**
241228
* Gets the status.
242229
*
243-
* <p>The current status of this set of credentials. `connected` indicates that the credentials
244-
* are available to use with the source configuration of a collection. `invalid` refers to the
245-
* credentials (for example, the password provided has expired) and must be corrected before they
246-
* can be used with a collection.
230+
* <p>Object that contains details about the status of the authentication process.
247231
*
248232
* @return the status
249233
*/
250-
public String status() {
234+
public StatusDetails status() {
251235
return status;
252236
}
253237
}

0 commit comments

Comments
 (0)