Yaml Template Guide

Merchant needs to register their service informations to the platform via a yaml file. By using the merchant cli client, the yaml format configuration file is transmitted to the merchant node. After the node verifies the information, it is sent to the platform node for further analysis and registration.

Yaml Template File Example

provider: service-merchant-registration-demo-2
walletAddress: ATzEKTyxxxxxxxxxxxxxxxxxxxxxuTebug
apiHost: "demo-api-host"
serviceCategory:
  - name: Container-Service
    categoryDescription: "This is a category description for several service types."
    apiHost: "category api"
    options:
      user-choose-option-1: &user-choose-option-1
        - 1-choose-value-1
        - 1-choose-value-2
        - 1-choose-value-3
        - 1-choose-value-4
        - 1-choose-value-5
        - 1-choose-value-6
      user-choose-option-2: &user-choose-option-2
        - 2-choose-value-1
        - 2-choose-value-2
    services:
      - name: Demo-Service-Name-1
        description: "Documentation for user to use this service: http:xxxxxxx"
        apiHost: "11.42.119.90:3002"
        refundable: true
        options:
          user-choose-option-1: *user-choose-option-1
          user-choose-option-2: *user-choose-option-2
        serviceFunctionApi:
          start: "local http = require(\"VsysHttp\")\nlocal util = require(\"SystemUtils\")\nfunction start(inputTable)\n    util.preventDefault()\n    a = {} \t\n    a[\"id\"]= inputTable[\"id\"] \t\n    a[\"createdAt\"] = inputTable[\"createdAt\"] \t\n    a[\"duration\"] = inputTable[\"duration\"] \t\n    resp = http.postwosign(\"http://127.0.0.1:3004/service/secret\", a) \t\n    return resp\nend"
          stop: "local http = require(\"VsysHttp\")\nfunction stop(inputTable)\n    a = {}\n    a[\"id\"] = inputTable[\"id\"]\n    a[\"createdAt\"] = inputTable[\"createdAt\"]\n    resp = http.postwosign(\"http://127.0.0.1:3004/service/deploy/\"..a[\"id\"], a)\n    return resp\nend"
		  refund: ""
        durationToPrice:
          - setA:
            price: 100
            chargingOptions:
              user-choose-option-1: 1-choose-value-1
            duration:
              100: 0.9
              200: 0.85
          - setB:
            price: 200
            chargingOptions:
              user-choose-option-1: 1-choose-value-2
            duration:
              100: 0.9
              200: 0.85
          - setC:
            price: 500
            chargingOptions:
              user-choose-option-1: 1-choose-value-3
            duration:
              100: 0.9
              200: 0.85

Overview

Attribute Type Required Description
provider string True Merchant name must be unique
walletAddress string True Merchant's VSYS address must be unique
apiHost string True The url which user cli tool send requests to, such as request User Service
serviceCategory list True List of categories of providers' services

Fields in serviceCategory

The data type ofserviceCategory is list, it contains the configuration of each service category provided by merchants.

Attribute Type Required Description
name string True Service category name
categoryDescription string False Service category description
apiHost string False The Standby API of a specific service category
options object False Options provided by service category.
services list False Service category list

Fields in serviceCategory -- options

options is the object of YAML, and the value of options key is user-defined list. In the sample, two services options groups are defined, named as user-choose-option-1 and user-choose- option-2. Both of these two variables' type are list, which defines the available options in service options group. In order to utilize service options for the following specific service types, the yaml & syntax should be used after each service options group.

There is no limit to the number of variables in options. The elements in the service options list is string.

Fields in serviceCategory -- services

services is defined as the specific services under a service category. Its variable type is list. Each element is a service type. The following content is the description of variables that define a serivice type.

Attribute Type Required Description
name string True The name of a specific service, should be unique under a service category
description string False Service description of payment methods and usage guide of the service
apiHost string False The service API host. If the variable is empty, the system will use the backup API host from serviceCategory
refundable bool True If the service is refundable
options object True The options of the service type used by the service
serviceFunctionApi object False The user-defined Lua Scripts for services start , stop and refund
durationToPrice object True It defines the base price according to the value in chargingOption, and the discount factor for service time exceeding cetain level

Fields in services -- serviceFunctionApi

Attribute Type Required Description
start string False A lua script for preparing service resource after user paid
stop string False A lua script for service termination
refund string False A lua script for refund logic

After the above Lua script is edited in the local editor, it needs to be URL-encoded and then entered as a string into the corresponding field.

Fields in services -- durationToPrice

Attribute Type Required Description
price float64 True Service price per hour
chargingOptions dict True The charging options that the service use
duration dict True The discount factor corresponds to the purchased service duration

See Prices Calculation Document for detailed price calculation process.

Last Updated: 6/16/2021, 8:38:11 AM