本文整理汇总了Java中com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse.success方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultGoPluginApiResponse.success方法的具体用法?Java DefaultGoPluginApiResponse.success怎么用?Java DefaultGoPluginApiResponse.success使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse
的用法示例。
在下文中一共展示了DefaultGoPluginApiResponse.success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() throws Exception {
final ValidationResult validationResult = new MetadataValidator().validate(request.gitHubRoleConfiguration());
if (!request.gitHubRoleConfiguration().hasConfiguration()) {
validationResult.addError("Organizations", "At least one of the fields(organizations,teams or users) should be specified.");
validationResult.addError("Teams", "At least one of the fields(organizations,teams or users) should be specified.");
validationResult.addError("Users", "At least one of the fields(organizations,teams or users) should be specified.");
}
try {
request.gitHubRoleConfiguration().teams();
} catch (RuntimeException e) {
validationResult.addError("Teams", e.getMessage());
}
return DefaultGoPluginApiResponse.success(validationResult.toJSON());
}
开发者ID:gocd-contrib,项目名称:github-oauth-authorization-plugin,代码行数:19,代码来源:RoleConfigValidateRequestExecutor.java
示例2: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
public GoPluginApiResponse execute() throws Exception {
if (request.authConfigs() == null || request.authConfigs().isEmpty()) {
throw new NoAuthorizationConfigurationException("[Get Access Token] No authorization configuration found.");
}
if (!request.requestParameters().containsKey("code")) {
throw new IllegalArgumentException("Get Access Token] Expecting `code` in request params, but not received.");
}
final AuthConfig authConfig = request.authConfigs().get(0);
final GitHubConfiguration gitHubConfiguration = authConfig.gitHubConfiguration();
String fetchAccessTokenUrl = fetchAccessTokenUrl(gitHubConfiguration);
final Request fetchAccessTokenRequest = fetchAccessTokenRequest(fetchAccessTokenUrl);
final Response response = httpClient.newCall(fetchAccessTokenRequest).execute();
if (response.isSuccessful()) {
LOG.info("[Get Access Token] Access token fetched successfully.");
final TokenInfo tokenInfo = TokenInfo.fromJSON(response.body().string());
return DefaultGoPluginApiResponse.success(tokenInfo.toJSON());
}
throw new AuthenticationException(format("[Get Access Token] {0}", response.message()));
}
开发者ID:gocd-contrib,项目名称:github-oauth-authorization-plugin,代码行数:25,代码来源:FetchAccessTokenRequestExecutor.java
示例3: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
public GoPluginApiResponse execute() throws Exception {
if (request.authConfigs() == null || request.authConfigs().isEmpty()) {
throw new NoAuthorizationConfigurationException("[Authorization Server Url] No authorization configuration found.");
}
LOG.debug("[Get Authorization Server URL] Getting authorization server url from auth config.");
final AuthConfig authConfig = request.authConfigs().get(0);
final GitHubConfiguration gitHubConfiguration = authConfig.gitHubConfiguration();
String authorizationServerUrl = HttpUrl.parse(gitHubConfiguration.apiUrl())
.newBuilder()
.addPathSegment("login")
.addPathSegment("oauth")
.addPathSegment("authorize")
.addQueryParameter("client_id", gitHubConfiguration.clientId())
.addQueryParameter("redirect_uri", request.callbackUrl())
.addQueryParameter("scope", gitHubConfiguration.scope())
.build().toString();
return DefaultGoPluginApiResponse.success(GSON.toJson(Collections.singletonMap("authorization_server_url", authorizationServerUrl)));
}
开发者ID:gocd-contrib,项目名称:github-oauth-authorization-plugin,代码行数:24,代码来源:GetAuthorizationServerUrlRequestExecutor.java
示例4: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() throws Exception {
if (request.authConfigs().isEmpty()) {
throw new NoAuthorizationConfigurationException("[Authenticate] No authorization configuration found.");
}
final GoogleConfiguration configuration = request.authConfigs().get(0).getConfiguration();
final GoogleApiClient googleApiClient = configuration.googleApiClient();
final GoogleUser googleUser = googleApiClient.userProfile(request.tokenInfo());
if (configuration.allowedDomains().isEmpty() || configuration.allowedDomains().contains(googleUser.getHd())) {
Map<String, Object> userMap = new HashMap<>();
userMap.put("user", new User(googleUser));
userMap.put("roles", Collections.emptyList());
return DefaultGoPluginApiResponse.success(GSON.toJson(userMap));
}
LOG.warn(format("[Authenticate] User `{0}` is not belongs to allowed domain list.", googleUser.getEmail()));
return DefaultGoPluginApiResponse.error(format("[Authenticate] User `{0}` is not belongs to allowed domain list.", googleUser.getEmail()));
}
开发者ID:gocd-contrib,项目名称:google-oauth-authorization-plugin,代码行数:23,代码来源:UserAuthenticationRequestExecutor.java
示例5: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() {
DockerContainer instance = agentInstances.find(request.agent().elasticAgentId());
if (instance == null) {
return DefaultGoPluginApiResponse.success("false");
}
boolean environmentMatches = stripToEmpty(request.environment()).equalsIgnoreCase(stripToEmpty(instance.environment()));
Map<String, String> containerProperties = instance.properties() == null ? new HashMap<String, String>() : instance.properties();
Map<String, String> requestProperties = request.properties() == null ? new HashMap<String, String>() : request.properties();
boolean propertiesMatch = requestProperties.equals(containerProperties);
if (environmentMatches && propertiesMatch) {
return DefaultGoPluginApiResponse.success("true");
}
return DefaultGoPluginApiResponse.success("false");
}
示例6: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() throws Exception {
PluginSettings pluginSettings = pluginRequest.getPluginSettings();
Agents allAgents = pluginRequest.listAgents();
Agents missingAgents = new Agents();
for (Agent agent : allAgents.agents()) {
if (agentInstances.find(agent.elasticAgentId()) == null) {
LOG.warn("Was expecting a container with name " + agent.elasticAgentId() + ", but it was missing!");
missingAgents.add(agent);
}
}
Agents agentsToDisable = agentInstances.instancesCreatedAfterTimeout(pluginSettings, allAgents);
agentsToDisable.addAll(missingAgents);
disableIdleAgents(agentsToDisable);
allAgents = pluginRequest.listAgents();
terminateDisabledAgents(allAgents, pluginSettings);
agentInstances.terminateUnregisteredInstances(pluginSettings, allAgents);
return DefaultGoPluginApiResponse.success("");
}
示例7: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() {
DockerService instance = agentInstances.find(request.agent().elasticAgentId());
if (instance == null) {
LOG.info(format(format("[should-assign-work] Agent with id `{0}` not exists.", request.agent().elasticAgentId())));
return DefaultGoPluginApiResponse.success("false");
}
if (request.jobIdentifier().getJobId().equals(instance.jobId())) {
LOG.info(format("[should-assign-work] Job with profile {0} can be assigned to an agent {1} with job id {2}", request.properties(), instance.name(), instance.jobId()));
return DefaultGoPluginApiResponse.success("true");
}
LOG.info(format("[should-assign-work] Job with profile {0} can be assigned to an agent {1}", request.properties(), instance.name()));
return DefaultGoPluginApiResponse.success("false");
}
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:18,代码来源:ShouldAssignWorkRequestExecutor.java
示例8: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() throws Exception {
final List<String> knownFields = new ArrayList<>();
final ValidationResult validationResult = new ValidationResult();
for (Metadata field : GetProfileMetadataExecutor.FIELDS) {
knownFields.add(field.getKey());
validationResult.addError(field.validate(request.getProperties().get(field.getKey())));
}
final Set<String> set = new HashSet<>(request.getProperties().keySet());
set.removeAll(knownFields);
if (!set.isEmpty()) {
for (String key : set) {
validationResult.addError(key, "Is an unknown property.");
}
}
for (Validatable validatable : validators) {
validationResult.merge(validatable.validate(request.getProperties()));
}
return DefaultGoPluginApiResponse.success(validationResult.toJSON());
}
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:26,代码来源:ProfileValidateRequestExecutor.java
示例9: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
public GoPluginApiResponse execute() {
ArrayList<Map<String, String>> result = new ArrayList<>();
for (Map.Entry<String, Field> entry : GetPluginConfigurationExecutor.FIELDS.entrySet()) {
Field field = entry.getValue();
Map<String, String> validationError = field.validate(request.get(entry.getKey()));
if (!validationError.isEmpty()) {
result.add(validationError);
}
}
result.addAll(new PrivateDockerRegistrySettingsValidator().validate(request));
return DefaultGoPluginApiResponse.success(GSON.toJson(result));
}
示例10: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() throws Exception {
OpenStackInstance instance = (OpenStackInstance) agentInstances.find(request.agent().elasticAgentId());
LOG.info("Trying to match Elastic Agent with work request : " + request);
if (instance == null) {
LOG.info("Work can NOT be assigned to missing Elastic Agent: " + request.agent().elasticAgentId());
return DefaultGoPluginApiResponse.success("false");
}
OpenstackClientWrapper clientWrapper = new OpenstackClientWrapper(pluginRequest.getPluginSettings());
if ((agentInstances.matchInstance(request.agent().elasticAgentId(), request.properties(), request.environment(), pluginRequest.getPluginSettings(), clientWrapper)) ) {
LOG.info("Work can be assigned to Elastic Agent : " + request.agent().elasticAgentId());
return DefaultGoPluginApiResponse.success("true");
} else {
LOG.info("Work can NOT be assigned to Elastic Agent : " + request.agent().elasticAgentId());
return DefaultGoPluginApiResponse.success("false");
}
}
示例11: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() {
ExampleInstance instance = agentInstances.find(request.agent().elasticAgentId());
if (instance == null) {
return DefaultGoPluginApiResponse.success("false");
}
boolean environmentMatches = stripToEmpty(request.environment()).equalsIgnoreCase(stripToEmpty(instance.environment()));
Map<String, String> containerProperties = instance.properties() == null ? new HashMap<String, String>() : instance.properties();
Map<String, String> requestProperties = request.properties() == null ? new HashMap<String, String>() : request.properties();
boolean propertiesMatch = requestProperties.equals(containerProperties);
if (environmentMatches && propertiesMatch) {
return DefaultGoPluginApiResponse.success("true");
}
return DefaultGoPluginApiResponse.success("false");
}
开发者ID:gocd-contrib,项目名称:elastic-agent-skeleton-plugin,代码行数:22,代码来源:ShouldAssignWorkRequestExecutor.java
示例12: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() {
KubernetesInstance pod = agentInstances.find(request.agent().elasticAgentId());
if (pod == null) {
return DefaultGoPluginApiResponse.success("false");
}
if (request.jobIdentifier().getJobId().equals(pod.jobId())) {
return DefaultGoPluginApiResponse.success("true");
}
return DefaultGoPluginApiResponse.success("false");
}
示例13: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
@Override
public GoPluginApiResponse execute() throws Exception {
PluginSettings pluginSettings = pluginRequest.getPluginSettings();
Agents allAgents = pluginRequest.listAgents();
Agents missingAgents = new Agents();
for (Agent agent : allAgents.agents()) {
if (agentInstances.find(agent.elasticAgentId()) == null) {
LOG.warn(String.format("Was expecting a container with name %s, but it was missing!", agent.elasticAgentId()));
missingAgents.add(agent);
}
}
LOG.debug(String.format("[Server Ping] Missing Agents:%s", missingAgents.agentIds()));
Agents agentsToDisable = agentInstances.instancesCreatedAfterTimeout(pluginSettings, allAgents);
LOG.debug(String.format("[Server Ping] Agent Created After Timeout:%s", agentsToDisable.agentIds()));
agentsToDisable.addAll(missingAgents);
disableIdleAgents(agentsToDisable);
allAgents = pluginRequest.listAgents();
terminateDisabledAgents(allAgents, pluginSettings);
agentInstances.terminateUnregisteredInstances(pluginSettings, allAgents);
return DefaultGoPluginApiResponse.success("");
}
示例14: execute
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
public GoPluginApiResponse execute() throws Exception {
LOG.info("[status-report] Generating status report");
KubernetesClient client = factory.kubernetes(pluginRequest.getPluginSettings());
final KubernetesCluster kubernetesCluster = new KubernetesCluster(client);
final Template template = statusReportViewBuilder.getTemplate("status-report.template.ftlh");
final String statusReportView = statusReportViewBuilder.build(template, kubernetesCluster);
JsonObject responseJSON = new JsonObject();
responseJSON.addProperty("view", statusReportView);
return DefaultGoPluginApiResponse.success(responseJSON.toString());
}
示例15: responseWith
import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; //导入方法依赖的package包/类
private GoPluginApiResponse responseWith(String status, String message, List<Map<String, String>> errors) {
HashMap<String, Object> response = new HashMap<>();
response.put("status", status);
response.put("message", message);
if (errors != null && errors.size() > 0) {
response.put("errors", errors);
}
return DefaultGoPluginApiResponse.success(GSON.toJson(response));
}
开发者ID:gocd-contrib,项目名称:google-oauth-authorization-plugin,代码行数:12,代码来源:VerifyConnectionRequestExecutor.java