def start_server():
    try:
        config_file = Utils.get_config_file()
        Config(api_url=config_file['quickStart']['url'],
               api_key=config_file['quickStart']['key'],
               products=config_file['quickStart']['products'])

        logger.setLevel(config_file['quickStart']['log_level'])
        logger.addHandler(FileHandler(config_file['logFilename']))

        daemonizer = Daemonizer(cherrypy.engine)
        daemonizer.subscribe()
        # Configure and launch
        cherrypy.config.update(
            {'server.socket_port': config_file['executionPort']})
        cherrypy.quickstart(FulfilmentExecution(config_file))
    except Exception as err:
        raise err
Exemplo n.º 2
0
# This file is part of the Ingram Micro Cloud Blue Connect SDK.
# Copyright (c) 2019 Ingram Micro. All Rights Reserved.

from datetime import datetime, timedelta
import warnings

from connect.config import Config
from connect.logger import logger
from connect.models import Contract, UsageRecord, UsageFile, UsageListing, Product
from connect.resources import UsageAutomation

# Enable processing of deprecation warnings
warnings.simplefilter('default')

# Set logger level / default level ERROR
logger.setLevel('DEBUG')

# If we remove this line, it is done implicitly
Config(file='config.json')


class UsageExample(UsageAutomation):
    def process_request(self, request):
        # type: (UsageListing) -> None

        # Detect specific provider contract
        if request.contract.id == 'CRD-41560-05399-123':
            # Can also be seen from request.provider.id and parametrized further
            # via marketplace available at request.marketplace.id
            usage_file = UsageFile(
                name='sdk test',
Exemplo n.º 3
0
from connect import FulfillmentAutomation
from connect.config import Config
from connect.logger import logger
from connect.models import ActivationTemplateResponse, ActivationTileResponse
from connect.models.exception import FulfillmentFail, FulfillmentInquire, Skip

Config(file='config.json')

# set logger level / default level ERROR
logger.setLevel("DEBUG")


class ExampleRequestProcessor(FulfillmentAutomation):
    def process_request(self, request):

        # custom logic
        if request.type == 'purchase':
            for item in request.asset.items:
                if item.quantity > 100000:
                    raise FulfillmentFail(
                        message='Is Not possible to purchase product')

            for param in request.asset.params:
                if param.name == 'email' and not param.value:
                    param.value_error = 'Email address has not been provided, please provide one'
                    raise FulfillmentInquire(params=[param])

            # approve by ActivationTile
            return ActivationTileResponse(
                tile='\n  # Welcome to Fallball!\n\nYes, '
                'you decided to have an account in our amazing service!')
# -*- coding: utf-8 -*-
"""
This file is part of the Ingram Micro Cloud Blue Connect SDK.
Copyright (c) 2019 Ingram Micro. All Rights Reserved.
"""
from connect.config import Config
from connect.logger import logger
from app.tier_fulfillment import TierFulfillment
from app.product_fulfillment import ProductFulfillment
from app.utils.utils import Utils

# Set logger level (default level is ERROR)
logger.setLevel("INFO")

if __name__ == '__main__':
    config_file = Utils.get_config_file()
    tier_request = TierFulfillment(
        Config(api_url=config_file['quickStart']['url'],
               api_key=config_file['quickStart']['key'],
               products=config_file['quickStart']['products']))

    tier_request.process()

    request = ProductFulfillment(
        Config(api_url=config_file['quickStart']['url'],
               api_key=config_file['quickStart']['key'],
               products=config_file['quickStart']['products']))

    request.process()