Search in sources :

Example 16 with Network

use of com.google.api.ads.admanager.axis.v202205.Network in project googleads-java-lib by googleads.

the class CreateNativeStyles method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the NativeStyleService.
    NativeStyleServiceInterface nativeStyleService = adManagerServices.get(session, NativeStyleServiceInterface.class);
    String htmlSnippet = "<div id=\"adunit\" style=\"overflow: hidden;\">\n" + "  <img src='[%Thirdpartyimpressiontracker%]' style='display:none'>\n" + "  <div class='attribution'>Ad</div>\n" + "  <div class='image'>\n" + "    <a class='image-link' " + "href='%%CLICK_URL_UNESC%%[%Thirdpartyclicktracker%]%%DEST_URL%%' target='_top'>" + "<img src=\"[%Image%]\"></a>\n" + "  </div>\n" + "  <div class='app-icon'><img src=\"[%Appicon%]\"/></div>\n" + "  <div class='title'>\n" + "    <a class='title-link' " + "href='%%CLICK_URL_UNESC%%[%Thirdpartyclicktracker%]%%DEST_URL%%' " + "target='_top'>[%Headline%]</a>\n" + "  </div>\n" + "  <div class='reviews'></div>\n" + "  <div class='body'>\n" + "    <a class='body-link' " + "href='%%CLICK_URL_UNESC%%[%Thirdpartyclicktracker%]%%DEST_URL%%' " + "target='_top'>[%Body%]</a>\n" + "  </div>\n" + "  <div class='price'>[%Price%]</div>\n" + "  <div class='button'>\n" + "    <a class='button-link' " + "href='%%CLICK_URL_UNESC%%[%Thirdpartyclicktracker%]%%DEST_URL%%' " + "target='_top'>[%Calltoaction%]</a>\n" + "  </div>\n" + "</div>\n";
    String cssSnippet = "body {" + "    background-color: rgba(255, 255, 255, 1);" + "    font-family: \"Roboto-Regular\", sans-serif;" + "    font-weight: normal;" + "    font-size: 12px;" + "    line-height: 14px;" + "}" + ".attribution {" + "    background-color: rgba(236, 182, 0, 1);" + "    color: rgba(255, 255, 255, 1);" + "    font-size: 13px;" + "    display: table;" + "    margin: 4px 8px;" + "    padding: 0 3px;" + "    border-radius: 2px;" + "}" + ".image {" + "    text-align: center;" + "    margin: 8px;" + "}" + ".image img," + ".image-link {" + "    width: 100%;" + "}" + ".app-icon {" + "    float: left;" + "    margin: 0 8px 4px 8px;" + "    height: 40px;" + "    width: 40px;" + "    background-color: transparent;" + "}" + ".app-icon img {" + "    height: 100%;" + "    width: 100%;" + "    border-radius: 20%;" + "}" + ".title {" + "    font-weight: bold;" + "    font-size: 14px;" + "    line-height: 20px;" + "    margin: 8px 8px 4px 8px;" + "}" + ".title a {" + "    color: rgba(112, 112, 112, 1);" + "    text-decoration: none;" + "}" + ".reviews {" + "    float: left;" + "}" + ".reviews svg {" + "    fill: rgba(0, 0, 0, 0.7);" + "}" + ".body {" + "    clear: left;" + "    margin: 8px;" + "}" + ".body a {" + "    color: rgba(110, 110, 110, 1);" + "    text-decoration: none;" + "}" + ".price {" + "    display: none;" + "}" + ".button {" + "    font-size: 14px;" + "    font-weight: bold;" + "    float: right;" + "    margin: 0px 16px 16px 0px;" + "    white-space: nowrap;" + "}" + ".button a {" + "    color: #2196F3;" + "    text-decoration: none;" + "}" + ".button svg {" + "    display: none;" + "}";
    // This is the creative template ID for the system-defined native app
    // install ad format, which we will create the native style from. Use
    // CreativeTemplateService.getCreativeTemplatesByStatement() and
    // CreativeTemplate.isNativeEligible to get other native ad formats
    // available in your network.
    long nativeAppInstallTemplateId = 10004400L;
    // Set the size for the native style.
    Size size = new Size();
    size.setWidth(300);
    size.setHeight(250);
    size.setIsAspectRatio(false);
    // Create a style for native app install ads.
    NativeStyle nativeStyle = new NativeStyle();
    nativeStyle.setName("Native style #" + new Random().nextInt(Integer.MAX_VALUE));
    nativeStyle.setCreativeTemplateId(nativeAppInstallTemplateId);
    nativeStyle.setSize(size);
    nativeStyle.setHtmlSnippet(htmlSnippet);
    nativeStyle.setCssSnippet(cssSnippet);
    // Create the native style on the server.
    NativeStyle[] nativeStyles = nativeStyleService.createNativeStyles(new NativeStyle[] { nativeStyle });
    for (NativeStyle createdNativeStyle : nativeStyles) {
        System.out.printf("A native style with ID %d and name '%s' was created.%n", createdNativeStyle.getId(), createdNativeStyle.getName());
    }
}
Also used : NativeStyleServiceInterface(com.google.api.ads.admanager.axis.v202205.NativeStyleServiceInterface) Random(java.util.Random) Size(com.google.api.ads.admanager.axis.v202205.Size) NativeStyle(com.google.api.ads.admanager.axis.v202205.NativeStyle)

Example 17 with Network

use of com.google.api.ads.admanager.axis.v202205.Network in project googleads-java-lib by googleads.

the class GetCurrentNetwork method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the NetworkService.
    NetworkServiceInterface networkService = adManagerServices.get(session, NetworkServiceInterface.class);
    // Get the current network.
    Network network = networkService.getCurrentNetwork();
    System.out.printf("Current network has network code '%s' and display name '%s'.%n", network.getNetworkCode(), network.getDisplayName());
}
Also used : NetworkServiceInterface(com.google.api.ads.admanager.axis.v202205.NetworkServiceInterface) Network(com.google.api.ads.admanager.axis.v202205.Network)

Example 18 with Network

use of com.google.api.ads.admanager.axis.v202205.Network in project googleads-java-lib by googleads.

the class GetDefaultThirdPartyDataDeclaration method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws Exception {
    // Get the NetworkService.
    NetworkServiceInterface networkService = adManagerServices.get(session, NetworkServiceInterface.class);
    // Get the PublisherQueryLanguageService.
    PublisherQueryLanguageServiceInterface pqlService = adManagerServices.get(session, PublisherQueryLanguageServiceInterface.class);
    // Get the current network's default third party data declaration.
    ThirdPartyDataDeclaration declaration = networkService.getDefaultThirdPartyDataDeclaration();
    if (declaration == null) {
        System.out.println("No default ad technology partners have been set on this network.");
    } else if (DeclarationType.NONE.equals(declaration.getDeclarationType()) || declaration.getThirdPartyCompanyIds().length == 0) {
        System.out.println("This network has specified that there are no ad technology providers " + " associated with its reservation creatives by default.");
    } else {
        System.out.printf("This network has specified %d ad technology provider(s) associated with its reservation" + " creatives by default:%n", declaration.getThirdPartyCompanyIds().length);
        ResultSet companies = pqlService.select(new StatementBuilder().select("name, id").from("rich_media_ad_company").where("id in (:ids)").withBindVariableValue("ids", ImmutableSet.copyOf(Longs.asList(declaration.getThirdPartyCompanyIds()))).toStatement());
        System.out.println(Pql.resultSetToString(companies));
    }
}
Also used : PublisherQueryLanguageServiceInterface(com.google.api.ads.admanager.axis.v202205.PublisherQueryLanguageServiceInterface) NetworkServiceInterface(com.google.api.ads.admanager.axis.v202205.NetworkServiceInterface) ThirdPartyDataDeclaration(com.google.api.ads.admanager.axis.v202205.ThirdPartyDataDeclaration) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) ResultSet(com.google.api.ads.admanager.axis.v202205.ResultSet)

Example 19 with Network

use of com.google.api.ads.admanager.axis.v202205.Network in project googleads-java-lib by googleads.

the class MakeTestNetwork method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the NetworkService.
    NetworkServiceInterface networkService = adManagerServices.get(session, NetworkServiceInterface.class);
    // Make the test network.
    Network network = networkService.makeTestNetwork();
    System.out.printf("Test network with network code '%s' and display name '%s' created.%n" + "You may now sign in at https://admanager.google.com/%s%n", network.getNetworkCode(), network.getDisplayName(), network.getNetworkCode());
}
Also used : NetworkServiceInterface(com.google.api.ads.admanager.axis.v202108.NetworkServiceInterface) Network(com.google.api.ads.admanager.axis.v202108.Network)

Example 20 with Network

use of com.google.api.ads.admanager.axis.v202205.Network in project universa by UniversaBlockchain.

the class CLIMain method main.

public static void main(String[] args) throws IOException {
    // when we run untit tests, it is important:
    // args = new String[]{"-c", "/Users/sergeych/dev/new_universa/uniclient-testcreate/simple_root_contract.yml"};
    Config.forceInit(Contract.class);
    Config.forceInit(Parcel.class);
    reporter.clear();
    // it could be called more than once from tests
    keyFiles = null;
    parser = new OptionParser() {

        {
            acceptsAll(asList("?", "h", "help"), "Show help.").forHelp();
            acceptsAll(asList("g", "generate"), "Generate new key pair and store in a files starting " + "with a given prefix.").withRequiredArg().ofType(String.class).describedAs("name_prefix");
            accepts("s", "With -g, specify key strength.").withRequiredArg().ofType(Integer.class).defaultsTo(2048);
            acceptsAll(asList("c", "create"), "Create smart contract from dsl template.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("file.yml");
            accepts("wait", "with --register,  wait for network consensus up to specified number of milliseconds.").withOptionalArg().ofType(Integer.class).defaultsTo(5000).describedAs("milliseconds");
            acceptsAll(asList("j", "json"), "Return result in json format.");
            acceptsAll(asList("v", "verbose"), "Provide more detailed information.");
            acceptsAll(asList("network"), "Check network status.");
            acceptsAll(asList("u-rate"), "Get how many U are given for 1 UTN at this time.");
            acceptsAll(asList("no-cache"), "Do not use session cache");
            accepts("register", "register a specified contract, must be a sealed binary file. Use with either --wallet or --u with --keys to specify payment options. If none are specified default wallet will be used. If no default wallet exist command fails. Amount to pay is specified with --amount").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("contract.unicon");
            accepts("register-parcel", "register a specified parcel").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("parcel.uniparcel");
            accepts("create-parcel", "prepare parcel for registering given contract. use with either --wallet or --u with --keys to specify payment options. If none are specified default wallet will be used. If no default wallet exist command fails. Amount to pay is specified with --amount").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("contract.unicon");
            accepts("put-into-wallet", "Adds specified U/UTN contracts and keys to UUTN wallet (creates one if not exists). " + "Use with non-optional arguments passing U and UTN contracts and --keys to specify keys required to split UTNs and decrement Us. " + "Argument to --put-into-wallet is optional and specifies path to create wallet at. If no path specifed default will be taken (~/.universa)" + "Wallet can then be used with --register and --create-parcel. It will also try to top up when needed Us if there are any UTN contract in the wallet").withOptionalArg().ofType(String.class).describedAs("/path/to/wallet");
            accepts("wallet", "specify wallet to pay with. Use with --register or --create-parcel.").withRequiredArg().ofType(String.class).describedAs("/path/to/wallet");
            accepts("u-for-utn", "reserve U for UTN. Use with --keys to specify keys required to split UTNs and --amount to specify amount of U to reserve").withRequiredArg().ofType(String.class).describedAs("utn.unicon");
            accepts("tu", "Deprecated. Use -u instead.").withRequiredArg().ofType(String.class).describedAs("tu.unicon");
            accepts("u", "Use with --register and --create-parcel. Point to file with your U. " + "Use it to pay for contract's register.").withRequiredArg().ofType(String.class).describedAs("u.unicon");
            accepts("amount", "Use with --register, --create-parcel and -u. " + "Command is set amount of U will be pay for contract's register.").withRequiredArg().ofType(Integer.class).defaultsTo(1).describedAs("u amount");
            accepts("amount-storage", "Use with --register, --create-parcel and -u. " + "Command is set amount-storage of storage U will be pay for contract's register.").withRequiredArg().ofType(Integer.class).defaultsTo(0).describedAs("u amount-storage");
            accepts("tutest", "Deprecated. Use -utest instead.");
            accepts("utest", "Use with --register, --create-parcel and -u. Key is point to use test U.");
            accepts("no-exit", "Used for tests. Uniclient d");
            accepts("probe", "query the state of the document in the Universa network").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("base64_id");
            accepts("probe-file", "query the state of the document in the Universa network").withRequiredArg().ofType(String.class).describedAs("filename");
            accepts("sign", "add signatures to contract. Use with --keys to specify keys to sign with").withRequiredArg().ofType(String.class).describedAs("filename");
            accepts("set-log-levels", "sets log levels of the node,network and udp adapter").withRequiredArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("level");
            accepts("resync", "start resync of the document in the Universa network").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("base64_id");
            accepts("node", "used with to specify node number to connect to").withRequiredArg().ofType(Integer.class);
            accepts("skey", "used with to specify session private key file").withRequiredArg().ofType(String.class).describedAs("file");
            ;
            acceptsAll(asList("k", "keys"), "List of comma-separated private key files to" + "use to sign contract with, if appropriated.").withRequiredArg().ofType(String.class).withValuesSeparatedBy(",").describedAs("key_file");
            acceptsAll(asList("topology"), "Specify topology to be used as entry point. Should be " + "either path to json file for creating new / updating existing named topology " + "or cached topology name").withRequiredArg().ofType(String.class).withValuesSeparatedBy(",").describedAs("./path/to/topology_name.json or topology_name");
            acceptsAll(asList("password"), "List of comma-separated passwords " + "to generate or unpack password protected keys. Use with -g or -k").withRequiredArg().ofType(String.class).withValuesSeparatedBy(",").describedAs("key_password");
            acceptsAll(asList("rounds"), "The number of iterations to use when packing " + "password protected key (default is 160000). The more iterations the longer it takes " + "to unpack private key so it becomes harder to brute force.").withRequiredArg().ofType(String.class).withValuesSeparatedBy(",").describedAs("key_password");
            acceptsAll(asList("k-contract", "keys-contract"), "Use with -register by paying parcel. " + "List of comma-separated private key files to" + "use to sign contract in paying parcel, if appropriated.").withRequiredArg().ofType(String.class).withValuesSeparatedBy(",").describedAs("key_file");
            acceptsAll(asList("fingerprints"), "Print fingerprints of keys specified with -k.");
            // acceptsAll(asList("show", "s"), "show contract")
            // .withRequiredArg().ofType(String.class)
            acceptsAll(asList("e", "export"), "Export specified contract. " + "Default export format is JSON. " + "Use '-as' option with values 'json', 'xml' or 'yaml' for export as specified format.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("file");
            accepts("as", "Use with -e, --export command. Specify format for export contract. " + "Possible values are 'json', 'xml' or 'yaml'.").withRequiredArg().ofType(String.class).describedAs("format");
            acceptsAll(asList("i", "import"), "Import contract from specified xml, json or yaml file.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("file");
            acceptsAll(asList("output", "o"), "Use with -e, --export or -i, --import commands. " + "Specify name of destination file.").withRequiredArg().ofType(String.class).describedAs("filename");
            accepts("extract-key", "Use with -e, --export command. " + "Extracts any public key(s) from specified role into external file.").withRequiredArg().ofType(String.class).describedAs("role");
            accepts("base64", "with --extract-key keys to the text base64 format");
            accepts("get", "Use with -e, --export command. " + "Extracts any field of the contract into external file.").withRequiredArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("field_name");
            accepts("set", "Use with -e, --export command. " + "Specify field of the contract for update. Use -value option to specify value for the field").withRequiredArg().ofType(String.class).describedAs("field_name");
            accepts("value", "Use with -e, --export command and after -set argument. " + "Update specified with -set argument field of the contract.").withRequiredArg().ofType(String.class).describedAs("field_value");
            acceptsAll(asList("f", "find"), "Search all contracts in the specified path including subpaths. " + "Use -r key to check all contracts in the path recursively.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("path");
            acceptsAll(asList("d", "download"), "Download contract from the specified url.").withRequiredArg().ofType(String.class).describedAs("url");
            acceptsAll(asList("ch", "check"), "Check contract for validness. " + "Use -r key to check all contracts in the path recursively.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("file/path");
            accepts("r", "Use with --ch, --check or -f, --find commands. " + "Specify to check contracts in the path and do it recursively.");
            // accepts("binary", "Use with --ch, --check. " +
            // "Specify to check contracts from binary data.");
            accepts("term-width").withRequiredArg().ofType(Integer.class).defaultsTo(80);
            accepts("pretty", "Use with -as json option. Make json string pretty.");
            acceptsAll(asList("revoke"), "Revoke specified contract and create a revocation transactional contract. " + "Use -k option to specify private key for revoke contract, " + "key should be same as key you signed contract for revoke with. " + "You cannot revoke contract without pointing private key.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("file.unicon");
            acceptsAll(asList("split-off"), "Joins specified contract with ones passed as non-optional arguments" + "and splits parts  off the result and transfers ownership of these parts to specified addresses. " + "Use with --parts and --owners to specify the amounts and new owners").withRequiredArg().ofType(String.class).describedAs("file.unicon");
            accepts("field-name", "Use with split-off to specify the field name to split. ").withRequiredArg().ofType(String.class).defaultsTo("amount").describedAs("field_name");
            accepts("parts", "Use with split-off to specify the ammount to split of the main contract. ").withRequiredArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("amount");
            accepts("owners", "Use with split-off to specify new owners of the parts. ").withRequiredArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("address");
            acceptsAll(asList("pack-with"), "Pack contract with counterparts (new, revoking). " + "Use -add-sibling option to add sibling and -add-revoke to add revoke item.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("file.unicon");
            accepts("add-sibling", "Use with --pack-with command. " + "Option add sibling item for packing contract.").withRequiredArg().ofType(String.class).describedAs("sibling.unicon");
            accepts("add-revoke", "Use with --pack-with command. " + "Option add revoke item for packing contract.").withRequiredArg().ofType(String.class).describedAs("file.unicon");
            accepts("add-referenced", "Use with --pack-with command. " + "Option add referenced item to transaction pack.").withRequiredArg().ofType(String.class).describedAs("file.unicon");
            accepts("revision-of", "Use with --import command. " + "Option adds parent to revokes and sets origin, parent and revision to imported contract.").withRequiredArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("parent.unicon");
            acceptsAll(asList("unpack"), "Extracts revoking and new items from contracts and save them.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("file.unicon");
            acceptsAll(asList("cost"), "Print cost of operations for contracts with given files of contracts. " + "Can be used as key with -register command.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("file");
            accepts("anonymize", "Key erase public key from given contract for role given with -role key and replace " + "it with anonymous id for that public key. If -role key is missed will anonymize all roles. " + "After anonymizing contract will be saved as <file_name>_anonymized.unicon. " + "If you want to save with custom name use -name keys.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("file");
            accepts("role", "Use with -anonymize. Set the role name for anonymizing.").withOptionalArg().withValuesSeparatedBy(",").ofType(String.class).describedAs("role_name");
            accepts("address", "Generate address from key. Path to key define in parameter -address. " + "For generate short address use parameter -short.").withRequiredArg().ofType(String.class).describedAs("file");
            accepts("short", "Generate short addres.");
            accepts("address-match", "Matching address with key from file. Address define in parameter -address-match." + "Path to key define in parameter -keyfile.").withRequiredArg().ofType(String.class).describedAs("file");
            accepts("keyfile", "Path to key for matching with address.").withRequiredArg().ofType(String.class).describedAs("file");
            accepts("folder-match", "Associates the entered address with the key file in the specified directory. Path to directory define in parameter -folder-match. " + "Address define in parameter -addr.").withRequiredArg().ofType(String.class).describedAs("file");
            accepts("addr", "Address for finding key in folder.").withRequiredArg().ofType(String.class).describedAs("address");
            accepts("id", "extract ID from a packed contract").withRequiredArg().ofType(String.class).describedAs("packed contract");
            accepts("hash", "get HashId of a file").withRequiredArg().ofType(String.class).describedAs("file");
            accepts("start-http-server", "Starts http server, whose endpoints are implemented in contracts.").withRequiredArg().ofType(String.class).describedAs("routes_file");
            accepts("exec-js", "Executes javascript attached to contract. If your contract have many scripts attached, specify concrete script with --script-name.").withRequiredArg().ofType(String.class).describedAs("packed_contract");
            accepts("script-name", "Use with -exec-js. Set the script filename that would be executed.").withRequiredArg().ofType(String.class).describedAs("script_filename");
            accepts("create-contract-with-js", "Creates new contract with given javascript attached. Use -o to set output filename; -k to set issuer and owner.").withRequiredArg().ofType(String.class).describedAs("javascript_file");
        // acceptsAll(asList("ie"), "Test - delete.")
        // .withRequiredArg().ofType(String.class)
        // .describedAs("file");
        }
    };
    try {
        options = parser.parse(args);
        if (options.has("?")) {
            usage(null);
        }
        if (options.has("node")) {
            setNodeNumber((Integer) options.valueOf("node"));
        }
        if (options.has("skey")) {
            setPrivateKey(new PrivateKey(Do.read((String) options.valueOf("skey"))));
        }
        if (options.has("v")) {
            setVerboseMode(true);
        } else {
            setVerboseMode(false);
        }
        if (options.has("k")) {
            keyFileNames = (List<String>) options.valuesOf("k");
        } else {
            if (!options.has("register") && !options.has("create-parcel")) {
                keyFileNames = new ArrayList<>();
            } else {
                String walletPath = (String) options.valueOf("wallet");
                if (walletPath == null) {
                    walletPath = DEFAULT_WALLET_PATH;
                }
                UUTNWallet wallet = loadWallet(walletPath, false);
                if (wallet == null)
                    keyFileNames = new ArrayList<>();
                else {
                    String finalWalletPath = walletPath;
                    keyFileNames = (List<String>) wallet.config.getListOrThrow("keys").stream().map(kPath -> finalWalletPath + File.separator + kPath).collect(Collectors.toList());
                }
            }
        }
        keyFiles = null;
        if (options.has("k-contract")) {
            keyFileNamesContract = (List<String>) options.valuesOf("k-contract");
        } else {
            keyFileNamesContract = new ArrayList<>();
            keyFilesContract = null;
        }
        if (options.has("fingerprints")) {
            printFingerprints();
            finish();
        }
        if (options.has("j")) {
            reporter.setQuiet(true);
        } else {
            reporter.setQuiet(false);
        }
        if (options.has("topology")) {
            List<String> names = (List) options.valuesOf("topology");
            setTopologyFileName(names.get(0));
        }
        if (options.has("network")) {
            ClientNetwork n = getClientNetwork();
            int total = n.size();
            n.checkNetworkState(reporter);
            finish();
        }
        if (options.has("id")) {
            doShowId();
        }
        if (options.has("hash")) {
            doShowHash();
        }
        if (options.has("probe-file")) {
            doProbeFile();
        }
        if (options.has("sign")) {
            doSign();
        }
        if (options.has("register")) {
            doRegister();
        }
        if (options.has("register-parcel")) {
            doRegisterParcel();
        }
        if (options.has("u-rate")) {
            doGetURate();
        }
        if (options.has("u-for-utn")) {
            doReserveUforUTN();
        }
        if (options.has("create-parcel")) {
            doCreateParcel();
        }
        if (options.has("put-into-wallet")) {
            doPutIntoWallet();
        }
        if (options.has("probe")) {
            doProbe();
        }
        if (options.has("resync")) {
            doResync();
        }
        if (options.has("set-log-levels")) {
            doSetLogLevels();
        }
        if (options.has("g")) {
            doGenerateKeyPair();
            return;
        }
        if (options.has("c")) {
            doCreateContract();
        }
        if (options.has("e")) {
            doExport();
        }
        if (options.has("i")) {
            doImport();
        }
        if (options.has("f")) {
            doFindContracts();
        }
        if (options.has("d")) {
            String source = (String) options.valueOf("d");
            downloadContract(source);
            finish();
        }
        if (options.has("ch")) {
            doCheckContracts();
        }
        if (options.has("revoke")) {
            doRevoke();
        }
        if (options.has("split-off")) {
            doSplit();
        }
        if (options.has("pack-with")) {
            doPackWith();
        }
        if (options.has("unpack")) {
            doUnpackWith();
        }
        if (options.has("cost")) {
            doCost();
        }
        if (options.has("anonymize")) {
            doAnonymize();
        }
        if (options.has("address")) {
            doCreateAddress((String) options.valueOf("address"), options.has("short"));
        }
        if (options.has("address-match")) {
            doAddressMatch((String) options.valueOf("address-match"), (String) options.valueOf("keyfile"));
        }
        if (options.has("folder-match")) {
            doSelectKeyInFolder((String) options.valueOf("folder-match"), (String) options.valueOf("addr"));
        }
        if (options.has("start-http-server")) {
            doStartHttpServer((String) options.valueOf("start-http-server"));
        }
        if (options.has("exec-js")) {
            doExecJs();
        }
        if (options.has("create-contract-with-js")) {
            doCreateContractWithJs();
        }
        usage(null);
    } catch (OptionException e) {
        if (options != null)
            usage("Unrecognized parameter: " + e.getMessage());
        else
            usage("No options: " + e.getMessage());
    } catch (Finished e) {
        if (reporter.isQuiet())
            System.out.println(reporter.reportJson());
        if (!options.has("no-exit")) {
            System.exit(e.getStatus());
        }
    } catch (Exception e) {
        System.err.println("Error: " + e.toString());
        if (options.has("verbose"))
            e.printStackTrace();
        System.out.println("\nShow usage: uniclient --help");
        // usage(e.getMessage());
        if (!options.has("no-exit")) {
            System.exit(100);
        }
    }
}
Also used : HierarchicalStreamWriter(com.thoughtworks.xstream.io.HierarchicalStreamWriter) BuiltinHelpFormatter(joptsimple.BuiltinHelpFormatter) XStream(com.thoughtworks.xstream.XStream) ZonedDateTime(java.time.ZonedDateTime) GsonBuilder(com.google.gson.GsonBuilder) ChangeOwnerPermission(com.icodici.universa.contract.permissions.ChangeOwnerPermission) java.nio.file(java.nio.file) BigDecimal(java.math.BigDecimal) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Gson(com.google.gson.Gson) Arrays.asList(java.util.Arrays.asList) OptionParser(joptsimple.OptionParser) Config(com.icodici.universa.node2.Config) ZoneOffset(java.time.ZoneOffset) Wallet(com.icodici.universa.wallet.Wallet) Role(com.icodici.universa.contract.roles.Role) OptionSet(joptsimple.OptionSet) Safe58(net.sergeych.utils.Safe58) ItemResult(com.icodici.universa.node.ItemResult) Converter(com.thoughtworks.xstream.converters.Converter) PosixFilePermission(java.nio.file.attribute.PosixFilePermission) MarshallingContext(com.thoughtworks.xstream.converters.MarshallingContext) FileAttribute(java.nio.file.attribute.FileAttribute) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) ItemState(com.icodici.universa.node.ItemState) Base64(net.sergeych.utils.Base64) HierarchicalStreamReader(com.thoughtworks.xstream.io.HierarchicalStreamReader) Permission(com.icodici.universa.contract.permissions.Permission) net.sergeych.biserializer(net.sergeych.biserializer) JSApiScriptParameters(com.icodici.universa.contract.jsapi.JSApiScriptParameters) java.util(java.util) BackingStoreException(java.util.prefs.BackingStoreException) net.sergeych.tools(net.sergeych.tools) Yaml(org.yaml.snakeyaml.Yaml) SimpleRole(com.icodici.universa.contract.roles.SimpleRole) PosixFilePermissions(java.nio.file.attribute.PosixFilePermissions) OptionException(joptsimple.OptionException) Base64u(net.sergeych.utils.Base64u) com.icodici.universa.contract(com.icodici.universa.contract) com.icodici.universa.node2.network(com.icodici.universa.node2.network) SplitJoinPermission(com.icodici.universa.contract.permissions.SplitJoinPermission) UnmarshallingContext(com.thoughtworks.xstream.converters.UnmarshallingContext) com.icodici.crypto(com.icodici.crypto) Quantiser(com.icodici.universa.node2.Quantiser) Bytes(net.sergeych.utils.Bytes) Preferences(java.util.prefs.Preferences) com.icodici.universa(com.icodici.universa) java.io(java.io) DateTimeFormatter(java.time.format.DateTimeFormatter) DomDriver(com.thoughtworks.xstream.io.xml.DomDriver) Multimap(net.sergeych.collections.Multimap) RoleLink(com.icodici.universa.contract.roles.RoleLink) Boss(net.sergeych.boss.Boss) OptionException(joptsimple.OptionException) OptionParser(joptsimple.OptionParser) BackingStoreException(java.util.prefs.BackingStoreException) OptionException(joptsimple.OptionException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Arrays.asList(java.util.Arrays.asList)

Aggregations

NetworkServiceInterface (com.google.api.ads.admanager.axis.v202205.NetworkServiceInterface)12 Network (com.google.api.ads.admanager.axis.v202205.Network)6 Random (java.util.Random)5 Network (com.google.api.ads.admanager.axis.v202111.Network)4 NetworkServiceInterface (com.google.api.ads.admanager.axis.v202111.NetworkServiceInterface)4 AdUnitTargeting (com.google.api.ads.admanager.axis.v202205.AdUnitTargeting)4 InventoryTargeting (com.google.api.ads.admanager.axis.v202205.InventoryTargeting)4 Size (com.google.api.ads.admanager.axis.v202205.Size)4 com.icodici.universa (com.icodici.universa)4 com.icodici.universa.contract (com.icodici.universa.contract)4 Role (com.icodici.universa.contract.roles.Role)4 RoleLink (com.icodici.universa.contract.roles.RoleLink)4 SimpleRole (com.icodici.universa.contract.roles.SimpleRole)4 com.icodici.universa.node2.network (com.icodici.universa.node2.network)4 BigDecimal (java.math.BigDecimal)4 Instant (java.time.Instant)4 ZonedDateTime (java.time.ZonedDateTime)4 java.util (java.util)4 Arrays.asList (java.util.Arrays.asList)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4