Package com.cloudbees.api

Examples of com.cloudbees.api.BeesClient


    public ApplicationBlueGreenSwitch() {
    }

    @Override
    public int main() throws Exception {
        BeesClient client = getBeesClient(BeesClient.class, getAppId());

        List<ApplicationAlias> aliases = getAliases(client, getAppId());
        if (aliases.isEmpty()) {
            System.err.println("ERROR: Application not configured for Blue-Green deployment switch. Use the \"blue-green=APP_ID[ALIASES]\" parameter");
            return 1;
        }

        if (force == null || !force.booleanValue()) {
            if (!Helper.promptMatches("Are you sure you want to switch the application aliases: (y/n) ", "[yY].*")) {
                return 0;
            }
        }

        for (ApplicationAlias alias : aliases) {
            Map<String, String> settings = new HashMap<String, String>();
            settings.put("aliases", alias.getAliasString());

            try {
                ApplicationStatusResponse res = client.applicationProxyUpdate(alias.getAppId(), settings);
                System.out.println("application proxy for " + alias.getAppId() + " : " + res.getStatus());
            } catch (Exception e) {
                System.err.println("ERROR: failed to update application proxy for " + alias.getAppId() + " : " + e.getMessage());
            }
        }
View Full Code Here


    protected String initAppId(String appid, AppConfig appConfig) throws IOException {
        String appId = super.initAppId(appid, appConfig);

        // Overwrite appId if blue-green parameter is defined
        try {
            BeesClient client = getAppClient(appId);
            ConfigurationParametersResponse res = client.configurationParameters(appId, "application");
            if (res.getConfiguration() != null) {
                ConfigParameters configParameters = ConfigParameters.parse(res.getConfiguration());
                ParameterMap parameterMap = configParameters.getParameters();

                String param = parameterMap.get("blue-green");

                if (param != null) {
                    ApplicationAlias bgApp = new ApplicationAlias(getAccount(), param);

                    // Get the current alias if any
                    ApplicationInfo applicationInfo = client.applicationInfo(appId);
                    String aliases = applicationInfo.getSettings().get("aliases");
                    ApplicationAlias currentApp = new ApplicationAlias(getAccount(), appId, aliases);

                    // If the current app has the alias already, deploy to the other app
                    if (currentApp.containAliases(bgApp.getAliases())) {
View Full Code Here

    @Inject
    BeesClientFactory beesClientFactory;

    public JSONObject getMetaData(String appId) throws Exception {
        BeesClient client = beesClientFactory.get(BeesClient.class);
        Map<String, String> params = new HashMap<String, String>();
        params.put("app_id", appId);
        String url = client.getRequestURL("application.platform.metadata", params);
        String response = client.executeRequest(url);

        SAXBuilder sxb = new SAXBuilder();
        Document document = sxb.build(new StringReader(response));
        String js = document.getRootElement().getChild("message").getText();
View Full Code Here

    public ApplicationBlueGreenSwitch() {
    }

    @Override
    public int main() throws Exception {
        BeesClient client = getBeesClient(BeesClient.class);

        List<ApplicationAlias> aliases = getAliases(client, getName(), primaryOnly != null ? primaryOnly : false);

        if (force == null || !force.booleanValue()) {
            if (!Helper.promptMatches("Are you sure you want to switch the application aliases: (y/n) ", "[yY].*")) {
                return 0;
            }
        }

        for (ApplicationAlias alias : aliases) {
            Map<String, String> settings = new HashMap<String, String>();
            settings.put("aliases", alias.getAliasString());

            try {
                ApplicationStatusResponse res = client.applicationProxyUpdate(alias.getAppId(), settings);
                System.out.println("application proxy for " + alias.getAppId() + " : " + res.getStatus());
            } catch (Exception e) {
                System.err.println("ERROR: failed to update application proxy for " + alias.getAppId());
                throw e;
            }
View Full Code Here

    public ApplicationBlueGreenStop() {
    }

    @Override
    public int main() throws Exception {
        BeesClient client = getBeesClient(BeesClient.class);

        String appId = getSecondaryApplicationId(client, getName());

        if (force == null || !force.booleanValue()) {
            if (!Helper.promptMatches(String.format("Are you sure you want to stop the application [%s]: (y/n) ", appId), "[yY].*")) {
                return 0;
            }
        }

        ApplicationStatusResponse res = client.applicationStop(appId);
        if (res.getStatus().equalsIgnoreCase("stopped"))
            System.out.println("application stopped - " + appId);
        else
            System.out.println("application could not be stopped, current status: " + res.getStatus());

View Full Code Here

        deployArgs.add(".bg.deploy." + getName() + "=" + blueGreenParam);
        return cs.getCommand("config:set").run(deployArgs);
    }

    protected void checkApplication(String appId, Boolean force) throws IOException {
        BeesClient client = getBeesClient(BeesClient.class);
        try {
            client.applicationInfo(appId);
        } catch (Exception e) {
            if (force != null && force.booleanValue())
                System.err.println("WARNING: cannot find application: " + appId);
            else
                throw new IllegalArgumentException("Cannot find application: " + appId);
View Full Code Here

    public ApplicationBlueGreenSwitch() {
    }

    @Override
    public int main() throws Exception {
        BeesClient client = getBeesClient(BeesClient.class);

        List<ApplicationAlias> aliases = getAliases(client, getName());

        if (force == null || !force.booleanValue()) {
            if (!Helper.promptMatches("Are you sure you want to switch the application aliases: (y/n) ", "[yY].*")) {
                return 0;
            }
        }

        for (ApplicationAlias alias : aliases) {
            Map<String, String> settings = new HashMap<String, String>();
            settings.put("aliases", alias.getAliasString());

            try {
                ApplicationStatusResponse res = client.applicationProxyUpdate(alias.getAppId(), settings);
                System.out.println("application proxy for " + alias.getAppId() + " : " + res.getStatus());
            } catch (Exception e) {
                System.err.println("ERROR: failed to update application proxy for " + alias.getAppId() + " : " + e.getMessage());
            }
        }
View Full Code Here

    }

    protected String initAppId(String appid, AppConfig appConfig) throws IOException {
        try {
            String appId = null;
            BeesClient client = getBeesClient(BeesClient.class);
            BlueGreenSettings blueGreenSettings = BlueGreenSettings.getInstance(client, getAccount(), getName());

            // Get the app1 alias
            ApplicationInfo applicationInfo = client.applicationInfo(blueGreenSettings.getApplication1());
            String aliases = applicationInfo.getSettings().get("aliases");
            ApplicationAlias application1 = new ApplicationAlias(getAccount(), blueGreenSettings.getApplication1(), aliases);

            // If the app1 has the alias already, deploy to the other app
            if (application1.containAliases(blueGreenSettings.getActiveAliases())) {
View Full Code Here

    public ApplicationBlueGreenInfo() {
    }

    @Override
    public int main() throws Exception {
        BeesClient client = getBeesClient(BeesClient.class);

        List<String> applicationIds = getApplicationIds(client, getName());
        System.out.println();
        System.out.println("PRIMARY APPLICATION");
        System.out.println("===================");
View Full Code Here

            }
        }
        logger.debug("Expecting scopes: "+Arrays.toString(scopes.toArray()));

        // Create OAuth client
        OauthClient oauthClient = new BeesClient(oauthConfig.getClientId(), oauthConfig.getClientSecret()).getOauthClient();

        //parse Bearer token from Authorization header
        String token = oauthClient.parseAuthorizationHeader(request.getHeaderValue("Authorization"));

        // If not found get it from the access_token parameter
View Full Code Here

TOP

Related Classes of com.cloudbees.api.BeesClient

Copyright © 2018 www.massapicom. 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.