def _save_fulfillment_parameters(request, client):
        # type: (Dict, ConnectClient) -> None
        """ This method saves the needed information of the reseller in the tier config request's fulfillment
            parameters. Customize the Payload params ids with your product tier fulfillment parameters id in Connect and
            the params values with the ones given by the Vendor API. """

        tcr_id = Utils.get_basic_value(request, 'id')

        # Prepare the update parameters payload with the response of APIClient.create_subscription method
        payload = {
            "params": [
                {
                    # TODO: Customize the tier fulfillment parameter id, as configured in product in Connect
                    "id": "param_a",
                    "value": "value for param_a in Vendor System",
                    "value_error": "",
                    "structured_value": ""
                },
                {
                    # TODO: Change and/or add the tier fulfillment parameters id, as configured in product in Connect
                    "id": "param_b",
                    "value": "value for param b in Vendor System",
                    "value_error": "",
                    "structured_value": ""
                }
            ]
        }

        # Update the value in the fulfillment parameter of the tier configuration
        Utils.update_tier1_parameters(tcr_id, payload, client)
    def _save_fulfillment_parameters(request, client):
        # type: (Dict, ConnectClient) -> None
        """ This method saves the needed information of the created subscription in the request's fulfillment
            parameters. Customize the Payload params ids with your product fulfillment parameters id in Connect and
            the params values with the ones given by the Vendor API. """

        request_id = Utils.get_basic_value(request, 'id')
        # Update the fulfilment parameters in Fulfillment Request in Connect with the corresponding value

        # Prepare the update parameters payload with the response of APIClient.create_subscription method
        payload = {
            "asset": {
                "params": [
                    {
                        # TODO: Customize the fulfillment parameter id, as configured in product in Connect
                        # Saving the Subscription ID from Vendor system is encouraged to be able to map
                        # the subscription in Connect with the subscription in Vendor system
                        "id": "subscription_id",
                        "value": "value for subscription ID in Vendor System",
                        "value_error": "",
                        "structured_value": {}
                    },
                    {
                        # TODO: Change and/or add the fulfillment parameters id, as configured in product in Connect
                        "id": "param_b",
                        "value": "value for parameter b",
                        "value_error": "",
                        "structured_value": {}
                    }
                ]
            }
        }

        # Update the value in the fulfillment parameter
        Utils.update_subscription_parameters(request_id, payload, client)
    def process_request(request, client):
        # type: (Dict, ConnectClient) -> Dict
        """ This method processes a tier configuration request in pending status for setup and update action. """

        # Check the reseller data in vendor system by calling the Vendor API
        # TODO: implement the Vendor API call to check, create or update the reseller in Vendor portal
        # The following is the Mock API and client to check tier scope ordering phase parameters
        # api_client = APIClient(api_url='',
        #                        api_key='')
        # data = {}
        # reseller_info = api_client.check_reseller(data=data)
        tcr_id = Utils.get_basic_value(request, 'id')

        # The response of check reseller Vendor API might have some information that needs to be saved in
        # the fulfillment parameter of the tier config request in Connect
        # With this response complete the tier config fulfillment parameters to be able to approve the request
        TierConfiguration._save_fulfillment_parameters(request, client)

        # If any tier scope parameter is not valid, the tier config request can be changed to Inquiring status,
        # so the reseller can change and check the entered values
        # using this method call Utils.set_inquiring_tier_config_request(tcr_id, client)

        return Utils.approve_tier_config_request(request, tcr_id, client)
Exemple #4
0
        for tcr in tc_requests:
            project_manager.tier_fulfillment.TierConfiguration.process_request(
                tcr, client)

    # Filter to fetch all the subscription Fulfillment requests from Connect that need to be processed by this Processor
    query = R()
    query &= R().asset.product.id.oneof(Globals.PRODUCTS)
    query &= R().asset.connection.type.oneof(Globals.ENVIRONMENT)
    query &= R().status.oneof(['pending'])

    # Applying the filter
    requests = client.collection('requests').filter(query)

    # Processing each request
    for request in requests:
        request_id = Utils.get_basic_value(request, 'id')
        request_status = Utils.get_basic_value(request, 'status')
        # Process all Fulfillment Request with status Pending
        if request_status == 'pending':
            # Check the type of Fulfillment Request
            request_type = Utils.get_basic_value(request, 'type')

            if request_type == 'purchase':
                # Type PURCHASE means, it is a new subscription in Connect
                if hasattr(project_manager, 'purchase'):
                    project_manager.purchase.Purchase.process_request(
                        request, client)

            if request_type == 'change':
                # Type CHANGE means, it is a change request of an existing active subscription in Connect
                # Change request includes request for changing the quantity of subscribed item/SKU