All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cloudbees.sdk.commands.db.DatabaseInfo Maven / Gradle / Ivy

The newest version!
/*
 * 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.db;

import com.cloudbees.api.BeesClient;
import com.cloudbees.sdk.cli.BeesCommand;
import com.cloudbees.sdk.cli.CLICommand;
import com.staxnet.appserver.utils.StringHelper;

/**
 * @author Fabian Donze
 */
@BeesCommand(group="Database", description = "Get a database configuration")
@CLICommand("db:info")
public class DatabaseInfo extends DatabaseBase {
    private Boolean password;

    public DatabaseInfo() {
    }

    public void setPassword(Boolean password) {
        this.password = password;
    }

    @Override
    protected boolean preParseCommandLine() {
        // add the Options
        addOption( "p", "password", false, "print the database password info" );

        return true;
    }

    @Override
    protected boolean execute() throws Exception {
        String dbId = getDatabaseName();
        BeesClient client = getBeesClient(BeesClient.class, dbId);
        boolean fetchPassword = password == null ? false : true;
        com.cloudbees.api.DatabaseInfo res = client.databaseInfo(dbId, fetchPassword);

        if (isTextOutput()) {
            displayDatabaseInfo(res, fetchPassword);
        } else
            printOutput(res, com.cloudbees.api.DatabaseInfo.class);

        return true;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy