Skip to content

Commit

Permalink
[PLAT-3154] [PLAT-2546] Fix API docs for runQuery to add request body…
Browse files Browse the repository at this point in the history
… type

Summary:
Add missing implicit params docs
Generated new swagger spec

Test Plan: Docs only change. Run unit test and eyeball swagger spec.

Reviewers: spotachev

Reviewed By: spotachev

Subscribers: yugaware

Differential Revision: https://phabricator.dev.yugabyte.com/D15566
  • Loading branch information
sb-yb committed Feb 18, 2022
1 parent e9efe5d commit b4215a5
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,25 @@
import com.yugabyte.yw.models.Universe;
import com.yugabyte.yw.models.Users;
import com.yugabyte.yw.models.extended.UserWithFeatures;
import io.ebean.annotation.Transactional;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Authorization;
import io.ebean.DuplicateKeyException;
import io.ebean.annotation.Transactional;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.time.Duration;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletionStage;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -69,14 +72,7 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.input.ReversedLinesFileReader;
import org.apache.directory.api.ldap.model.cursor.EntryCursor;
import org.apache.directory.api.ldap.model.entry.Attribute;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapAuthenticationException;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.ldap.client.api.LdapNetworkConnection;
import org.pac4j.core.profile.CommonProfile;
import org.pac4j.core.profile.ProfileManager;
import org.pac4j.play.PlayWebContext;
Expand All @@ -88,7 +84,6 @@
import play.Environment;
import play.data.Form;
import play.libs.Json;
import play.libs.concurrent.HttpExecutionContext;
import play.libs.ws.WSClient;
import play.libs.ws.WSRequest;
import play.mvc.Http;
Expand Down Expand Up @@ -127,8 +122,6 @@ public class SessionController extends AbstractPlatformController {

@Inject private RuntimeConfigFactory runtimeConfigFactory;

@Inject private HttpExecutionContext ec;

@Inject private SessionHandler sessionHandler;

@Inject private UserService userService;
Expand Down Expand Up @@ -471,7 +464,17 @@ public Result api_token(UUID customerUUID) {
return withData(sessionInfo);
}

@ApiOperation(value = "UI_ONLY", hidden = true, response = SessionInfo.class)
@ApiOperation(
value = "Register a customer",
notes = "Creates new customer and user",
nickname = "registerCustomer",
response = SessionInfo.class)
@ApiImplicitParams(
@ApiImplicitParam(
name = "CustomerRegisterFormData",
paramType = "body",
dataType = "com.yugabyte.yw.forms.CustomerRegisterFormData",
required = true))
@Transactional
public Result register() {
CustomerRegisterFormData data =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
import com.yugabyte.yw.controllers.handlers.UniverseYbDbAdminHandler;
import com.yugabyte.yw.forms.DatabaseSecurityFormData;
import com.yugabyte.yw.forms.DatabaseUserFormData;
import com.yugabyte.yw.forms.RunQueryFormData;
import com.yugabyte.yw.forms.PlatformResults;
import com.yugabyte.yw.forms.PlatformResults.YBPError;
import com.yugabyte.yw.forms.PlatformResults.YBPSuccess;
import com.yugabyte.yw.forms.RunQueryFormData;
import com.yugabyte.yw.models.Customer;
import com.yugabyte.yw.models.Universe;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Authorization;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import play.data.Form;
import play.libs.Json;
import play.mvc.Result;
Expand All @@ -39,8 +39,6 @@
value = "Universe database management",
authorizations = @Authorization(AbstractPlatformController.API_KEY_AUTH))
public class UniverseYbDbAdminController extends AuthenticatedController {
private static final Logger LOG = LoggerFactory.getLogger(UniverseYbDbAdminController.class);

@Inject private UniverseYbDbAdminHandler universeYbDbAdminHandler;

@ApiOperation(
Expand Down Expand Up @@ -94,6 +92,12 @@ public Result runInShell(UUID customerUUID, UUID universeUUID) {
notes = "Runs a YSQL query. Only valid when the platform is running in `OSS` mode.",
nickname = "runYsqlQueryUniverse",
response = Object.class)
@ApiImplicitParams(
@ApiImplicitParam(
name = "RunQueryFormData",
paramType = "body",
dataType = "com.yugabyte.yw.forms.RunQueryFormData",
required = true))
public Result runQuery(UUID customerUUID, UUID universeUUID) {
Customer customer = Customer.getOrBadRequest(customerUUID);
Universe universe = Universe.getValidUniverseOrBadRequest(universeUUID, customer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.yugabyte.yw.forms;

import com.yugabyte.yw.common.alerts.SmtpData;
import io.swagger.annotations.ApiModelProperty;
import java.util.Map;
import play.data.validation.Constraints;

Expand All @@ -14,14 +15,16 @@ public class CustomerRegisterFormData {

@Constraints.Required() @Constraints.Email private String email;

private String password;
@Constraints.Required() private String password;

@ApiModelProperty(value = "UI_ONLY", hidden = true)
private String confirmPassword;

@Constraints.Required()
@Constraints.MinLength(3)
private String name;

@ApiModelProperty(value = "UI_ONLY", hidden = true)
private Map features;

public String getCode() {
Expand Down Expand Up @@ -112,12 +115,18 @@ public static class AlertingData {
public long activeAlertNotificationIntervalMs = 0;
}

// TODO: Remove usages in UI and purge the field
@ApiModelProperty(value = "UNUSED", hidden = true)
public AlertingData alertingData;

// TODO: Remove usages in UI and purge the field
@ApiModelProperty(value = "UNUSED", hidden = true)
public SmtpData smtpData;

@Constraints.Pattern(
message = "Must be one of NONE, LOW, MEDIUM, HIGH",
value = "\\b(?:NONE|LOW|MEDIUM|HIGH)\\b")
// TODO: Remove usages in UI and purge the field
@ApiModelProperty(value = "UNUSED", hidden = true)
public String callhomeLevel = "MEDIUM";
}
65 changes: 65 additions & 0 deletions managed/src/main/resources/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2528,6 +2528,24 @@
"required" : [ "code", "name" ],
"type" : "object"
},
"CustomerRegisterFormData" : {
"properties" : {
"code" : {
"type" : "string"
},
"email" : {
"type" : "string"
},
"name" : {
"type" : "string"
},
"password" : {
"type" : "string"
}
},
"required" : [ "code", "email", "name", "password" ],
"type" : "object"
},
"CustomerTaskData" : {
"description" : "Customer task data",
"properties" : {
Expand Down Expand Up @@ -4288,6 +4306,22 @@
"required" : [ "universeUUID" ],
"type" : "object"
},
"RunQueryFormData" : {
"properties" : {
"db_name" : {
"type" : "string"
},
"query" : {
"type" : "string"
},
"tableType" : {
"enum" : [ "YQL_TABLE_TYPE", "REDIS_TABLE_TYPE", "PGSQL_TABLE_TYPE", "TRANSACTION_STATUS_TABLE_TYPE" ],
"type" : "string"
}
},
"required" : [ "db_name", "query", "tableType" ],
"type" : "object"
},
"RuntimeConfigData" : {
"description" : "Runtime configuration data",
"properties" : {
Expand Down Expand Up @@ -10721,6 +10755,13 @@
"name" : "uniUUID",
"required" : true,
"type" : "string"
}, {
"in" : "body",
"name" : "RunQueryFormData",
"required" : true,
"schema" : {
"$ref" : "#/definitions/RunQueryFormData"
}
} ],
"responses" : {
"200" : {
Expand Down Expand Up @@ -12325,6 +12366,30 @@
"tags" : [ "Metrics" ]
}
},
"/api/v1/register" : {
"post" : {
"description" : "Creates new customer and user",
"operationId" : "registerCustomer",
"parameters" : [ {
"in" : "body",
"name" : "CustomerRegisterFormData",
"required" : true,
"schema" : {
"$ref" : "#/definitions/CustomerRegisterFormData"
}
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/SessionInfo"
}
}
},
"summary" : "Register a customer",
"tags" : [ "Session management" ]
}
},
"/api/v1/runtime_config/mutable_keys" : {
"get" : {
"description" : "List all the mutable runtime config keys",
Expand Down

0 comments on commit b4215a5

Please sign in to comment.