Manage Services Sample

A command line console application that provides access to the Inbound Service Management, Outbound Service Management and Outbound Queue Management facilities of the Aculab Cloud Web Services API. This sample allows you to run a number of commands that give the ability to list, read, write, modify and delete service configurations; list and purge outbound service queues; and retrieve service configuration schemas. The final result of running a command successfully is written to stdout or (If the 'dstFilename' argument is set (Only applicable to the schema, read, write and modify commands)) saved to file. All other text is written to stderr.

Usage

python manage_services.py [--wsserver <cloudWebServerAddress>] <cloudId> <username> <apiAccessKey> <command>

Arguments

cloudWebServerAddress

The address of the cloud web server. By default the wrappers call web services on ws.aculabcloud.net. In certain circumstances you may need to use a different address which you can set here.

cloudId

cloud region id (e.g. 1-2-0)

username

cloud account username

apiAccessKey

cloud API Access key

command

One of the following...

list <direction>

schema <direction> [<dstFilename>]

read <direction> <serviceName> [<dstFilename>]

write <direction> <serviceName> <srcFilename> [<dstFilename>]

modify <direction> <serviceName> <srcFilename> [<dstFilename>]

delete <direction> <serviceName>

outbound_queues

outbound_queue_info <serviceName> [<servicePassword>]

outbound_purge_queue <serviceName> [<servicePassword>]

Where...

direction

direction of the service. Either 'inbound' or 'outbound'.

serviceName

The name of the service.

servicePassword

The service password found in the outbound service configuration. When set, the value supplied for the apiAccessKey is ignored and the cloud server will perform authentication using the service password instead.

srcFilename

The name of a file on the local file system containing a full or partial configuration of a service. The contents of the file must be JSON formatted. When running the 'write' command, this is the configuration that you want to create/replace your service with. When running the 'modify' command, this is the configuration that you want to modify your existing service with. When writing an inbound service, you can set this argument to "-" if you do not wish to specify a configuration file (Resulting in a service configuration being written with all its options set to default values).

dstFilename

The name of a file on the local file system to dump the service configuration schema (If using the schema command) or the configuration of a service (If using the read, write and modify commands). The contents of the file will be saved as JSON formatted data. If the file already exists, it will be overwritten. If omitted, the schema/configuration is written to stdout.

Note

The following exit codes apply: 0 indicates succeeded, 1 indicates an argument error and 2 indicates an exception was caught.

Examples

  1. List all inbound services.

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ list inbound
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Listing inbound services...
    
        stdout:
            4 service(s) found:
            --12345678                     Target[quickstart] Description[Your developer service, accessed uing your developer PIN code.]
            MyTestServiceA                 Target[http://blabla.com/myfirstpage] Description[This is rest service I use for testing.]
            MyTestServiceB                 Target[my_conference_uas_app] Description[My uas service. I also use this for testing.]
            MyTestServiceC                 Description[I haven't bothered specifying a rest first_page or application name yet.]
    
  2. Retrieve an inbound schema and dump it to file.

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ schema inbound C:\MyCloudServices\MyInboundSchema.json
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Getting inbound schema...
    
            Dumping the schema to 'C:\MyCloudServices\MyInboundSchema.json'.
    
        Nothing is written to stdout.
    
  3. Retrieve an outbound schema and print it to stdout.

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ schema outbound
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Getting outbound schema...
    
            Dumping the schema to stdout.
    
        stdout:
            <The outbound schema>
    
  4. Read an outbound service configuration and dump it to file.

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ read outbound MyOutboundService1 C:\MyCloudServices\MyOutboundService1.json
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Reading outbound service 'MyOutboundService1'...
    
            Dumping the configuration to 'C:\MyCloudServices\MyOutboundService1.json'.
    
        Nothing is written to stdout.
    
  5. Create an inbound service with all options set to default values and dump the new configuration to file.

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ write inbound MyInboundService2 - C:\MyCloudServices\MyInboundService2.json
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Writing inbound service 'MyInboundService2'...
    
            MyInboundService2 has been created. Dumping the new configuration to 'C:\MyCloudServices\MyInboundService2.json'.
    
        Nothing is written to stdout.
    
  6. Create an outbound service and dump the new configuration to file.

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ write outbound MyOutboundService2 C:\MyCloudServices\MySimpleOutboundRestCfg.json C:\MyCloudServices\MyOutboundService2.json
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Writing outbound service 'MyOutboundService2'...
    
            MyOutboundService2 has been created. Dumping the new configuration to 'C:\MyCloudServices\MyOutboundService2.json'.
    
        Nothing is written to stdout.
    
  7. Replace an existing inbound service with a new configuration and print the resultant configuration to stdout.

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ write inbound MyInboundService2 C:\MyCloudServices\MyNewConfig.json
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Writing inbound service 'MyInboundService2'...
    
            MyInboundService2 has been replaced. Dumping the new configuration to stdout.
    
        stdout:
            <The service configuration for MyInboundService2>
    
  8. Modify an existing outbound service and dump the modified configuration to file.

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ modify outbound MyOutboundService2 C:\MyCloudServices\MySimpleOutboundUASCfg.json C:\MyCloudServices\MyOutboundService2.json
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Modifying outbound service 'MyOutboundService2'...
    
            MyOutboundService2 has been modified. Dumping the new configuration to 'C:\MyCloudServices\MyOutboundService2.json'.
    
        Nothing is written to stdout.
    
  9. Delete an inbound service

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ delete inbound MyInboundService2
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Deleting inbound service 'MyInboundService2'...
    
        stdout:
            MyInboundService2 has been deleted.
    
  10. Retrieve the queue information for all outbound services that have queued service starts.

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ outbound_queues
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Retrieving queue information for all outbound services that have queued service starts......
    
        stdout:
            2 service(s) found:
            MyTestServiceD has 47 queued service starts.
            MyTestServiceF has 123 queued service starts.
    
  11. Retrieve the queue information for a specific outbound service

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ outbound_queue_info MyTestServiceE
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Retrieving queue information for 'MyTestServiceE'...
    
        stdout:
            MyTestServicE has 0 queued service starts.
    
  12. Purge the queue for a specific outbound service

    ManageServices 1-2-0 bob@acompany.com 6b4UmwoOPxjeI2M76aebfQ outbound_purge_queue MyTestServiceD
    
    Output:
        stderr:
            <Language> Manage Services Web Service Sample
    
            Purging queue for 'MyTestServiceD'...
    
        stdout:
            MyTestServiceD has had 47 queued service starts cancelled.