Integrating with a Billing System

MetalSoft records all deployment operations which include provisioning, edits changes of server type or VM type, deletions etc.

MetalSoft provides an API call (resource_utilization_detailed()) to retrieve the resource utilization for a particular user in JSON format.

The following is an example output:

{
	"detailed_report": {
		"3668": {
			"shared_drive":[
				{
					"cost": "0.23354152",
					"cost_currency": "GBP",
					"cost_per_unit": "0.00347222",
					"end_timestamp": "2016-01-25T09:54:39Z",
					"is_reservation": "0",
					"measurement_period": 3600,
					"measurement_unit": "seconds",
					"product_id": 779,
					"product_label": "new-shared-drive",
					"product_subdomain": "new-shared-drive.test.1.integration.metalsoft.io",
					"quantity: "242136",
					"shared_drive_size_mbytes": 51200,
					"start_timestamp": "2016-01-22T14:39:04Z"

				}
			],
			"drive": [
				{
					"cost": "1.11383813",
					"cost_currency": "GBP",
					"cost_per_unit": "0.01601563",
					"drive_size_mbytes": 41000,
					"end_timestamp": "2016-02-04T10:31:03Z",
					"is_reservation": "0",
					"measurement_period": "3600",
					"measurement_unit": "seconds",
					"product_id": 3727,
					"product_label": "drive-3727",
					"product_subdomain": "drive-3727.new-drive-array.d-lake.1.integration.metalsoft.io",
					"quantity": "250369",
					"start_timestamp": "2016-02-01T12:58:15Z"
				}
			],
			"instance": [
				{
					"cost": "7.25925278",
					"cost_currency": "GBP",
					"cost_per_unit": "0.31000000",
					"end_timestamp": "2016-02-02T12:23:00Z",
					"is_reservation": "0",
					"measurement_period": "3600",
					"measurement_unit": "seconds",
					"product_id": 2416,
					"product_label": "instance-2416",
					"product_subdomain": "instance-2416.new-instance-array.d-lake.1.integration.metalsoft.io",
					"quantity": "84301",
					"server_type_id": null,
					"start_timestamp": "2016-02-01T12:58:00Z"
				}
			],
			"subnet": [
				{
					"cost": "0.00000000",
					"cost_currency": "GBP",
					"cost_per_unit": "0.00000000",
					"end_timestamp": "2016-02-04T10:30:53Z",
					"is_reservation": "0",
					"measurement_period": "3600",
					"measurement_unit": "seconds",
					"product_id": 6378,
					"product_label": "subnet-6378",
					"product_subdomain": "subnet-6378.wan.d-lake.1.integration.metalsoft.io",
					"quantity": "250376",
					"start_timestamp": "2016-02-01T12:57:58Z",
					"subnet_prefix_size": 64,
					"subnet_type": "ipv6"
				}
			]
	},
	"network_report": {
		"3688": {
			"data_lake": {
				"download": {
					"cost": 0,
					"cost_currency": "GBP",
					"measurement_unit": "gbytes",
					"quantity": 0,
					"metered_waypoints": [
						{
							"cost": "0.00000000",
							"cost_currency": "GBP",
							"cost_per_unit": "0.00000000",
							"end_timestamp": "2016-02-09T08:11:39Z",
							"is_reservation": "0",
							"measurement_period": "3600",
							"measurement_unit": "gbytes",
							"product_id": 8,
							"product_label": "data-lake-8",
							"product_subdomain": "data-lake-8.d-lake.1.integration.metalsoft.io",
							"quantity": "0.0000",
							"start_timestamp": "2016-02-01T13:10:05Z"
						}
					]
				},
				"upload": {
					"cost": 0,
					"cost_currency": "GBP",
					"measurement_unit": "gbytes",
					"quantity": 0,
					"metered_waypoints": [
						{
							"cost": "0.00000000",
							"cost_currency": "GBP",
							"cost_per_unit": "0.06000000",
							"end_timestamp": "2016-02-09T08:11:39Z",
							"is_reservation": "0",
							"measurement_period": "3600",
							"measurement_unit": "gbytes",
							"product_id": 8,
							"product_label": "data-lake-8",
							"product_subdomain": "data-lake-8.d-lake.1.integration.metalsoft.io",
							"quantity": "0.0000",
							"start_timestamp": "2016-02-01T13:10:06Z"
						}
					]
				}
			},
			"network": {
				"download": {
					"cost": 0,
					"cost_currency": "GBP",
					"measurement_unit": "gbytes",
					"quantity": 0,
					"metered_waypoints": [
						{
							"cost": "0.00000000",
							"cost_currency": "GBP",
							"cost_per_unit": "0.00000000",
							"end_timestamp": "2016-02-04T10:30:54Z",
							"is_reservation": "0",
							"measurement_period": "10800",
							"measurement_unit": "gbytes",
							"product_id": 8381,
							"product_label": "wan",
							"product_subdomain": "wan.d-lake.1.integration.metalsoft.io",
							"quantity": "0.0000",
							"start_timestamp": "2016-02-01T12:57:59Z"
						}
					]
				},
				"upload": {
					"cost": 0,
					"cost_currency": "GBP",
					"measurement_unit": "gbytes",
					"quantity": 0,
					"metered_waypoints": [
						{
							"cost": "0.00000000",
							"cost_currency": "GBP",
							"cost_per_unit": "0.06000000",
							"end_timestamp": "2016-02-04T10:30:54Z",
							"is_reservation": "0",
							"measurement_period": "10800",
							"measurement_unit": "gbytes",
							"product_id": 8381,
							"product_label": "wan",
							"product_subdomain": "wan.d-lake.1.integration.metalsoft.io",
							"quantity": "0.0000",
							"start_timestamp": "2016-02-01T12:57:59Z"
						}
					]
				}
			}
		}
	},

Making the API call

To perform the HTTP API request the API key of a user with the utilization_reports_read permission. The API call details:

  1. POST request

  2. Authorization header set to “Bearer <the_API_key>”

  3. URL set to $ENV_ENDPOINT/api/developer/developer

  4. Body set to, for example:

{"method": "resource_utilization_detailed", 
"params": [1,"2023-12-31T23:59:59Z","2024-12-31T23:59:59Z"],
"id":null, "jsonrpc": 2.0, }

The parameters for the function are:

 resource_utilization_detailed(
	integer strUserIDOwner, 
	string  strStartTimestamp, 
	string  strEndTimestamp, 
	array   arrInfrastructureIDs=null, 
	array   arrDatacenterNames=null
)

The following is an example CURL request:

curl -X POST -H "Authorization: Bearer $METALCLOUD_API_KEY" https://us01.metalsoft.io/api/developer/developer -d '{"id":null, "jsonrpc": 2.0, "method": "resource_utilization_detailed", "params": [1,"2023-12-31T23:59:59Z","2024-12-31T23:59:59Z"]}'

If the Billing system is not capable of executing calls to pull the utilization of users, another option is to use a “glue” script that will call both MetalSoft and the billing system to insert the utilization data.

Using the subscriptions

The subscription system although functional in MetalSoft is deprecated and will be removed in future versions.

Using the pricing information

The pricing system although functional in MetalSoft is deprecated and will be removed in future versions.