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

com.aeontronix.enhancedmule.tools.cli.exchange.ExchangePromoteApplicationCmd Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha4
Show newest version
/*
 * Copyright (c) Aeontronix 2023
 */

package com.aeontronix.enhancedmule.tools.cli.exchange;

import com.aeontronix.enhancedmule.tools.anypoint.LegacyAnypointClient;
import com.aeontronix.enhancedmule.tools.anypoint.Organization;
import com.aeontronix.enhancedmule.tools.cli.AbstractCommand;
import com.aeontronix.enhancedmule.tools.emclient.EnhancedMuleClient;
import org.slf4j.Logger;
import picocli.CommandLine;
import picocli.CommandLine.Parameters;

import java.util.concurrent.Callable;

import static org.slf4j.LoggerFactory.getLogger;

@CommandLine.Command(name = "promote", description = "Promote an snapshot application in exchange to a release version")
public class ExchangePromoteApplicationCmd extends AbstractCommand implements Callable {
    private static final Logger logger = getLogger(ExchangePromoteApplicationCmd.class);
    @CommandLine.Option(names = {"-g", "--group-id"}, description = "Business group name or id")
    private String businessGroup;
    @Parameters(index = "0", arity = "1", description = "Asset Id")
    private String assetId;
    @Parameters(index = "1", arity = "1", description = "Asset Version")
    private String version;
    @CommandLine.Option(names = {"-n", "--new-version"}, description = "New version")
    private String newVersion;

    @Override
    public Integer call() throws Exception {
        final EnhancedMuleClient emClient = getCli().createEMClient();
        final LegacyAnypointClient legacyAnypointClient = emClient.getLegacyAnypointClient();
        final Organization org;
        if (businessGroup != null) {
            org = legacyAnypointClient.findOrganizationByNameOrId(businessGroup);
        } else {
            org = legacyAnypointClient.getUser().getOrganization();
            org.setClient(legacyAnypointClient);
        }
        org.promoteExchangeApplication(getCli().getAnypointClient(), emClient, org.getId(), assetId, version, newVersion);
        return 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy