Skip to content

Commit

Permalink
fix(discovery-v1): status is now deserialized as an object
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkowa committed Sep 10, 2021
1 parent 2971a3b commit c72b497
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 67 deletions.
Expand Up @@ -2673,7 +2673,10 @@ public ServiceCall<Credentials> createCredentials(
.toJsonTree(createCredentialsOptions.credentialDetails()));
}
if (createCredentialsOptions.status() != null) {
contentJson.addProperty("status", createCredentialsOptions.status());
contentJson.add(
"status",
com.ibm.cloud.sdk.core.util.GsonSingleton.getGson()
.toJsonTree(createCredentialsOptions.status()));
}
builder.bodyJson(contentJson);
ResponseConverter<Credentials> responseConverter =
Expand Down Expand Up @@ -2760,7 +2763,10 @@ public ServiceCall<Credentials> updateCredentials(
.toJsonTree(updateCredentialsOptions.credentialDetails()));
}
if (updateCredentialsOptions.status() != null) {
contentJson.addProperty("status", updateCredentialsOptions.status());
contentJson.add(
"status",
com.ibm.cloud.sdk.core.util.GsonSingleton.getGson()
.toJsonTree(updateCredentialsOptions.status()));
}
builder.bodyJson(contentJson);
ResponseConverter<Credentials> responseConverter =
Expand Down
Expand Up @@ -38,30 +38,17 @@ public interface SourceType {
String CLOUD_OBJECT_STORAGE = "cloud_object_storage";
}

/**
* The current status of this set of credentials. `connected` indicates that the credentials are
* available to use with the source configuration of a collection. `invalid` refers to the
* credentials (for example, the password provided has expired) and must be corrected before they
* can be used with a collection.
*/
public interface Status {
/** connected. */
String CONNECTED = "connected";
/** invalid. */
String INVALID = "invalid";
}

protected String environmentId;
protected String sourceType;
protected CredentialDetails credentialDetails;
protected String status;
protected StatusDetails status;

/** Builder. */
public static class Builder {
private String environmentId;
private String sourceType;
private CredentialDetails credentialDetails;
private String status;
private StatusDetails status;

private Builder(CreateCredentialsOptions createCredentialsOptions) {
this.environmentId = createCredentialsOptions.environmentId;
Expand Down Expand Up @@ -130,7 +117,7 @@ public Builder credentialDetails(CredentialDetails credentialDetails) {
* @param status the status
* @return the CreateCredentialsOptions builder
*/
public Builder status(String status) {
public Builder status(StatusDetails status) {
this.status = status;
return this;
}
Expand Down Expand Up @@ -210,14 +197,11 @@ public CredentialDetails credentialDetails() {
/**
* Gets the status.
*
* <p>The current status of this set of credentials. `connected` indicates that the credentials
* are available to use with the source configuration of a collection. `invalid` refers to the
* credentials (for example, the password provided has expired) and must be corrected before they
* can be used with a collection.
* <p>Object that contains details about the status of the authentication process.
*
* @return the status
*/
public String status() {
public StatusDetails status() {
return status;
}
}
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2018, 2020.
* (C) Copyright IBM Corp. 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -39,19 +39,6 @@ public interface SourceType {
String CLOUD_OBJECT_STORAGE = "cloud_object_storage";
}

/**
* The current status of this set of credentials. `connected` indicates that the credentials are
* available to use with the source configuration of a collection. `invalid` refers to the
* credentials (for example, the password provided has expired) and must be corrected before they
* can be used with a collection.
*/
public interface Status {
/** connected. */
String CONNECTED = "connected";
/** invalid. */
String INVALID = "invalid";
}

@SerializedName("credential_id")
protected String credentialId;

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

protected String status;
protected StatusDetails status;

/** Builder. */
public static class Builder {
private String sourceType;
private CredentialDetails credentialDetails;
private String status;
private StatusDetails status;

private Builder(Credentials credentials) {
this.sourceType = credentials.sourceType;
Expand Down Expand Up @@ -115,7 +102,7 @@ public Builder credentialDetails(CredentialDetails credentialDetails) {
* @param status the status
* @return the Credentials builder
*/
public Builder status(String status) {
public Builder status(StatusDetails status) {
this.status = status;
return this;
}
Expand Down Expand Up @@ -179,14 +166,11 @@ public CredentialDetails credentialDetails() {
/**
* Gets the status.
*
* <p>The current status of this set of credentials. `connected` indicates that the credentials
* are available to use with the source configuration of a collection. `invalid` refers to the
* credentials (for example, the password provided has expired) and must be corrected before they
* can be used with a collection.
* <p>Object that contains details about the status of the authentication process.
*
* @return the status
*/
public String status() {
public StatusDetails status() {
return status;
}
}
@@ -0,0 +1,106 @@
/*
* (C) Copyright IBM Corp. 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.ibm.watson.discovery.v1.model;

import com.google.gson.annotations.SerializedName;
import com.ibm.cloud.sdk.core.service.model.GenericModel;

/** Object that contains details about the status of the authentication process. */
public class StatusDetails extends GenericModel {

protected Boolean authentication;

@SerializedName("error_message")
protected String errorMessage;

/** Builder. */
public static class Builder {
private Boolean authentication;
private String errorMessage;

private Builder(StatusDetails statusDetails) {
this.authentication = statusDetails.authentication;
this.errorMessage = statusDetails.errorMessage;
}

/** Instantiates a new builder. */
public Builder() {}

/**
* Builds a StatusDetails.
*
* @return the new StatusDetails instance
*/
public StatusDetails build() {
return new StatusDetails(this);
}

/**
* Set the authentication.
*
* @param authentication the authentication
* @return the StatusDetails builder
*/
public Builder authentication(Boolean authentication) {
this.authentication = authentication;
return this;
}

/**
* Set the errorMessage.
*
* @param errorMessage the errorMessage
* @return the StatusDetails builder
*/
public Builder errorMessage(String errorMessage) {
this.errorMessage = errorMessage;
return this;
}
}

protected StatusDetails(Builder builder) {
authentication = builder.authentication;
errorMessage = builder.errorMessage;
}

/**
* New builder.
*
* @return a StatusDetails builder
*/
public Builder newBuilder() {
return new Builder(this);
}

/**
* Gets the authentication.
*
* <p>Indicates whether the credential is accepted by the target data source.
*
* @return the authentication
*/
public Boolean authentication() {
return authentication;
}

/**
* Gets the errorMessage.
*
* <p>If `authentication` is `false`, a message describes why the authentication was unsuccessful.
*
* @return the errorMessage
*/
public String errorMessage() {
return errorMessage;
}
}
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2018, 2020.
* (C) Copyright IBM Corp. 2021.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -38,32 +38,19 @@ public interface SourceType {
String CLOUD_OBJECT_STORAGE = "cloud_object_storage";
}

/**
* The current status of this set of credentials. `connected` indicates that the credentials are
* available to use with the source configuration of a collection. `invalid` refers to the
* credentials (for example, the password provided has expired) and must be corrected before they
* can be used with a collection.
*/
public interface Status {
/** connected. */
String CONNECTED = "connected";
/** invalid. */
String INVALID = "invalid";
}

protected String environmentId;
protected String credentialId;
protected String sourceType;
protected CredentialDetails credentialDetails;
protected String status;
protected StatusDetails status;

/** Builder. */
public static class Builder {
private String environmentId;
private String credentialId;
private String sourceType;
private CredentialDetails credentialDetails;
private String status;
private StatusDetails status;

private Builder(UpdateCredentialsOptions updateCredentialsOptions) {
this.environmentId = updateCredentialsOptions.environmentId;
Expand Down Expand Up @@ -146,7 +133,7 @@ public Builder credentialDetails(CredentialDetails credentialDetails) {
* @param status the status
* @return the UpdateCredentialsOptions builder
*/
public Builder status(String status) {
public Builder status(StatusDetails status) {
this.status = status;
return this;
}
Expand Down Expand Up @@ -240,14 +227,11 @@ public CredentialDetails credentialDetails() {
/**
* Gets the status.
*
* <p>The current status of this set of credentials. `connected` indicates that the credentials
* are available to use with the source configuration of a collection. `invalid` refers to the
* credentials (for example, the password provided has expired) and must be corrected before they
* can be used with a collection.
* <p>Object that contains details about the status of the authentication process.
*
* @return the status
*/
public String status() {
public StatusDetails status() {
return status;
}
}

0 comments on commit c72b497

Please sign in to comment.