Deploying and Testing a Configuration

Configure and deploy your Socotra application using Config.zip or with the following options:

  • Configure and deploy tables independently from Config.zip. This option enables you to add or update tables without deploying a new Config.zip. Each table will have an associated effective date. You can retrieve a specific table based on the chosen date, such as the start of a policy term. See the Tables API topic and the Independent Table Configuration topic for more information.

  • Use product versioning with Config.zip. See the Product Versioning topic for information on this method for handling configuration versions.

Deploying a Test Configuration

  1. Create a Config.zip archive of your test configuration.

  2. Using your Socotra Sandbox credentials, authenticate with the Socotra Sandbox API using the POST /account/authenticate endpoint.

  3. Save the token in the API response for use in the next step.

  4. Upload the Config.zip archive to the POST /configuration/deployTest endpoint, unless you are using product versioning. If you are using product versioning, upload Config.zip to the POST /configuration/studio/deploy endpoint.

    • The endpoint will deploy the configuration and return the instance name and hostname to the user.

    • You may specify the tenant name, the instance’s unique identifier, in this step.

      • The first half of the instance name created by this endpoint is your username.

      • The second half may be specified in the request using the tenantNameSuffix parameter.

      • If the suffix is not specified, it will be randomly generated.

    • The users specified in your test_users.json file will be created on the instance.

    • Upload tables if you are configuring and deploying tables independently. See the Tables API topic and the Independent Table Configuration topic for more information.

  5. Log into the hostname from the API response using one of your test users’ credentials and test your configuration.

Deploying a Production Configuration

  1. Create a Config.zip archive of your configuration.

  2. Using your Socotra Sandbox credentials, authenticate with the Socotra Sandbox API using the POST /account/authenticate endpoint.

  3. Save the token in the API response for use in the next step.

  4. Upload the Config.zip archive to the POST /assets/v1/deploy endpoint if you are not using product versioning, or to the the POST /configuration/deploy endpoint if you are using product versioning.

    • The endpoint will deploy the configuration and return the instance name and hostname to the user.

    • You may specify the tenant name, the instance’s unique identifier, in this step.

      • The first half of the instance name created by this endpoint is your username.

      • The second half may be specified in the request using the tenantNameSuffix parameter.

      • If the suffix is not specified, it will be randomly generated.

    • Upload tables if you are configuring and deploying tables independently. See the Tables API topic and the Independent Table Configuration topic for more information.

  5. Log into the hostname from the API response using one of your test users’ credentials and test your configuration.

Update an Instance

Socotra supports deploying different configurations onto the same instance. You can update your production environment in place or be used for testing to reuse data that already exists on an instance. When deploying configuration the instance name can be specified in the request. If the instance name has been deployed onto before then it will be deployed onto again. Note that deploying onto the same instance may cause problems when configuration changes are not backwards compatible.

Note

See the Product Versioning topic for information on a method for handling configuration versions.

Example Test Deployment

This is a python script demonstrating the process for deploying a configuration without product versioning:

$ python test_configuration_loader.py -z /home/socotra/test_configuration.zip -u jsmith -p password
import argparse
import json
import requests

API_URL = 'https://api.sandbox.socotra.com'


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('--zipfile', '-z', help='The path to the zipfile containing a configuration')
    parser.add_argument('--username', '-u', help='Your Socotra username')
    parser.add_argument('--password', '-p', help='Your Socotra password')
    parser.add_argument('--hostname', '-n', help='The hostname is a combination of your account '
                                                 'name and the suffix specified here. Not Required')
    return parser.parse_args()


def main():
    args = parse_args()
    client = SocotraClient(API_URL)
    client.authenticate(args.username, args.password)
    response = client.load_configuration_for_testing(args.zipfile, args.hostname)
    if response['success']:
        print 'Tenant loaded at %s' % response['hostname']
    else:
        print 'Tenant failed to load'


class SocotraClient(object):
    def __init__(self, api_url):
        self.api_url = api_url
        self.session = requests.Session()

    def _post(self, *args, **kwargs):
        response = self.session.post(*args, **kwargs)
        response_json = json.loads(response.text)
        if response.status_code != 200:
            message = "POST request to %s failed with status %s and message: %s"
            message = message % (response.url, response.status_code, response_json.get('message'))
            raise Exception(message)
        else:
            return response_json

    def authenticate(self, username, password):
        endpoint = self.api_url + '/account/authenticate'
        json_body = {'username': username,
                     'password': password}
        response = self._post(endpoint, json=json_body)
        token = response['authorizationToken']
        return self.session.headers.update({'Authorization': token})

    def load_configuration_for_testing(self, zipfile_location, tenant_suffix):
        endpoint = self.api_url + '/configuration/deployTest'
        multipart_form_data = {
            'zipFile': open(zipfile_location, 'rb')
        }
        return self._post(endpoint, files=multipart_form_data,
                          data={'tenantNameSuffix': tenant_suffix})

if __name__ == "__main__":
    main()