diff --git a/.github/workflows/build-plantuml.yml b/.github/workflows/build-plantuml.yml index f1965e2..2e0cb73 100644 --- a/.github/workflows/build-plantuml.yml +++ b/.github/workflows/build-plantuml.yml @@ -17,23 +17,33 @@ jobs: run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT id: extract_branch - - name: Run script + - name: Set execute permission for all the scripts run: | - cd models/schemas/ - bash ./generate_puml.sh - cd ../examples - bash ./generate_puml.sh - # Add any additional commands your script might need (e.g., install dependencies) + chmod +x scripts/*.sh + chmod +x scripts/*.py + + - name: Generate PlantUML + run: | + bash ./scripts/generate_puml.sh ./models/schemas/ + bash ./scripts/generate_puml.sh ./models/examples/ + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install -r scripts/requirements.txt - name: Generate SVG run: | - cd models/ - python3 generate_svg.py ${{ steps.extract_branch.outputs.branch }} + python scripts/generate_svg.py ./puml - name: Generate Docs - run: | - cd docs - python3 generate_docs.py + run: | + python scripts/generate_docs.py ./models/schemas/ ./svg/models/schemas/ ./svg/models/examples/ - name: Check for changes id: git-check diff --git a/README.md b/README.md deleted file mode 100644 index 7f3d773..0000000 --- a/README.md +++ /dev/null @@ -1,120 +0,0 @@ - -``` -DISCLAIMER #1: The content of this document is automatically generated upon pushing the files on GitHub. -The generation starts from the JSON schema and examples contained in the repository. -Do not try to modify this document, just the JSON files. -``` -``` -DISCLAIMER #2: Still, the generation of examples of JSONs (starting from the schema) is not automated yet. -Therefore, we suggest to use tools like ChatGPT or Gemini, providing the JSON schema to the prompt and asking for an example of compliant JSON. -``` -In the following we represent some examples of JSON, you can find the original JSON schemas [here](models/schemas). - -# Flavor -![0](models/examples/svg/flavor.svg) -- **FlavorID**. The unique identifier for a flavor ['string'] -- **ProviderID**. The unique identifier for a provider ['string'] -- **Timestamp**. Timestamp of the provided Flavor offer. It allows to advertise Flavors in the (near) future ['string'] -- **Location**: - - **Latitude**. Latitude of the location ['string'] - - **Longitude**. Longitude of the location ['string'] - - **Altitude**. Altitude of the location expressed in meters ['string'] - - **AdditionalNotes**. Additional notes about the location ['string'] -- **NetworkPropertyType**. Type of network property ensured by the privider (e.g., 5G, Wifi, Ethernet) ['string'] -- **FlavorType**. A reference to a specific flavor type schema using JSON references ($ref) to external files like 'k8slice.json', 'vm.json', etc. This allows defining details specific to each flavor type. -- **Price**: - - **Amount**. Amount of the price. ['string'] - - **Currency**. Currency of the price. ['string'] - - **Period**. Period of the price. ['string'] -- **Owner**: - - **Domain**. Domain of the node. ['string'] - - **NodeID**. ID of the node. ['string'] - - **IP**. IP of the node. ['string'] - - **AdditionalInformation**: - - **LiqoID**. Liqo ID of the node. ['string'] -- **OptionalFields**: - - **Availability**. Availability flag of the Flavor. ['boolean'] - - **WorkerID**. ID of the worker that provides the Flavor. ['string'] -- **AdditionalInfo**. Additional information to enrich the Flavor description using a key: value representation. ['string'] - -# FlavorType -The FlavorType describes the actual flavor that is adverised. - -## k8slice -![1](models/examples/svg/flavor-types/k8slice.svg) -- **Characteristics**: - - **CPU**. The number of CPU cores ['integer'] - - **Pods**. The number of pods ['integer'] - - **Memory**. The amount of memory ['integer'] - - **GPU**: - - **GPUModel**. The model of the GPU offered for the specific Flavor. ['string'] - - **GPUCores**. The number of GPU cores advertised by the Flavor. ['integer'] - - **Storage**. The amount of storage ['integer'] -- **Properties**: - - **Latency**. The latency of the Flavor. ['integer'] - - **SecurityStandards**. Security standards supported by the Flavor (e.g., GDPR). ['array'] - - **CarbonFootprint**: - - **Embodied**. Embodied carbon of the node hardware normalized by its expected lifetime. ['integer'] - - **Operational**. Forecasted average carbon intensity of the node for the next N windows/hours. ['array'] -- **Policy**: - - **Aggregatable**: - - **MinCount**. Minimum required number of instances of the Flavor. ['integer'] - - **MaxCount**. Maximum required number of instances of the Flavor. ['integer'] - - **Partitionable**: - - **CpuMin**. Minimum required number of CPU cores of the Flavor. ['integer'] - - **MemoryMin**. Minimum required amount of RAM of the Flavor. ['integer'] - - **CpuStep**. Incremental value of CPU cores of the Flavor. ['integer'] - - **MemoryStep**. Incremental value of RAM of the Flavor. ['integer'] - -## service -![2](models/examples/svg/flavor-types/service.svg) -- **Characteristics**: - - **Name**. Name of the flavor. ['string'] - - **Description**. Description of the flavor. ['string'] - - **Tags**. Tags associated with the flavor. ['array'] - - **Plan**. Plan of the flavor. ['string'] - - **Latency**. The latency of the Flavor. ['integer'] - - **SecurityStandards**. Security standards supported by the Flavor (e.g., GDPR). ['array'] -- **ServiceType**. ServiceType to describe the specific characteristics of the advertised flavor. - -## vm -![3](models/examples/svg/flavor-types/vm.svg) -- **Characteristics**: - - **Architecture**. Architecture of the Flavor. ['string'] - - **OS**. The Operating System of the advertised VM ['string'] - - **CPU**. Number of CPU cores of the Flavor. ['integer'] - - **Memory**. Amount of RAM of the Flavor. ['integer'] - - **GPU**: - - **GPUModel**. The model of the GPU offered for the specific Flavor. ['string'] - - **GPUCores**. The number of GPU cores advertised by the Flavor. ['integer'] - - **Storage**. The amount of storage ['integer'] -- **Properties**: - - **Latency**. The latency of the Flavor. ['integer'] - - **SecurityStandards**. Security standards supported by the Flavor (e.g., GDPR). ['array'] - - **CarbonFootprint**: - - **Embodied**. Embodied carbon of the node hardware normalized by its expected lifetime. ['integer'] - - **Operational**. Forecasted average carbon intensity of the node for the next N windows/hours. ['array'] -- **Policy**: - - **Aggregatable**: - - **MinCount**. Minimum required number of instances of the Flavor. ['integer'] - - **MaxCount**. Maximum required number of instances of the Flavor. ['integer'] - -## sensor -![4](models/examples/svg/flavor-types/sensor.svg) -- **Characteristics**: - - **SensorType**. The type of sensor ['string'] - - **SensorModel**. The model of sensor ['string'] - - **SensorManufacturer**. The manufacturer of sensor ['string'] - - **SensorMarket**. The market of sensor ['string'] - - **SamplingRate**. The sampling rate of the sensor in milliseconds ['integer'] - - **Accuracy**. The accuracy reported for the measurements (unit percentage) ['integer'] - - **Consumption**. The power consumption of the reported sensor (unit mW) ['integer'] - - **Interface**. Not clear what that means. ['string'] - - **SecurityStandards**. Security standards supported by the Flavor (e.g., GDPR). ['array'] - - **Latency**. The latency of the Flavor. ['integer'] - - **additionalProperties**: - - **MeasurementUnit**. The unit of measure for the measurements ['string'] - - **ConsumptionUnit**. The unit of measure for the sensor power consumption ['string'] - - **SamplingRateUnit**. The unit of measure for the sampling rate ['string'] - - **AccessProtocol**. Not sure what that means ['string'] -- **AccessType**. The access type of the sensor. Currently, HTTP and MQTT are supported. \ No newline at end of file diff --git a/docs/generate_docs.py b/docs/generate_docs.py deleted file mode 100644 index cca20cc..0000000 --- a/docs/generate_docs.py +++ /dev/null @@ -1,57 +0,0 @@ -import json - -def generate_html(data, depth, res): - spaces = "" - for i in range(depth): - spaces += " " - spaces += " " - - for key in data: - if "oneOf" in data[key]: - res.append(f"{spaces}- **{key}**. {data[key]['description']}") - continue - if data[key]["type"] != "object": - res.append(f"{spaces}- **{key}**. {data[key]['description']} {[data[key]['type']]}") - else: - res.append(f"{spaces}- **{key}**:") - generate_html(data[key]["properties"], depth + 1, res) - -dir = "../models/schemas" -example_dir = "models/examples/svg" - -filenames = ["flavor.json", "flavor-types/k8slice.json", "flavor-types/service.json", "flavor-types/vm.json", "flavor-types/sensor.json"] -res = [""] -res.append("```") -res.append("DISCLAIMER #1: The content of this document is automatically generated upon pushing the files on GitHub. \nThe generation starts from the JSON schema and examples contained in the repository. \nDo not try to modify this document, just the JSON files.") -res.append("```") -res.append("```") -res.append("DISCLAIMER #2: Still, the generation of examples of JSONs (starting from the schema) is not automated yet. \nTherefore, we suggest to use tools like ChatGPT or Gemini, providing the JSON schema to the prompt and asking for an example of compliant JSON.") -res.append("```") -res.append("In the following we represent some examples of JSON, you can find the original JSON schemas [here](models/schemas).") - -for id, f_name in enumerate(filenames): - res.append("") - if f_name == "flavor.json": - res.append("# Flavor") - else: - res.append(f"## {f_name.replace('.json', '').replace('flavor-types/', '')}") - - res.append(f"![{str(id)}]({'/'.join([example_dir, f_name.replace('.json', '.svg')])})") - - f = open("/".join([dir, f_name])) - data = json.load(f) - - generate_html(data["properties"], 0, res) - - if f_name == "flavor.json": - res.append("") - res.append("# FlavorType") - res.append("The FlavorType describes the actual flavor that is adverised.") - -text_file = open("../README.md", "w") - -#write string to file -text_file.write("\n".join(res)) - -#close file -text_file.close() \ No newline at end of file diff --git a/models/examples/configuration-types/k8slice-configuration.json b/models/examples/configuration-types/k8slice-configuration.json new file mode 100644 index 0000000..378ed72 --- /dev/null +++ b/models/examples/configuration-types/k8slice-configuration.json @@ -0,0 +1,11 @@ +{ + "cpu": "2", + "pods": "5", + "memory": "4Gi", + "gpu": { + "model": "NVIDIA Tesla V100", + "cores": "1", + "memory": "16Gi" + }, + "storage": "100Gi" +} \ No newline at end of file diff --git a/models/examples/configuration.json b/models/examples/configuration.json new file mode 100644 index 0000000..a68a15b --- /dev/null +++ b/models/examples/configuration.json @@ -0,0 +1,6 @@ +{ + "type": "k8slice", + "data": { + "$ref": "./configurationTypes/k8slice-configuration.schema.json" + } +} \ No newline at end of file diff --git a/models/examples/contract.json b/models/examples/contract.json new file mode 100644 index 0000000..c1843dc --- /dev/null +++ b/models/examples/contract.json @@ -0,0 +1,16 @@ +{ + "ContractID": "12345-abcde", + "Flavor": { + "$ref": "./flavor.schema.json" + }, + "Buyer": { + "$ref": "node-identity.schema.json" + }, + "Seller": { + "$ref": "node-identity.schema.json" + }, + "ExpirationTime": "2024-12-31T23:59:59Z", + "Credentials": { + "$ref": "credentials/liqo-credentials.schema.json" + } +} diff --git a/models/examples/credentials/liqo-credentials.json b/models/examples/credentials/liqo-credentials.json new file mode 100644 index 0000000..9c820b7 --- /dev/null +++ b/models/examples/credentials/liqo-credentials.json @@ -0,0 +1,6 @@ +{ + "clusterID": "cluster-123", + "clusterName": "ExampleCluster", + "endpoint": "https://example.cluster.endpoint", + "token": "abc123token" +} diff --git a/models/examples/flavor-types/k8slice.json b/models/examples/flavor-types/k8slice.json new file mode 100644 index 0000000..f29c595 --- /dev/null +++ b/models/examples/flavor-types/k8slice.json @@ -0,0 +1,35 @@ +{ + "name": "ExampleK8Slice", + "characteristics": { + "cpu": "2", + "pods": "5", + "memory": "4Gi", + "gpu": { + "model": "NVIDIA Tesla K80", + "cores": "1", + "memory": "12Gi" + }, + "storage": "100Gi" + }, + "properties": { + "latency": 50, + "securityStandards": [ + "GDPR", + "HIPAA" + ], + "carbonFootprint": { + "embodied": 2000, + "operational": [] + } + }, + "policies": { + "partitionability": { + "cpuMin": "500m", + "memoryMin": "1Gi", + "podsMin": "1", + "cpuStep": "250m", + "memoryStep": "512Mi", + "podsStep": "1" + } + } +} diff --git a/models/examples/flavor-types/sensor.json b/models/examples/flavor-types/sensor.json new file mode 100644 index 0000000..c72ca4d --- /dev/null +++ b/models/examples/flavor-types/sensor.json @@ -0,0 +1,31 @@ +{ + "Characteristics": { + "SensorType": "Temperature", + "SensorModel": "T1000", + "SensorManufacturer": "SensorCorp", + "SensorMarket": "Industrial", + "SamplingRate": 1000, + "Accuracy": 95, + "Consumption": 50, + "Interface": "I2C", + "SecurityStandards": [ + "ISO 27001", + "GDPR" + ], + "Latency": 10, + "additionalProperties": { + "MeasurementUnit": "Celsius", + "ConsumptionUnit": "mW", + "SamplingRateUnit": "milliseconds", + "AccessProtocol": "HTTP" + } + }, + "AccessType": { + "HTTP": { + "method": [ + "GET", + "POST" + ] + } + } +} diff --git a/models/examples/flavor-types/service.json b/models/examples/flavor-types/service.json new file mode 100644 index 0000000..7c35c29 --- /dev/null +++ b/models/examples/flavor-types/service.json @@ -0,0 +1,17 @@ +{ + "Characteristics": { + "Name": "Database Service", + "Description": "A scalable database service for applications.", + "Tags": [ + "database", + "scalable", + "managed" + ], + "Plan": "Premium", + "Latency": 20, + "SecurityStandards": [ + "ISO 27001", + "GDPR" + ] + } +} diff --git a/models/examples/flavor-types/vm.json b/models/examples/flavor-types/vm.json new file mode 100644 index 0000000..53c8b23 --- /dev/null +++ b/models/examples/flavor-types/vm.json @@ -0,0 +1,30 @@ +{ + "Characteristics": { + "Architecture": "x86_64", + "OS": "Ubuntu 20.04", + "CPU": 4, + "Memory": 8192, + "GPU": { + "GPUModel": "NVIDIA RTX 3080", + "GPUCores": 10 + }, + "Storage": 100 + }, + "Properties": { + "Latency": 30, + "SecurityStandards": [ + "GDPR", + "ISO 27001" + ], + "CarbonFootprint": { + "Embodied": 1500, + "Operational": [] + } + }, + "Policy": { + "Aggregatable": { + "MinCount": 1, + "MaxCount": 10 + } + } +} diff --git a/models/examples/flavor.json b/models/examples/flavor.json new file mode 100644 index 0000000..c8bf025 --- /dev/null +++ b/models/examples/flavor.json @@ -0,0 +1,33 @@ +{ + "flavorId": "flavor-123", + "providerId": "provider-456", + "timestamp": "2024-07-15T12:00:00Z", + "location": { + "latitude": "37.7749", + "longitude": "-122.4194", + "country": "USA", + "city": "San Francisco", + "additionalNotes": "Near the waterfront" + }, + "networkPropertyType": "5G", + "type": { + "name": "k8slice", + "data": { + "$ref": "flavor-types/k8slice.json" + } + }, + "price": { + "amount": "100", + "currency": "USD", + "period": "monthly" + }, + "owner": { + "domain": "example.com", + "nodeId": "node-789", + "ip": "192.168.1.1", + "additionalInformation": { + "LiqoID": "liqo-001" + } + }, + "availability": true +} diff --git a/models/examples/generate_puml.sh b/models/examples/generate_puml.sh deleted file mode 100755 index 8349243..0000000 --- a/models/examples/generate_puml.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Generate PlantUML diagram from schema files -# Usage: ./generate_puml.sh - -# Open json schema files and generate PlantUML diagram - -# Flavor schema -echo "@startjson" > puml/flavor.txt -cat json/flavor.json >> puml/flavor.txt -echo "" >> puml/flavor.txt -echo "@endjson" >> puml/flavor.txt - -for filename in $(ls json/flavor-types); do - if test -f "json/flavor-types/$filename"; then - new_filename=$(echo $filename | sed 's/.json//') - echo "@startjson" > puml/flavor-types/$new_filename.txt - cat json/flavor-types/$filename >> puml/flavor-types/$new_filename.txt - echo "" >> puml/flavor-types/$new_filename.txt - echo "@endjson" >> puml/flavor-types/$new_filename.txt - fi -done \ No newline at end of file diff --git a/models/examples/json/flavor-types/k8slice.json b/models/examples/json/flavor-types/k8slice.json deleted file mode 100644 index 33e3686..0000000 --- a/models/examples/json/flavor-types/k8slice.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "Characteristics": { - "CPU": 4, - "Pods": 10, - "Memory": 16384, - "GPU": { - "GPUModel": "Tesla T4", - "GPUCores": 8 - }, - "Storage": 512 - }, - "Properties": { - "Latency": 20, - "SecurityStandards": ["GDPR"], - "CarbonFootprint": { - "Embodied": 200, - "Operational": [ - 150, - 123 - ] - } - }, - "Policy": { - "Aggregatable": { - "MinCount": 1, - "MaxCount": 5 - }, - "Partitionable": { - "CpuMin": 2, - "MemoryMin": 8192, - "CpuStep": 2, - "MemoryStep": 4096 - } - } -} diff --git a/models/examples/json/flavor-types/sensor.json b/models/examples/json/flavor-types/sensor.json deleted file mode 100644 index db59747..0000000 --- a/models/examples/json/flavor-types/sensor.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "Characteristics": { - "SensorType": "Temperature", - "SensorModel": "ABC123", - "SensorManufacturer": "XYZ Company", - "SensorMarket": "Industrial", - "SamplingRate": 1000, - "Accuracy": 95, - "Consumption": 50, - "SecurityStandards": [ - "GDPR" - ], - "Latency": 20, - "additionalProperties": { - "MeasurementUnit": "Celsius", - "ConsumptionUnit": "mW", - "SamplingRateUnit": "milliseconds" - } - }, - "AccessType": { - "HTTP": { - "method": [ - "GET", - "POST" - ] - } - } -} \ No newline at end of file diff --git a/models/examples/json/flavor-types/service-types/db.json b/models/examples/json/flavor-types/service-types/db.json deleted file mode 100644 index 7d4416b..0000000 --- a/models/examples/json/flavor-types/service-types/db.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "DBService": { - "Characteristics": { - "NumberOfDatabases": 20, - "TransactionsPerSecond": 20000, - "HighAvailability": { - "Available": true, - "NumberOfReplicas": 3 - } - } - } - } \ No newline at end of file diff --git a/models/examples/json/flavor-types/service.json b/models/examples/json/flavor-types/service.json deleted file mode 100644 index 6b2443d..0000000 --- a/models/examples/json/flavor-types/service.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Characteristics": { - "Name": "My High Performance Database", - "Description": "A high performance database service with low latency.", - "Tags": [ - "high-performance", - "database" - ], - "Plan": "Enterprise", - "Latency": 10 - }, - "ServiceType": { - "$ref": "*" - } -} \ No newline at end of file diff --git a/models/examples/json/flavor-types/vm.json b/models/examples/json/flavor-types/vm.json deleted file mode 100644 index f871f9f..0000000 --- a/models/examples/json/flavor-types/vm.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "Characteristics": { - "Architecture": "x86_64", - "OS": "Ubuntu 22.04", - "CPU": 2, - "Memory": 8192, - "GPU": { - "GPUModel": "None", - "GPUCores": 0 - }, - "Storage": 128 - }, - "Properties": { - "Latency": 30, - "SecurityStandards": ["GDPR"], - "CarbonFootprint": { - "Embodied": 150, - "Operational": [ - 200, - 123 - ] - } - }, - "Policy": { - "Aggregatable": { - "MinCount": 1, - "MaxCount": 10 - } - } -} diff --git a/models/examples/json/flavor.json b/models/examples/json/flavor.json deleted file mode 100644 index 4308b3f..0000000 --- a/models/examples/json/flavor.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "FlavorID": "unique-flavor-id-123", - "ProviderID": "provider-id-456", - "Timestamp": "2024-03-27T11:47:00Z", - "Location": { - "Latitude": "40.7128", - "Longitude": "-74.0059", - "Altitude": "100", - "AdditionalNotes": "Located on rooftop with good ventilation" - }, - "NetworkPropertyType": "5G", - "FlavorType": { - "$ref": "*" - }, - "Price": { - "Amount": "10.00", - "Currency": "USD", - "Period": "Hourly" - }, - "Owner": { - "Domain": "example.com", - "NodeID": "node-id-789", - "IP": "192.168.1.10", - "AdditionalInformation": { - "LiqoID": "liqo-id-001" - } - }, - "OptionalFields": { - "Availability": true, - "WorkerID": "worker-id-xyz" - }, - "AdditionalInfo": "available-now: true" -} \ No newline at end of file diff --git a/models/examples/node-identity.json b/models/examples/node-identity.json new file mode 100644 index 0000000..06670dc --- /dev/null +++ b/models/examples/node-identity.json @@ -0,0 +1,8 @@ +{ + "Domain": "example.com", + "NodeID": "node-123", + "IP": "192.168.1.10", + "AdditionalInformation": { + "LiqoID": "liqo-abc" + } +} \ No newline at end of file diff --git a/models/examples/puml/flavor-types/k8slice.txt b/models/examples/puml/flavor-types/k8slice.txt deleted file mode 100644 index a2a36ce..0000000 --- a/models/examples/puml/flavor-types/k8slice.txt +++ /dev/null @@ -1,38 +0,0 @@ -@startjson -{ - "Characteristics": { - "CPU": 4, - "Pods": 10, - "Memory": 16384, - "GPU": { - "GPUModel": "Tesla T4", - "GPUCores": 8 - }, - "Storage": 512 - }, - "Properties": { - "Latency": 20, - "SecurityStandards": ["GDPR"], - "CarbonFootprint": { - "Embodied": 200, - "Operational": [ - 150, - 123 - ] - } - }, - "Policy": { - "Aggregatable": { - "MinCount": 1, - "MaxCount": 5 - }, - "Partitionable": { - "CpuMin": 2, - "MemoryMin": 8192, - "CpuStep": 2, - "MemoryStep": 4096 - } - } -} - -@endjson diff --git a/models/examples/puml/flavor-types/sensor.txt b/models/examples/puml/flavor-types/sensor.txt deleted file mode 100644 index 8cb9f88..0000000 --- a/models/examples/puml/flavor-types/sensor.txt +++ /dev/null @@ -1,30 +0,0 @@ -@startjson -{ - "Characteristics": { - "SensorType": "Temperature", - "SensorModel": "ABC123", - "SensorManufacturer": "XYZ Company", - "SensorMarket": "Industrial", - "SamplingRate": 1000, - "Accuracy": 95, - "Consumption": 50, - "SecurityStandards": [ - "GDPR" - ], - "Latency": 20, - "additionalProperties": { - "MeasurementUnit": "Celsius", - "ConsumptionUnit": "mW", - "SamplingRateUnit": "milliseconds" - } - }, - "AccessType": { - "HTTP": { - "method": [ - "GET", - "POST" - ] - } - } -} -@endjson diff --git a/models/examples/puml/flavor-types/service.txt b/models/examples/puml/flavor-types/service.txt deleted file mode 100644 index 90d0580..0000000 --- a/models/examples/puml/flavor-types/service.txt +++ /dev/null @@ -1,17 +0,0 @@ -@startjson -{ - "Characteristics": { - "Name": "My High Performance Database", - "Description": "A high performance database service with low latency.", - "Tags": [ - "high-performance", - "database" - ], - "Plan": "Enterprise", - "Latency": 10 - }, - "ServiceType": { - "$ref": "*" - } -} -@endjson diff --git a/models/examples/puml/flavor-types/vm.txt b/models/examples/puml/flavor-types/vm.txt deleted file mode 100644 index 21d5dea..0000000 --- a/models/examples/puml/flavor-types/vm.txt +++ /dev/null @@ -1,33 +0,0 @@ -@startjson -{ - "Characteristics": { - "Architecture": "x86_64", - "OS": "Ubuntu 22.04", - "CPU": 2, - "Memory": 8192, - "GPU": { - "GPUModel": "None", - "GPUCores": 0 - }, - "Storage": 128 - }, - "Properties": { - "Latency": 30, - "SecurityStandards": ["GDPR"], - "CarbonFootprint": { - "Embodied": 150, - "Operational": [ - 200, - 123 - ] - } - }, - "Policy": { - "Aggregatable": { - "MinCount": 1, - "MaxCount": 10 - } - } -} - -@endjson diff --git a/models/examples/puml/flavor.txt b/models/examples/puml/flavor.txt deleted file mode 100644 index e88cf37..0000000 --- a/models/examples/puml/flavor.txt +++ /dev/null @@ -1,35 +0,0 @@ -@startjson -{ - "FlavorID": "unique-flavor-id-123", - "ProviderID": "provider-id-456", - "Timestamp": "2024-03-27T11:47:00Z", - "Location": { - "Latitude": "40.7128", - "Longitude": "-74.0059", - "Altitude": "100", - "AdditionalNotes": "Located on rooftop with good ventilation" - }, - "NetworkPropertyType": "5G", - "FlavorType": { - "$ref": "*" - }, - "Price": { - "Amount": "10.00", - "Currency": "USD", - "Period": "Hourly" - }, - "Owner": { - "Domain": "example.com", - "NodeID": "node-id-789", - "IP": "192.168.1.10", - "AdditionalInformation": { - "LiqoID": "liqo-id-001" - } - }, - "OptionalFields": { - "Availability": true, - "WorkerID": "worker-id-xyz" - }, - "AdditionalInfo": "available-now: true" -} -@endjson diff --git a/models/examples/purchase-request.json b/models/examples/purchase-request.json new file mode 100644 index 0000000..274eb19 --- /dev/null +++ b/models/examples/purchase-request.json @@ -0,0 +1,5 @@ +{ + "LiqoCredentials": { + "$ref": "credentials/liqo-credentials.schema.json" + } +} \ No newline at end of file diff --git a/models/examples/reservation.json b/models/examples/reservation.json new file mode 100644 index 0000000..2832426 --- /dev/null +++ b/models/examples/reservation.json @@ -0,0 +1,9 @@ +{ + "FlavorID": "flavor-789", + "Buyer": { + "$ref": "node-identity.schema.json" + }, + "Configuration": { + "$ref": "configuration.schema.json" + } +} diff --git a/models/examples/svg/flavor-types/k8slice.svg b/models/examples/svg/flavor-types/k8slice.svg deleted file mode 100644 index 050dbe2..0000000 --- a/models/examples/svg/flavor-types/k8slice.svg +++ /dev/null @@ -1 +0,0 @@ -Characteristics   Properties   Policy   CPU4Pods10Memory16384GPU   Storage512GPUModelTesla T4GPUCores8Latency20SecurityStandards   CarbonFootprint   GDPREmbodied200Operational   150123Aggregatable   Partitionable   MinCount1MaxCount5CpuMin2MemoryMin8192CpuStep2MemoryStep4096 \ No newline at end of file diff --git a/models/examples/svg/flavor-types/sensor.svg b/models/examples/svg/flavor-types/sensor.svg deleted file mode 100644 index 40c6bcb..0000000 --- a/models/examples/svg/flavor-types/sensor.svg +++ /dev/null @@ -1 +0,0 @@ -Characteristics   AccessType   SensorTypeTemperatureSensorModelABC123SensorManufacturerXYZ CompanySensorMarketIndustrialSamplingRate1000Accuracy95Consumption50SecurityStandards   Latency20additionalProperties   GDPRMeasurementUnitCelsiusConsumptionUnitmWSamplingRateUnitmillisecondsHTTP   method   GETPOST \ No newline at end of file diff --git a/models/examples/svg/flavor-types/service.svg b/models/examples/svg/flavor-types/service.svg deleted file mode 100644 index 4be2f84..0000000 --- a/models/examples/svg/flavor-types/service.svg +++ /dev/null @@ -1 +0,0 @@ -Characteristics   ServiceType   NameMy High Performance DatabaseDescriptionA high performance database service with low latency.Tags   PlanEnterpriseLatency10high-performancedatabase$ref* \ No newline at end of file diff --git a/models/examples/svg/flavor-types/vm.svg b/models/examples/svg/flavor-types/vm.svg deleted file mode 100644 index b390e34..0000000 --- a/models/examples/svg/flavor-types/vm.svg +++ /dev/null @@ -1 +0,0 @@ -Characteristics   Properties   Policy   Architecturex86_64OSUbuntu 22.04CPU2Memory8192GPU   Storage128GPUModelNoneGPUCores0Latency30SecurityStandards   CarbonFootprint   GDPREmbodied150Operational   200123Aggregatable   MinCount1MaxCount10 \ No newline at end of file diff --git a/models/examples/svg/flavor.svg b/models/examples/svg/flavor.svg deleted file mode 100644 index aa811fd..0000000 --- a/models/examples/svg/flavor.svg +++ /dev/null @@ -1 +0,0 @@ -FlavorIDunique-flavor-id-123ProviderIDprovider-id-456Timestamp2024-03-27T11:47:00ZLocation   NetworkPropertyType5GFlavorType   Price   Owner   OptionalFields   AdditionalInfoavailable-now: trueLatitude40.7128Longitude-74.0059Altitude100AdditionalNotesLocated on rooftop with good ventilation$ref*Amount10.00CurrencyUSDPeriodHourlyDomainexample.comNodeIDnode-id-789IP192.168.1.10AdditionalInformation   LiqoIDliqo-id-001Availability☑ trueWorkerIDworker-id-xyz \ No newline at end of file diff --git a/models/examples/transaction.json b/models/examples/transaction.json new file mode 100644 index 0000000..241ad2d --- /dev/null +++ b/models/examples/transaction.json @@ -0,0 +1,8 @@ +{ + "TransactionID": "txn-001", + "FlavorID": "flavor-789", + "Buyer": { + "$ref": "node-identity.schema.json" + }, + "ExpirationTime": "2024-12-31T23:59:59Z" +} \ No newline at end of file diff --git a/models/generate_svg.py b/models/generate_svg.py deleted file mode 100644 index e30722e..0000000 --- a/models/generate_svg.py +++ /dev/null @@ -1,21 +0,0 @@ -import sys -import requests - -def write_text(data: str, path: str): - with open(path, 'w') as file: - file.write(data) - -def generate_schema_svg(dir, branch_name): - out_dir = dir + "/svg" - - filenames = ["flavor.txt", "flavor-types/k8slice.txt", "flavor-types/service.txt", "flavor-types/vm.txt", "flavor-types/sensor.txt"] - - for f in filenames: - response = requests.get(f"https://plantuml.com/plantuml/proxy?src=https://raw.githubusercontent.com/fluidos-project/REAR-data-models/{branch_name}/models/{dir}/puml/{f}&fmt=svg") - write_text(response.text, f"{out_dir}/{f.replace('.txt', '.svg')}") - -# get first CLI param -branch = sys.argv[1] - -generate_schema_svg("schemas", branch) -generate_schema_svg("examples", branch) diff --git a/models/schemas/README.md b/models/schemas/README.md deleted file mode 100644 index cc7ec67..0000000 --- a/models/schemas/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Flavor - -![flavor](svg/flavor.svg) - -# FlavorType - -## K8Slice - -![K8slice](svg/flavor-types/k8slice.svg) - -## vm - -![vm](svg/flavor-types/vm.svg) - -## Sensor - -![sensor](svg/flavor-types/sensor.svg) - -## Service - -![service](svg/flavor-types/service.svg) \ No newline at end of file diff --git a/models/schemas/configuration-types/k8slice-configuration.schema.json b/models/schemas/configuration-types/k8slice-configuration.schema.json new file mode 100644 index 0000000..7f905e6 --- /dev/null +++ b/models/schemas/configuration-types/k8slice-configuration.schema.json @@ -0,0 +1,53 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "K8SliceConfiguration", + "properties": { + "cpu": { + "type": "string", + "description": "The number of CPU cores", + "pattern": "^[0-9]+(m|([.][0-9]+)?|[kMGTP]i?)?$" + }, + "pods": { + "type": "string", + "description": "The number of pods", + "pattern": "^[0-9]+$" + }, + "memory": { + "type": "string", + "description": "The amount of memory", + "pattern": "^[0-9]+(Ki|Mi|Gi|Ti|Pi|Ei|k|M|G|T|P|E)?$" + }, + "gpu": { + "type": "object", + "description": "GPU characteristics of the Flavor.", + "properties": { + "model" : { + "type": "string", + "description": "The model of the GPU offered for the specific Flavor." + }, + "cores": { + "type": "string", + "description": "The number of GPU cores advertised by the Flavor.", + "pattern": "^[0-9]+(m|([.][0-9]+)?|[kMGTP]i?)?$" + }, + "memory": { + "type": "string", + "description": "The amount of GPU memory advertised by the Flavor.", + "pattern": "^[0-9]+(Ki|Mi|Gi|Ti|Pi|Ei|k|M|G|T|P|E)?$" + } + } + }, + "storage": { + "type": "string", + "description": "The amount of storage", + "pattern": "^[0-9]+(Ki|Mi|Gi|Ti|Pi|Ei|k|M|G|T|P|E)?$" + } + }, + "required": [ + "cpu", + "pods", + "memory" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/models/schemas/configuration.schema.json b/models/schemas/configuration.schema.json new file mode 100644 index 0000000..e618547 --- /dev/null +++ b/models/schemas/configuration.schema.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "configuration", + "properties": { + "type": { + "type": "string", + "title": "Type", + "description": "The type of the configuration", + "enum": [ + "k8slice", + "vm", + "service", + "sensor" + ] + }, + "data": { + "type": "object", + "title": "Data", + "description": "The configuration data", + "oneOf": [ + { + "$ref": "./configurationTypes/k8slice-configuration.schema.json" + } + ] + } + }, + "required": [ + "type", + "data" + ], + "additionalProperties": false +} diff --git a/models/schemas/contract.schema.json b/models/schemas/contract.schema.json new file mode 100644 index 0000000..50fe562 --- /dev/null +++ b/models/schemas/contract.schema.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "Contract", + "properties": { + "ContractID": { + "type": "string", + "description": "The contract ID" + }, + "Flavor": { + "$ref": "./flavor.schema.json", + "description": "The flavor of the contract" + }, + "Buyer": { + "$ref": "node-identity.schema.json", + "description": "The buyer of the contract" + }, + "Seller": { + "$ref": "node-identity.schema.json", + "description": "The seller of the contract" + }, + "ExpirationTime": { + "type": "string", + "format": "date-time", + "description": "The expiration time of the contract" + }, + "Credentials": { + "$ref": "credentials/liqo-credentials.schema.json" + } + } +} \ No newline at end of file diff --git a/models/schemas/credentials/liqo-credentials.schema.json b/models/schemas/credentials/liqo-credentials.schema.json new file mode 100644 index 0000000..fb486ec --- /dev/null +++ b/models/schemas/credentials/liqo-credentials.schema.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "Liqo Credentials", + "description": "Liqo credentials to be used for the peering", + "properties": { + "clusterID": { + "type": "string", + "description": "The unique identifier of the cluster" + }, + "clusterName": { + "type": "string", + "description": "The name of the cluster" + }, + "endpoint": { + "type": "string", + "description": "The endpoint of the cluster" + }, + "token": { + "type": "string", + "description": "The token to be used for the peering" + } + } +} \ No newline at end of file diff --git a/models/schemas/flavor-types/k8slice.json b/models/schemas/flavor-types/k8slice.json deleted file mode 100644 index bebbdc7..0000000 --- a/models/schemas/flavor-types/k8slice.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "title": "K8Slice", - "description": "Kubernetes Flavor Type", - "properties": { - "Characteristics": { - "type": "object", - "properties": { - "CPU": { - "type": "integer", - "description": "The number of CPU cores" - }, - "Pods": { - "type": "integer", - "description": "The number of pods" - }, - "Memory": { - "type": "integer", - "description": "The amount of memory" - }, - "GPU": { - "type": "object", - "description": "GPU characteristics of the Flavor.", - "properties": { - "GPUModel" : { - "type": "string", - "description": "The model of the GPU offered for the specific Flavor." - }, - "GPUCores": { - "type": "integer", - "description": "The number of GPU cores advertised by the Flavor." - } - } - }, - "Storage": { - "type": "integer", - "description": "The amount of storage" - } - } - }, - "Properties": { - "type": "object", - "properties": { - "Latency": { - "type": "integer", - "description": "The latency of the Flavor." - }, - "SecurityStandards": { - "type": "array", - "description": "Security standards supported by the Flavor (e.g., GDPR).", - "items": { - "type": "string" - } - }, - "CarbonFootprint": { - "type": "object", - "properties": { - "Embodied": { - "type": "integer", - "description": "Embodied carbon of the node hardware normalized by its expected lifetime." - }, - "Operational": { - "type": "array", - "description": "Forecasted average carbon intensity of the node for the next N windows/hours." - } - } - } - } - }, - "Policy": { - "type": "object", - "properties": { - "Aggregatable": { - "type": "object", - "properties": { - "MinCount": { - "type": "integer", - "description": "Minimum required number of instances of the Flavor." - }, - "MaxCount": { - "type": "integer", - "description": "Maximum required number of instances of the Flavor." - } - } - }, - "Partitionable": { - "type": "object", - "properties": { - "CpuMin": { - "type": "integer", - "description": "Minimum required number of CPU cores of the Flavor." - }, - "MemoryMin": { - "type": "integer", - "description": "Minimum required amount of RAM of the Flavor." - }, - "CpuStep": { - "type": "integer", - "description": "Incremental value of CPU cores of the Flavor." - }, - "MemoryStep": { - "type": "integer", - "description": "Incremental value of RAM of the Flavor." - } - } - } - } - } - } -} \ No newline at end of file diff --git a/models/schemas/flavor-types/k8slice.schema.json b/models/schemas/flavor-types/k8slice.schema.json new file mode 100644 index 0000000..978f5e5 --- /dev/null +++ b/models/schemas/flavor-types/k8slice.schema.json @@ -0,0 +1,126 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "K8Slice", + "description": "Kubernetes Flavor Type", + "properties": { + "characteristics": { + "type": "object", + "properties": { + "cpu": { + "type": "string", + "description": "The number of CPU cores", + "pattern": "^[0-9]+(m|([.][0-9]+)?|[kMGTP]i?)?$" + }, + "pods": { + "type": "string", + "description": "The number of pods", + "pattern": "^[0-9]+$" + }, + "memory": { + "type": "string", + "description": "The amount of memory", + "pattern": "^[0-9]+(Ki|Mi|Gi|Ti|Pi|Ei|k|M|G|T|P|E)?$" + }, + "gpu": { + "type": "object", + "description": "GPU characteristics of the Flavor.", + "properties": { + "model" : { + "type": "string", + "description": "The model of the GPU offered for the specific Flavor." + }, + "cores": { + "type": "string", + "description": "The number of GPU cores advertised by the Flavor.", + "pattern": "^[0-9]+(m|([.][0-9]+)?|[kMGTP]i?)?$" + }, + "memory": { + "type": "string", + "description": "The amount of GPU memory advertised by the Flavor.", + "pattern": "^[0-9]+(Ki|Mi|Gi|Ti|Pi|Ei|k|M|G|T|P|E)?$" + } + } + }, + "storage": { + "type": "string", + "description": "The amount of storage", + "pattern": "^[0-9]+(Ki|Mi|Gi|Ti|Pi|Ei|k|M|G|T|P|E)?$" + } + }, + "required": ["cpu", "pods", "memory"], + "additionalProperties": false + }, + "properties": { + "type": "object", + "properties": { + "latency": { + "type": "integer", + "description": "The latency of the Flavor in milliseconds." + }, + "securityStandards": { + "type": "array", + "description": "Security standards supported by the Flavor (e.g., GDPR).", + "items": { + "type": "string" + } + }, + "carbonFootprint": { + "type": "object", + "properties": { + "embodied": { + "type": "integer", + "description": "Embodied carbon of the node hardware normalized by its expected lifetime." + }, + "operational": { + "type": "array", + "description": "Forecasted average carbon intensity of the node for the next N windows/hours." + } + } + } + } + }, + "policies": { + "type": "object", + "properties": { + "partitionability": { + "type": "object", + "properties": { + "cpuMin": { + "type": "string", + "description": "Minimum required number of CPU cores of the Flavor for the eventual partition.", + "pattern": "^[0-9]+(m|([.][0-9]+)?|[kMGTP]i?)?$" + }, + "memoryMin": { + "type": "string", + "description": "Minimum required amount of RAM of the Flavor for the eventual partition.", + "pattern": "^[0-9]+(Ki|Mi|Gi|Ti|Pi|Ei|k|M|G|T|P|E)?$" + }, + "podsMin": { + "type": "string", + "description": "Minimum required number of pods of the Flavor for the eventual partition.", + "pattern": "^[0-9]+$" + }, + "cpuStep": { + "type": "string", + "description": "Incremental value of CPU cores of the Flavor for the eventual partition.", + "pattern": "^[0-9]+(m|([.][0-9]+)?|[kMGTP]i?)?$" + }, + "memoryStep": { + "type": "string", + "description": "Incremental value of RAM of the Flavor for the eventual partition.", + "pattern": "^[0-9]+(Ki|Mi|Gi|Ti|Pi|Ei|k|M|G|T|P|E)?$" + }, + "podsStep": { + "type": "string", + "description": "Incremental value of pods of the Flavor for the eventual partition.", + "pattern": "^[0-9]+$" + } + } + } + } + } + }, + "required": ["name", "characteristics", "properties", "policies"], + "additionalProperties": false +} \ No newline at end of file diff --git a/models/schemas/flavor-types/sensor.json b/models/schemas/flavor-types/sensor.schema.json similarity index 100% rename from models/schemas/flavor-types/sensor.json rename to models/schemas/flavor-types/sensor.schema.json diff --git a/models/schemas/flavor-types/service-types/db.json b/models/schemas/flavor-types/service-types/db.json deleted file mode 100644 index 8cbb431..0000000 --- a/models/schemas/flavor-types/service-types/db.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "title": "DBService", - "description": "DB Service Type", - "properties": { - "Characteristics": { - "type": "object", - "properties": { - "NumberOfDatabases": { - "type": "integer", - "description": "The number of databases that can be created" - }, - "TransactionsPerSecond": { - "type": "integer", - "description": "The guaranteed number of transactions per second." - }, - "HighAvailability": { - "type": "object", - "description": "Description of the HA property.", - "properties": { - "Available": { - "type": "boolean", - "description": "Describe if the HA property is guaranteed" - }, - "NumberOfReplicas": { - "type": "integer", - "description": "The number of replicas for the HA database" - } - } - } - } - } - } -} \ No newline at end of file diff --git a/models/schemas/flavor-types/service.json b/models/schemas/flavor-types/service.schema.json similarity index 83% rename from models/schemas/flavor-types/service.json rename to models/schemas/flavor-types/service.schema.json index 6c87654..eeb98f7 100644 --- a/models/schemas/flavor-types/service.json +++ b/models/schemas/flavor-types/service.schema.json @@ -38,14 +38,6 @@ } } } - }, - "ServiceType": { - "description": "ServiceType to describe the specific characteristics of the advertised flavor.", - "oneOf": [ - { - "$ref": "service-types/db.json" - } - ] } } } \ No newline at end of file diff --git a/models/schemas/flavor-types/vm.json b/models/schemas/flavor-types/vm.schema.json similarity index 100% rename from models/schemas/flavor-types/vm.json rename to models/schemas/flavor-types/vm.schema.json diff --git a/models/schemas/flavor.json b/models/schemas/flavor.json deleted file mode 100644 index 670074d..0000000 --- a/models/schemas/flavor.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Flavor", - "type": "object", - "properties": { - "FlavorID": { - "type": "string", - "description": "The unique identifier for a flavor" - }, - "ProviderID": { - "type": "string", - "description": "The unique identifier for a provider" - }, - "Timestamp": { - "type": "string", - "description": "Timestamp of the provided Flavor offer. It allows to advertise Flavors in the (near) future" - }, - "Location": { - "type": "object", - "properties": { - "Latitude": { - "type": "string", - "description": "Latitude of the location" - }, - "Longitude": { - "type": "string", - "description": "Longitude of the location" - }, - "Altitude": { - "type": "string", - "description": "Altitude of the location expressed in meters" - }, - "AdditionalNotes": { - "type": "string", - "description": "Additional notes about the location" - } - } - }, - "NetworkPropertyType": { - "type": "string", - "description": "Type of network property ensured by the privider (e.g., 5G, Wifi, Ethernet)" - }, - "FlavorType": { - "description": "A reference to a specific flavor type schema using JSON references ($ref) to external files like 'k8slice.json', 'vm.json', etc. This allows defining details specific to each flavor type.", - "oneOf": [ - { - "$ref": "flavor-types/k8slice.json" - }, - { - "$ref": "flavor-types/vm.json" - }, - { - "$ref": "flavor-types/service.json" - }, - { - "$ref": "flavor-types/sensor.json" - } - ] - }, - "Price": { - "type": "object", - "properties": { - "Amount": { - "type": "string", - "description": "Amount of the price." - }, - "Currency": { - "type": "string", - "description": "Currency of the price." - }, - "Period": { - "type": "string", - "description": "Period of the price." - } - } - }, - "Owner": { - "type": "object", - "properties": { - "Domain": { - "type": "string", - "description": "Domain of the node." - }, - "NodeID": { - "type": "string", - "description": "ID of the node." - }, - "IP": { - "type": "string", - "description": "IP of the node." - }, - "AdditionalInformation": { - "type": "object", - "description": "Additional information about the node.", - "properties": { - "LiqoID": { - "type": "string", - "description": "Liqo ID of the node." - } - } - } - } - }, - "OptionalFields": { - "type": "object", - "properties": { - "Availability": { - "type": "boolean", - "description": "Availability flag of the Flavor." - }, - "WorkerID": { - "type": "string", - "description": "ID of the worker that provides the Flavor." - } - } - }, - "AdditionalInfo": { - "type": "string", - "description": "Additional information to enrich the Flavor description using a key: value representation." - } - } -} \ No newline at end of file diff --git a/models/schemas/flavor.schema.json b/models/schemas/flavor.schema.json new file mode 100644 index 0000000..99bfb5d --- /dev/null +++ b/models/schemas/flavor.schema.json @@ -0,0 +1,140 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Flavor", + "type": "object", + "properties": { + "flavorId": { + "type": "string", + "description": "The unique identifier for a flavor" + }, + "providerId": { + "type": "string", + "description": "The unique identifier for a provider" + }, + "timestamp": { + "type": "string", + "description": "Timestamp of the provided Flavor offer. It allows to advertise Flavors in the (near) future" + }, + "location": { + "type": "object", + "description": "Location of the Flavor", + "properties": { + "latitude": { + "type": "string", + "description": "Latitude of the location" + }, + "longitude": { + "type": "string", + "description": "Longitude of the location" + }, + "country": { + "type": "string", + "description": "Country of the location" + }, + "city": { + "type": "string", + "description": "City of the location" + }, + "additionalNotes": { + "type": "string", + "description": "Additional notes about the location" + } + }, + "additionalProperties": false + }, + "networkPropertyType": { + "type": "string", + "description": "Type of network property ensured by the provider (e.g., 5G, Wifi, Ethernet)" + }, + "type": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The name of the type of the Flavor.", + "enum": [ + "k8slice", + "vm", + "service", + "sensor" + ] + }, + "data": { + "type": "object", + "description": "A reference to a specific flavor type schema using JSON references ($ref) to external files like 'k8slice.json', 'vm.json', etc. This allows defining details specific to each flavor type.", + "oneOf": [ + { + "$ref": "flavor-types/k8slice.json" + }, + { + "$ref": "flavor-types/vm.json" + }, + { + "$ref": "flavor-types/service.json" + }, + { + "$ref": "flavor-types/sensor.json" + } + ] + } + } + }, + "price": { + "type": "object", + "description": "Price of the Flavor.", + "properties": { + "amount": { + "type": "string", + "description": "Amount of the price." + }, + "currency": { + "type": "string", + "description": "Currency of the price." + }, + "period": { + "type": "string", + "description": "Period of the price." + } + }, + "required": ["amount", "currency", "period"], + "additionalProperties": false + }, + "owner": { + "type": "object", + "description": "Owner of the Flavor.", + "properties": { + "domain": { + "type": "string", + "description": "Domain of the node." + }, + "nodeId": { + "type": "string", + "description": "ID of the node." + }, + "ip": { + "type": "string", + "description": "IP of the node." + }, + "additionalInformation": { + "type": "object", + "description": "Additional information about the node.", + "properties": { + "LiqoID": { + "type": "string", + "description": "Liqo ID of the node." + } + }, + "additionalProperties": true + } + }, + "required": ["domain", "nodeId", "ip"], + "additionalProperties": false + }, + "availability": { + "type": "boolean", + "description": "Availability flag of the Flavor." + } + }, + "required": ["flavorId", "providerId", "timestamp", "type", "price", "owner", "availability"], + "additionalProperties": false +} \ No newline at end of file diff --git a/models/schemas/generate_puml.sh b/models/schemas/generate_puml.sh deleted file mode 100755 index 35a0a64..0000000 --- a/models/schemas/generate_puml.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Generate PlantUML diagram from schema files -# Usage: ./generate_puml.sh - -# Open json schema files and generate PlantUML diagram - -# Flavor schema -echo "@startjson" > puml/flavor.txt -cat flavor.json >> puml/flavor.txt -echo "" >> puml/flavor.txt -echo "@endjson" >> puml/flavor.txt - -for filename in $(ls flavor-types); do - if test -f "flavor-types/$filename"; then - new_filename=$(echo $filename | sed 's/.json//') - echo "@startjson" > puml/flavor-types/$new_filename.txt - cat flavor-types/$filename >> puml/flavor-types/$new_filename.txt - echo "" >> puml/flavor-types/$new_filename.txt - echo "@endjson" >> puml/flavor-types/$new_filename.txt - fi -done \ No newline at end of file diff --git a/models/schemas/node-identity.schema.json b/models/schemas/node-identity.schema.json new file mode 100644 index 0000000..b58d75c --- /dev/null +++ b/models/schemas/node-identity.schema.json @@ -0,0 +1,35 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "NodeIdentity", + "properties": { + "Domain": { + "type": "string", + "description": "Domain of the node." + }, + "NodeID": { + "type": "string", + "description": "ID of the node." + }, + "IP": { + "type": "string", + "description": "IP of the node." + }, + "AdditionalInformation": { + "type": "object", + "description": "Additional information about the node.", + "properties": { + "LiqoID": { + "type": "string", + "description": "Liqo ID of the node." + } + } + } + }, + "required": [ + "Domain", + "NodeID", + "IP" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/models/schemas/puml/flavor-types/k8slice.txt b/models/schemas/puml/flavor-types/k8slice.txt deleted file mode 100644 index 7b2d946..0000000 --- a/models/schemas/puml/flavor-types/k8slice.txt +++ /dev/null @@ -1,113 +0,0 @@ -@startjson -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "title": "K8Slice", - "description": "Kubernetes Flavor Type", - "properties": { - "Characteristics": { - "type": "object", - "properties": { - "CPU": { - "type": "integer", - "description": "The number of CPU cores" - }, - "Pods": { - "type": "integer", - "description": "The number of pods" - }, - "Memory": { - "type": "integer", - "description": "The amount of memory" - }, - "GPU": { - "type": "object", - "description": "GPU characteristics of the Flavor.", - "properties": { - "GPUModel" : { - "type": "string", - "description": "The model of the GPU offered for the specific Flavor." - }, - "GPUCores": { - "type": "integer", - "description": "The number of GPU cores advertised by the Flavor." - } - } - }, - "Storage": { - "type": "integer", - "description": "The amount of storage" - } - } - }, - "Properties": { - "type": "object", - "properties": { - "Latency": { - "type": "integer", - "description": "The latency of the Flavor." - }, - "SecurityStandards": { - "type": "array", - "description": "Security standards supported by the Flavor (e.g., GDPR).", - "items": { - "type": "string" - } - }, - "CarbonFootprint": { - "type": "object", - "properties": { - "Embodied": { - "type": "integer", - "description": "Embodied carbon of the node hardware normalized by its expected lifetime." - }, - "Operational": { - "type": "array", - "description": "Forecasted average carbon intensity of the node for the next N windows/hours." - } - } - } - } - }, - "Policy": { - "type": "object", - "properties": { - "Aggregatable": { - "type": "object", - "properties": { - "MinCount": { - "type": "integer", - "description": "Minimum required number of instances of the Flavor." - }, - "MaxCount": { - "type": "integer", - "description": "Maximum required number of instances of the Flavor." - } - } - }, - "Partitionable": { - "type": "object", - "properties": { - "CpuMin": { - "type": "integer", - "description": "Minimum required number of CPU cores of the Flavor." - }, - "MemoryMin": { - "type": "integer", - "description": "Minimum required amount of RAM of the Flavor." - }, - "CpuStep": { - "type": "integer", - "description": "Incremental value of CPU cores of the Flavor." - }, - "MemoryStep": { - "type": "integer", - "description": "Incremental value of RAM of the Flavor." - } - } - } - } - } - } -} -@endjson diff --git a/models/schemas/puml/flavor-types/sensor.txt b/models/schemas/puml/flavor-types/sensor.txt deleted file mode 100644 index 49d2d7d..0000000 --- a/models/schemas/puml/flavor-types/sensor.txt +++ /dev/null @@ -1,107 +0,0 @@ -@startjson -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "title": "Sensor", - "properties": { - "Characteristics": { - "type": "object", - "properties": { - "SensorType": { - "type": "string", - "description": "The type of sensor" - }, - "SensorModel": { - "type": "string", - "description": "The model of sensor" - }, - "SensorManufacturer": { - "type": "string", - "description": "The manufacturer of sensor" - }, - "SensorMarket": { - "type": "string", - "description": "The market of sensor" - }, - "SamplingRate": { - "type": "integer", - "description": "The sampling rate of the sensor in milliseconds" - }, - "Accuracy": { - "type": "integer", - "description": "The accuracy reported for the measurements (unit percentage)" - }, - "Consumption": { - "type": "integer", - "description": "The power consumption of the reported sensor (unit mW)" - }, - "Interface": { - "type": "string", - "description": "Not clear what that means." - }, - "SecurityStandards": { - "type": "array", - "description": "Security standards supported by the Flavor (e.g., GDPR).", - "items": { - "type": "string" - } - }, - "Latency": { - "type": "integer", - "description": "The latency of the Flavor." - }, - "additionalProperties": { - "type": "object", - "description": "Additional properties of the sensor", - "properties": { - "MeasurementUnit": { - "type": "string", - "description": "The unit of measure for the measurements" - }, - "ConsumptionUnit": { - "type": "string", - "description": "The unit of measure for the sensor power consumption" - }, - "SamplingRateUnit": { - "type": "string", - "description": "The unit of measure for the sampling rate" - }, - "AccessProtocol": { - "type": "string", - "description": "Not sure what that means" - } - } - } - } - }, - "AccessType": { - "description": "The access type of the sensor. Currently, HTTP and MQTT are supported.", - "oneOf": [ - { - "type": "object", - "title": "HTTP", - "properties": { - "method": { - "type": "array", - "description": "HTTP method supported.", - "items": { - "type": "string" - } - } - } - }, - { - "type": "object", - "title": "MQTT", - "description": "QoS level guaranteed.", - "properties": { - "QoS": { - "type": "string" - } - } - } - ] - } - } -} -@endjson diff --git a/models/schemas/puml/flavor-types/service.txt b/models/schemas/puml/flavor-types/service.txt deleted file mode 100644 index fc281c7..0000000 --- a/models/schemas/puml/flavor-types/service.txt +++ /dev/null @@ -1,53 +0,0 @@ -@startjson -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "title": "Service", - "description": "Service flavor type", - "properties": { - "Characteristics": { - "type": "object", - "properties": { - "Name": { - "type": "string", - "description": "Name of the flavor." - }, - "Description": { - "type": "string", - "description": "Description of the flavor." - }, - "Tags": { - "type": "array", - "description": "Tags associated with the flavor.", - "items": { - "type": "string" - } - }, - "Plan": { - "type": "string", - "description": "Plan of the flavor." - }, - "Latency": { - "type": "integer", - "description": "The latency of the Flavor." - }, - "SecurityStandards": { - "type": "array", - "description": "Security standards supported by the Flavor (e.g., GDPR).", - "items": { - "type": "string" - } - } - } - }, - "ServiceType": { - "description": "ServiceType to describe the specific characteristics of the advertised flavor.", - "oneOf": [ - { - "$ref": "service-types/db.json" - } - ] - } - } -} -@endjson diff --git a/models/schemas/puml/flavor-types/vm.txt b/models/schemas/puml/flavor-types/vm.txt deleted file mode 100644 index d010dc9..0000000 --- a/models/schemas/puml/flavor-types/vm.txt +++ /dev/null @@ -1,96 +0,0 @@ -@startjson -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "title": "VM", - "description": "Virtual Machine flavor type", - "properties": { - "Characteristics": { - "type": "object", - "properties": { - "Architecture": { - "type": "string", - "description": "Architecture of the Flavor." - }, - "OS": { - "type": "string", - "description": "The Operating System of the advertised VM" - }, - "CPU": { - "type": "integer", - "description": "Number of CPU cores of the Flavor." - }, - "Memory": { - "type": "integer", - "description": "Amount of RAM of the Flavor." - }, - "GPU": { - "type": "object", - "description": "GPU characteristics of the Flavor.", - "properties": { - "GPUModel" : { - "type": "string", - "description": "The model of the GPU offered for the specific Flavor." - }, - "GPUCores": { - "type": "integer", - "description": "The number of GPU cores advertised by the Flavor." - } - } - }, - "Storage": { - "type": "integer", - "description": "The amount of storage" - } - } - }, - "Properties": { - "type": "object", - "properties": { - "Latency": { - "type": "integer", - "description": "The latency of the Flavor." - }, - "SecurityStandards": { - "type": "array", - "description": "Security standards supported by the Flavor (e.g., GDPR).", - "items": { - "type": "string" - } - }, - "CarbonFootprint": { - "type": "object", - "properties": { - "Embodied": { - "type": "integer", - "description": "Embodied carbon of the node hardware normalized by its expected lifetime." - }, - "Operational": { - "type": "array", - "description": "Forecasted average carbon intensity of the node for the next N windows/hours." - } - } - } - } - }, - "Policy": { - "type": "object", - "properties": { - "Aggregatable": { - "type": "object", - "properties": { - "MinCount": { - "type": "integer", - "description": "Minimum required number of instances of the Flavor." - }, - "MaxCount": { - "type": "integer", - "description": "Maximum required number of instances of the Flavor." - } - } - } - } - } - } -} -@endjson diff --git a/models/schemas/puml/flavor.txt b/models/schemas/puml/flavor.txt deleted file mode 100644 index bc2379d..0000000 --- a/models/schemas/puml/flavor.txt +++ /dev/null @@ -1,124 +0,0 @@ -@startjson -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Flavor", - "type": "object", - "properties": { - "FlavorID": { - "type": "string", - "description": "The unique identifier for a flavor" - }, - "ProviderID": { - "type": "string", - "description": "The unique identifier for a provider" - }, - "Timestamp": { - "type": "string", - "description": "Timestamp of the provided Flavor offer. It allows to advertise Flavors in the (near) future" - }, - "Location": { - "type": "object", - "properties": { - "Latitude": { - "type": "string", - "description": "Latitude of the location" - }, - "Longitude": { - "type": "string", - "description": "Longitude of the location" - }, - "Altitude": { - "type": "string", - "description": "Altitude of the location expressed in meters" - }, - "AdditionalNotes": { - "type": "string", - "description": "Additional notes about the location" - } - } - }, - "NetworkPropertyType": { - "type": "string", - "description": "Type of network property ensured by the privider (e.g., 5G, Wifi, Ethernet)" - }, - "FlavorType": { - "description": "A reference to a specific flavor type schema using JSON references ($ref) to external files like 'k8slice.json', 'vm.json', etc. This allows defining details specific to each flavor type.", - "oneOf": [ - { - "$ref": "flavor-types/k8slice.json" - }, - { - "$ref": "flavor-types/vm.json" - }, - { - "$ref": "flavor-types/service.json" - }, - { - "$ref": "flavor-types/sensor.json" - } - ] - }, - "Price": { - "type": "object", - "properties": { - "Amount": { - "type": "string", - "description": "Amount of the price." - }, - "Currency": { - "type": "string", - "description": "Currency of the price." - }, - "Period": { - "type": "string", - "description": "Period of the price." - } - } - }, - "Owner": { - "type": "object", - "properties": { - "Domain": { - "type": "string", - "description": "Domain of the node." - }, - "NodeID": { - "type": "string", - "description": "ID of the node." - }, - "IP": { - "type": "string", - "description": "IP of the node." - }, - "AdditionalInformation": { - "type": "object", - "description": "Additional information about the node.", - "properties": { - "LiqoID": { - "type": "string", - "description": "Liqo ID of the node." - } - } - } - } - }, - "OptionalFields": { - "type": "object", - "properties": { - "Availability": { - "type": "boolean", - "description": "Availability flag of the Flavor." - }, - "WorkerID": { - "type": "string", - "description": "ID of the worker that provides the Flavor." - } - } - }, - "AdditionalInfo": { - "type": "string", - "description": "Additional information to enrich the Flavor description using a key: value representation." - } - } -} -@endjson diff --git a/models/schemas/purchase-request.schema.json b/models/schemas/purchase-request.schema.json new file mode 100644 index 0000000..036722c --- /dev/null +++ b/models/schemas/purchase-request.schema.json @@ -0,0 +1,11 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "PurchaseRequest", + "properties": { + "LiqoCredentials": { + "$ref": "credentials/liqo-credentials.schema.json" + } + }, + "additionalProperties": false +} \ No newline at end of file diff --git a/models/schemas/reservation.schema.json b/models/schemas/reservation.schema.json new file mode 100644 index 0000000..13bec27 --- /dev/null +++ b/models/schemas/reservation.schema.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "Reservation", + "properties": { + "FlavorID": { + "type": "string", + "description": "The unique identifier of the flavor to be reserved" + }, + "Buyer": { + "$ref": "node-identity.schema.json" + }, + "Configuration": { + "$ref": "configuration.schema.json", + "description": "The configuration of the flavour to reserve" + } + }, + "required": [ + "FlavorID", + "Buyer" + ], + "additionalProperties": false +} \ No newline at end of file diff --git a/models/schemas/svg/flavor-types/k8slice.svg b/models/schemas/svg/flavor-types/k8slice.svg deleted file mode 100644 index 9bdeda1..0000000 --- a/models/schemas/svg/flavor-types/k8slice.svg +++ /dev/null @@ -1 +0,0 @@ -$schemahttp://json-schema.org/draft-07/schema#typeobjecttitleK8SlicedescriptionKubernetes Flavor Typeproperties   Characteristics   Properties   Policy   typeobjectproperties   CPU   Pods   Memory   GPU   Storage   typeintegerdescriptionThe number of CPU corestypeintegerdescriptionThe number of podstypeintegerdescriptionThe amount of memorytypeobjectdescriptionGPU characteristics of the Flavor.properties   GPUModel   GPUCores   typestringdescriptionThe model of the GPU offered for the specific Flavor.typeintegerdescriptionThe number of GPU cores advertised by the Flavor.typeintegerdescriptionThe amount of storagetypeobjectproperties   Latency   SecurityStandards   CarbonFootprint   typeintegerdescriptionThe latency of the Flavor.typearraydescriptionSecurity standards supported by the Flavor (e.g., GDPR).items   typestringtypeobjectproperties   Embodied   Operational   typeintegerdescriptionEmbodied carbon of the node hardware normalized by its expected lifetime.typearraydescriptionForecasted average carbon intensity of the node for the next N windows/hours.typeobjectproperties   Aggregatable   Partitionable   typeobjectproperties   MinCount   MaxCount   typeintegerdescriptionMinimum required number of instances of the Flavor.typeintegerdescriptionMaximum required number of instances of the Flavor.typeobjectproperties   CpuMin   MemoryMin   CpuStep   MemoryStep   typeintegerdescriptionMinimum required number of CPU cores of the Flavor.typeintegerdescriptionMinimum required amount of RAM of the Flavor.typeintegerdescriptionIncremental value of CPU cores of the Flavor.typeintegerdescriptionIncremental value of RAM of the Flavor. \ No newline at end of file diff --git a/models/schemas/svg/flavor-types/sensor.svg b/models/schemas/svg/flavor-types/sensor.svg deleted file mode 100644 index df4caf1..0000000 --- a/models/schemas/svg/flavor-types/sensor.svg +++ /dev/null @@ -1 +0,0 @@ -$schemahttp://json-schema.org/draft-07/schema#typeobjecttitleSensorproperties   Characteristics   AccessType   typeobjectproperties   SensorType   SensorModel   SensorManufacturer   SensorMarket   SamplingRate   Accuracy   Consumption   Interface   SecurityStandards   Latency   additionalProperties   typestringdescriptionThe type of sensortypestringdescriptionThe model of sensortypestringdescriptionThe manufacturer of sensortypestringdescriptionThe market of sensortypeintegerdescriptionThe sampling rate of the sensor in millisecondstypeintegerdescriptionThe accuracy reported for the measurements (unit percentage)typeintegerdescriptionThe power consumption of the reported sensor (unit mW)typestringdescriptionNot clear what that means.typearraydescriptionSecurity standards supported by the Flavor (e.g., GDPR).items   typestringtypeintegerdescriptionThe latency of the Flavor.typeobjectdescriptionAdditional properties of the sensorproperties   MeasurementUnit   ConsumptionUnit   SamplingRateUnit   AccessProtocol   typestringdescriptionThe unit of measure for the measurementstypestringdescriptionThe unit of measure for the sensor power consumptiontypestringdescriptionThe unit of measure for the sampling ratetypestringdescriptionNot sure what that meansdescriptionThe access type of the sensor. Currently, HTTP and MQTT are supported.oneOf         typeobjecttitleHTTPproperties   method   typearraydescriptionHTTP method supported.items   typestringtypeobjecttitleMQTTdescriptionQoS level guaranteed.properties   QoS   typestring \ No newline at end of file diff --git a/models/schemas/svg/flavor-types/service.svg b/models/schemas/svg/flavor-types/service.svg deleted file mode 100644 index 92cee3b..0000000 --- a/models/schemas/svg/flavor-types/service.svg +++ /dev/null @@ -1 +0,0 @@ -$schemahttp://json-schema.org/draft-07/schema#typeobjecttitleServicedescriptionService flavor typeproperties   Characteristics   ServiceType   typeobjectproperties   Name   Description   Tags   Plan   Latency   SecurityStandards   typestringdescriptionName of the flavor.typestringdescriptionDescription of the flavor.typearraydescriptionTags associated with the flavor.items   typestringtypestringdescriptionPlan of the flavor.typeintegerdescriptionThe latency of the Flavor.typearraydescriptionSecurity standards supported by the Flavor (e.g., GDPR).items   typestringdescriptionServiceType to describe the specific characteristics of the advertised flavor.oneOf      $refservice-types/db.json \ No newline at end of file diff --git a/models/schemas/svg/flavor-types/vm.svg b/models/schemas/svg/flavor-types/vm.svg deleted file mode 100644 index 1d8cb65..0000000 --- a/models/schemas/svg/flavor-types/vm.svg +++ /dev/null @@ -1 +0,0 @@ -$schemahttp://json-schema.org/draft-07/schema#typeobjecttitleVMdescriptionVirtual Machine flavor typeproperties   Characteristics   Properties   Policy   typeobjectproperties   Architecture   OS   CPU   Memory   GPU   Storage   typestringdescriptionArchitecture of the Flavor.typestringdescriptionThe Operating System of the advertised VMtypeintegerdescriptionNumber of CPU cores of the Flavor.typeintegerdescriptionAmount of RAM of the Flavor.typeobjectdescriptionGPU characteristics of the Flavor.properties   GPUModel   GPUCores   typestringdescriptionThe model of the GPU offered for the specific Flavor.typeintegerdescriptionThe number of GPU cores advertised by the Flavor.typeintegerdescriptionThe amount of storagetypeobjectproperties   Latency   SecurityStandards   CarbonFootprint   typeintegerdescriptionThe latency of the Flavor.typearraydescriptionSecurity standards supported by the Flavor (e.g., GDPR).items   typestringtypeobjectproperties   Embodied   Operational   typeintegerdescriptionEmbodied carbon of the node hardware normalized by its expected lifetime.typearraydescriptionForecasted average carbon intensity of the node for the next N windows/hours.typeobjectproperties   Aggregatable   typeobjectproperties   MinCount   MaxCount   typeintegerdescriptionMinimum required number of instances of the Flavor.typeintegerdescriptionMaximum required number of instances of the Flavor. \ No newline at end of file diff --git a/models/schemas/svg/flavor.svg b/models/schemas/svg/flavor.svg deleted file mode 100644 index 21f985b..0000000 --- a/models/schemas/svg/flavor.svg +++ /dev/null @@ -1 +0,0 @@ -$schemahttp://json-schema.org/draft-07/schema#titleFlavortypeobjectproperties   FlavorID   ProviderID   Timestamp   Location   NetworkPropertyType   FlavorType   Price   Owner   OptionalFields   AdditionalInfo   typestringdescriptionThe unique identifier for a flavortypestringdescriptionThe unique identifier for a providertypestringdescriptionTimestamp of the provided Flavor offer. It allows to advertise Flavors in the (near) futuretypeobjectproperties   Latitude   Longitude   Altitude   AdditionalNotes   typestringdescriptionLatitude of the locationtypestringdescriptionLongitude of the locationtypestringdescriptionAltitude of the location expressed in meterstypestringdescriptionAdditional notes about the locationtypestringdescriptionType of network property ensured by the privider (e.g., 5G, Wifi, Ethernet)descriptionA reference to a specific flavor type schema using JSON references ($ref) to external files like 'k8slice.json', 'vm.json', etc. This allows defining details specific to each flavor type.oneOf               $refflavor-types/k8slice.json$refflavor-types/vm.json$refflavor-types/service.json$refflavor-types/sensor.jsontypeobjectproperties   Amount   Currency   Period   typestringdescriptionAmount of the price.typestringdescriptionCurrency of the price.typestringdescriptionPeriod of the price.typeobjectproperties   Domain   NodeID   IP   AdditionalInformation   typestringdescriptionDomain of the node.typestringdescriptionID of the node.typestringdescriptionIP of the node.typeobjectdescriptionAdditional information about the node.properties   LiqoID   typestringdescriptionLiqo ID of the node.typeobjectproperties   Availability   WorkerID   typebooleandescriptionAvailability flag of the Flavor.typestringdescriptionID of the worker that provides the Flavor.typestringdescriptionAdditional information to enrich the Flavor description using a key: value representation. \ No newline at end of file diff --git a/models/schemas/transaction.schema.json b/models/schemas/transaction.schema.json new file mode 100644 index 0000000..819f406 --- /dev/null +++ b/models/schemas/transaction.schema.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "title": "Transaction", + "properties": { + "TransactionID": { + "type": "string", + "description": "The unique identifier for the transaction" + }, + "FlavorID": { + "type": "string", + "description": "The unique identifier for the flavor reserved" + }, + "Buyer": { + "$ref": "node-identity.schema.json", + "description": "The node identity of the buyer that is reserverving the flavor" + }, + "ExpirationTime": { + "type": "string", + "format": "date-time", + "description": "The expiration time of the transaction" + } + } +} \ No newline at end of file diff --git a/scripts/generate_docs.py b/scripts/generate_docs.py new file mode 100755 index 0000000..3400c26 --- /dev/null +++ b/scripts/generate_docs.py @@ -0,0 +1,126 @@ +import json +import os +import argparse + +def generate_html(data, base_dir, depth, res): + spaces = " " * depth + + for key, value in data.items(): + if "oneOf" in value: + res.append(f"{spaces}- **{key}**. {value['description']}") + continue + if "$ref" in value: + ref = value["$ref"] + if ref.startswith("http"): + res.append(f"{spaces}- **{key}**. {value.get('description', '')} [Reference: {ref}]") + else: + ref_name = os.path.basename(ref).replace('.schema.json', '') + res.append(f"{spaces}- **{key}**. {value.get('description', '')} [Reference: #{ref_name}]") + elif value["type"] != "object": + res.append(f"{spaces}- **{key}**. {value.get('description', '')} [{value['type']}]") + else: + res.append(f"{spaces}- **{key}**:") + generate_html(value["properties"], base_dir, depth + 1, res) + +def generate_type_markdown(type_name, type_data, schema_name, docs_base_dir, schema_svg_dir, example_svg_dir, relative_path): + lines = [f"# {type_name.capitalize()}"] + lines.append("") + + schema_svg_path = os.path.abspath(os.path.join(schema_svg_dir, relative_path, f"{type_name}.svg")) + example_svg_path = os.path.abspath(os.path.join(example_svg_dir, relative_path, f"{type_name}.svg")) + schema_svg_relative_path = os.path.relpath(schema_svg_path, os.path.join(docs_base_dir, relative_path)) + example_svg_relative_path = os.path.relpath(example_svg_path, os.path.join(docs_base_dir, relative_path)) + + lines.append(f"![Example SVG]({example_svg_relative_path})") + lines.append("") + lines.append(f"[Show schema SVG]({schema_svg_relative_path})") + lines.append("") + + generate_html(type_data["properties"], docs_base_dir, 0, lines) + type_md_path = os.path.join(docs_base_dir, relative_path, f"{type_name}.md") + os.makedirs(os.path.dirname(type_md_path), exist_ok=True) + + with open(type_md_path, "w") as type_md_file: + type_md_file.write("\n".join(lines)) + +def process_directory(base_dir, schema_svg_dir, example_svg_dir, res, depth=0): + docs_base_dir = os.path.join(os.getcwd(), 'docs') + + # Create array of subdirectories already mapped as related components + subdirs = [] + + for root, dirs, files in os.walk(base_dir): + + print(f"Processing {root}") + print(f"dirs: {dirs}") + print(f"files: {files}") + + if root in subdirs: + continue + + schema_files = [f for f in files if f.endswith(".schema.json")] + if not schema_files: + continue + + relative_path = os.path.relpath(root, base_dir) + + for f_name in schema_files: + schema_name = f_name.replace('.schema.json', '') + schema_path = os.path.join(root, f_name) + + # Calculate SVG paths + schema_svg_path = os.path.abspath(os.path.join(schema_svg_dir, relative_path, f"{schema_name}.svg")) + example_svg_path = os.path.abspath(os.path.join(example_svg_dir, relative_path, f"{schema_name}.svg")) + schema_svg_relative_path = os.path.relpath(schema_svg_path, os.getcwd()) + example_svg_relative_path = os.path.relpath(example_svg_path, os.getcwd()) + + res.append("") + res.append(f"{'#' * (depth + 2)} {schema_name.capitalize()}") + res.append("") + res.append(f"![Example SVG]({example_svg_relative_path})") + res.append("") + res.append(f"[Show schema SVG]({schema_svg_relative_path})") + res.append("") + + with open(schema_path) as f: + data = json.load(f) + + generate_html(data["properties"], root, depth + 1, res) + + # Check for subdirectory types but do not process them here + types_dir = os.path.join(root, f"{schema_name}-types") + if os.path.isdir(types_dir): + # Add directory to array + subdirs.append(types_dir) + res.append(f"### {schema_name.capitalize()} types") + type_files = [f for f in os.listdir(types_dir) if f.endswith('.schema.json')] + for type_file in type_files: + type_name = type_file.replace('.schema.json', '') + type_md_relative_path = os.path.relpath( + os.path.join('docs', f"{schema_name}-types", f"{type_name}.md"), os.getcwd() + ) + res.append(f"- [{type_name.capitalize()}]({type_md_relative_path})") + with open(os.path.join(types_dir, type_file)) as tf: + type_data = json.load(tf) + generate_type_markdown(type_name, type_data, schema_name, docs_base_dir, schema_svg_dir, example_svg_dir, os.path.join(relative_path, f"{schema_name}-types")) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Generate README.md from JSON schemas.') + parser.add_argument('schema_dir', type=str, help='The directory containing the JSON schemas') + parser.add_argument('schema_svg_dir', type=str, help='The directory containing the schema SVGs') + parser.add_argument('example_svg_dir', type=str, help='The directory containing the example SVGs') + args = parser.parse_args() + + res = [""] + res.append("```") + res.append("DISCLAIMER #1: The content of this document is automatically generated upon pushing the files on GitHub. \nThe generation starts from the JSON schema and examples contained in the repository. \nDo not try to modify this document, just the JSON files.") + res.append("```") + res.append("```") + res.append("DISCLAIMER #2: Still, the generation of examples of JSONs (starting from the schema) is not automated yet. \nTherefore, we suggest to use tools like ChatGPT or Gemini, providing the JSON schema to the prompt and asking for an example of compliant JSON.") + res.append("```") + res.append("In the following we represent some examples of JSON, you can find the original JSON schemas [here](models/schemas).") + + process_directory(args.schema_dir, args.schema_svg_dir, args.example_svg_dir, res) + + with open("README.md", "w") as text_file: + text_file.write("\n".join(res)) diff --git a/scripts/generate_puml.sh b/scripts/generate_puml.sh new file mode 100755 index 0000000..2b7adf5 --- /dev/null +++ b/scripts/generate_puml.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Generate PlantUML diagram from schema files +# Usage: ./generate_puml.sh + +# Check if directory parameter is provided +if [ -z "$1" ]; then + echo "Usage: ./generate_puml.sh " + exit 1 +fi + +# Store the directory path +directory="$1" + +# Get the absolute path of the script in execution +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +# Create a new directory to store the PlantUML files +mkdir -p "$SCRIPT_DIR/../puml/$directory" + +# Get the absolute path of the directory + +# Open json schema files in the specified directory and generate PlantUML diagram +find "$directory" -type f -name "*.json" | while read -r filename; do + new_filename=$(echo "$filename" | sed 's/\.schema\.json$//' | sed 's/\.json$//') + # Create a new PlantUML file and its upper directory if necessary + mkdir -p "$(dirname "$SCRIPT_DIR/../puml/$new_filename.puml")" + # Add the PlantUML diagram header + echo "@startjson" > "$SCRIPT_DIR/../puml/$new_filename.puml" + # Add the content of the json schema file + cat "$filename" >> "$SCRIPT_DIR/../puml/$new_filename.puml" + # Add the PlantUML diagram footer + echo "" >> "$SCRIPT_DIR/../puml/$new_filename.puml" + echo "@endjson" >> "$SCRIPT_DIR/../puml/$new_filename.puml" +done diff --git a/scripts/generate_svg.py b/scripts/generate_svg.py new file mode 100755 index 0000000..f71b764 --- /dev/null +++ b/scripts/generate_svg.py @@ -0,0 +1,32 @@ +import argparse +import sys +import os +from plantuml import PlantUML + +def write_text(data: str, path: str): + with open(path, 'w') as file: + file.write(data) + +def generate_schema_svg(dir): + script_dir = os.path.dirname(os.path.abspath(__file__)) + out_dir = os.path.join(script_dir, "..", "svg") + + plantuml = PlantUML(url='http://www.plantuml.com/plantuml/svg/') + + puml_files = [os.path.join(root, f) for root, _, files in os.walk(f"{dir}") for f in files if f.endswith(".puml")] + + for puml_file in puml_files: + relative_path = os.path.relpath(puml_file, start=f"{dir}") + svg_path = os.path.join(out_dir, relative_path).replace('.puml', '.svg') + svg_dir = os.path.dirname(svg_path) + if not os.path.exists(svg_dir): + os.makedirs(svg_dir) + plantuml.processes_file(puml_file, svg_path) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Generate SVG from PlantUML files') + parser.add_argument('directory', type=str, help='The directory containing the PlantUML files') + args = parser.parse_args() + + generate_schema_svg(args.directory) + diff --git a/scripts/requirements.txt b/scripts/requirements.txt new file mode 100644 index 0000000..d422bf9 --- /dev/null +++ b/scripts/requirements.txt @@ -0,0 +1,4 @@ +httplib2==0.22.0 +plantuml==0.3.0 +pyparsing==3.1.2 +six==1.16.0