Package com.cloudbees.sdk.pool

Source Code of com.cloudbees.sdk.pool.ServerPoolGetInfo

/*
* Copyright 2010-2014, 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.pool;

import com.cloudbees.api.BeesClient;
import com.cloudbees.api.ServerInfo;
import com.cloudbees.api.ServerPoolInfo;
import com.cloudbees.sdk.cli.BeesCommand;
import com.cloudbees.sdk.cli.CLICommand;

/**
* @author Fabian Donze
*/
@BeesCommand(group = "Server", description = "Get pool information")
@CLICommand("app:pool:info")
public class ServerPoolGetInfo extends ServerPoolBase {
    private Boolean allServers;
    private Boolean listApplications;

    public ServerPoolGetInfo() {
        super();
    }

    public void setAllServers(Boolean allServers) {
        this.allServers = allServers;
    }

    protected boolean allServers() {
        return allServers == null ? false : allServers;
    }

    protected boolean withApplications() {
        return listApplications == null ? false : listApplications;
    }

    public void setListApplications(Boolean listApplications) {
        this.listApplications = listApplications;
    }

    @Override
    protected String getUsageMessage() {
        return "POOL_ID";
    }

    @Override
    protected boolean preParseCommandLine() {
        if (super.preParseCommandLine()) {
            addOption( null, "allServers", false, "list all servers even deleted one" );
            addOption( null, "listApplications", false, "list application attached to the pool" );
        }
        return true;
    }

    @Override
    protected boolean execute() throws Exception {
        BeesClient client = getBeesClient(BeesClient.class);

        ServerPoolInfo poolInfo = client.serverPoolInfo(getParameterID(), withApplications());
        if (isTextOutput()) {
            printPoolInfo(poolInfo, allServers());

        } else  printOutput(poolInfo, ServerInfo.class, ServerPoolInfo.class);

        return true;
    }
}
TOP

Related Classes of com.cloudbees.sdk.pool.ServerPoolGetInfo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.