![JAR search and dependency download from the Maven repository](/logo.png)
com.cloudbees.sdk.commands.config.ConfigParametersUpdate Maven / Gradle / Ivy
/*
* Copyright 2010-2013, CloudBees Inc.
*
* 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.cloudbees.sdk.commands.config;
import com.cloudbees.api.BeesClient;
import com.cloudbees.api.ConfigurationParametersUpdateResponse;
import com.cloudbees.sdk.cli.BeesCommand;
import com.cloudbees.sdk.cli.CLICommand;
import com.cloudbees.sdk.utils.Helper;
import java.io.File;
import java.io.IOException;
/**
* @author Fabian Donze
*/
@BeesCommand(group="Configuration")
@CLICommand("config:update")
public class ConfigParametersUpdate extends ConfigParametersBase {
private String file;
public ConfigParametersUpdate() {
setArgumentExpected(1);
}
public void setFile(String file) {
this.file = file;
}
public String getFile() throws IOException {
if (file == null) file = getParameters().get(0);
if (file == null) file = Helper.promptFor("Config file name: ", true);
return file;
}
@Override
protected String getUsageMessage() {
return "CONFIG_FILE";
}
@Override
protected boolean execute() throws Exception {
if (getFile() == null) {
throw new IllegalArgumentException("Config file not specified");
}
File resourceFile = new File(getFile());
if (!resourceFile.exists()) {
throw new IllegalArgumentException("Config file not found: " + getFile());
}
String resourceId;
String resourceType;
if (isGlobal("update")) {
resourceId = getAccount();
resourceType = "global";
} else {
resourceId = getAppId();
resourceType = "application";
}
BeesClient client = getBeesClient(BeesClient.class);
ConfigurationParametersUpdateResponse res = client.configurationParametersUpdate(resourceId, resourceType, resourceFile);
if (isTextOutput()) {
displayStatus(resourceType, resourceId, res.getStatus());
} else {
printOutput(res, ConfigurationParametersUpdateResponse.class);
}
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy