Create a Data Model

The Data Model defines what test data to generate, for example, credit card numbers or email addresses.

To create a Data Model in your workspace, you need to know your workspace identifier. The sample code uses a workspaceId of 123456. Use the actual ID value of your workspace.

The response contains a Data Model identifier ( "id": "09af09af-09af-09af-09af-09af09af09af") that you should note down. You will need this dataModelID when you want to configure, deploy, or delete this Data Model later.

API Explorer:/datamodels

Create a Data Model

curl 'https://ar.blazemeter.com/​api​/v1​/workspaces​/123456/assets' 
    -X POST \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{
      "metadata": {
        "kind": "tdm",
        "fileName": "data-model.json",
        "contentType": "application/json"
      },
      "packageId": "7775df96-a80a-451d-999f-5751d146873f",
      "name": "Pet",
      "displayName": "Pet",
      "type": "data-model",
      "data": {
        "fileName": "data-model.json",
        "contentType": "application/json",
        "content": "{\"id\":\"262e943c-f3be-49d7-872d-dcc2827d7838\",\"kind\":\"tdm\",\"title\":\"Pet\",\"type\":\"object\",\"entities\":{\"default\":{\"type\":\"object\",\"title\":\"Pet\",\"repeat\":1,\"properties\":{\"age\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"},\"email\":{\"type\":\"string\"}},\"description\":\"A Pet can be dog or cat\",\"requirements\":{\"age\":\"randInt(18, 99)\",{\"name\":\"randText(5, 10)\",\"email\":\"$name + '@google.com'\"},\"targets\":{\"default\":{\"type\":\"csv\",\"file\":\"blazedata-test.csv\"}},\"datasources\":[]}}}"
      }
	}'

Create A Data Model Request Attributes

Data Model file:

     "packageId": "79ca6d76-0eac-4e89-917a-dc8b7cb66cbf",
      "name": "mytestdata.csv",
      "displayName": "mytestdata.csv",
      "type": "data-model-file",
	  "metadata": {
			"fileName": "mytestdata.csv",
			"contentType": "text/csv",
			"modelAssetId": "53de0dd6-05bd-4b5b-8190-aa2aa41e543e"
		  },
	  "data": {
			"fileName": "mytestdata.csv",
			"contentType": "text/csv",
			"content": "id,name\r
1,Joe"
		  },
	  "dependencies": {}

Data Model:

Attributes

  • description string

    The description of the new Data Model

  • properties string

    required

    Defines the data properties. For example, "email": { "type": "string"} or "age": {"type": "integer"}.

  • requirements string

    required

    Defines the rules what data to generate for each property. For example, {"name":"randText(5, 10)"}. For more information on data generation functions, see Get List of Seedlists, Get List of Data Generator Functions, and Get List of CardIssuers.

  • id numeric

    The identifier of the new Data Model.

  • title string

    The human readable title of the new Data Model.

  • type string

    The type of the new Data Model, usually "object".

  • kind string

    The kind of the new Data Model, usually "tdm".

  • repeat numeric

The following JSON sample provides a more readable version of the content contained in the above curl example. This example represents the attributes and values contained in the -d flag of the curl example.

Create a Data ModelCreate a Data Model POST Body (JSON)

{
	"metadata": {
		"kind": "tdm",
		"fileName": "data-model.json",
		"contentType": "application/json"
	},
	"packageId": "7775df96-a80a-451d-999f-5751d146873f",
	"name": "Pet",
	"displayName": "Pet",
	"type": "data-model",
	"data": {
		"fileName": "data-model.json",
		"contentType": "application/json",
		"content": {
			"kind": "tdm",
			"title": "Pet",
			"type": "object",
			"entities": {
				"default": {
					"type": "object",
					"title": "Pet",
					"repeat": 1,
					"properties": {
						"age": { "type": "integer" },
						"name": { "type": "string" },
						"email": { "type": "string" }
					},
					"description": "A Pet can be dog or cat",
					"requirements": {
						"age": "randInt(18, 99)",
						"name": "randText(5, 10)",
						"email": "$name + '@google.com'"
					},
					"targets": {
						"default": {
							"type": "csv",
							"file": "blazedata-test.csv"
						}
					},
					"datasources": []
				}
			}
		}
	}
}

The following parameters are the base parameters required to create a Data Model.

Create A Data Model Response Attributes

Attributes

  • description string

    The description of the new Data Model

  • properties string

    required

    Describes the test data properties.

  • requirements string

    required

    Describes the rules what data to generate for each property.

  • id numeric

    The identifier of the new Data Model.

  • title string

    The human readable title of the new Data Model.

  • type string

    The type of the new Data Model, usually "object".

  • kind string

    The kind of the new Data Model, usually "tdm".

  • repeat numeric

Response201 Created

{
  "timestamp": "2022-07-22T13:43:47+00:00",
  "request_id": "758339fe4eb5f9ae267718da7768e38c",
  "result": {
    "data": {
      "fileName": "mytestdata.csv",
      "contentType": "text/csv",
      "content": "id,name\r
1,Joe"
    },
    "dependencies": {},
    "id": "09af09af-09af-09af-09af-09af09af09af",
    "accountId": 514413,
    "workspaceId": 123456,
    "packageId": "79ca6d76-0eac-4e89-917a-dc8b7cb66cbf",
    "name": "mytestdata.csv",
    "displayName": "mytestdata.csv",
    "type": "data-model-file",
    "metadata": {
      "fileName": "mytestdata.csv",
      "contentType": "text/csv"
    },
    "createdAt": "2022-07-22T13:43:47.952Z",
    "createdBy": 432,
    "updatedAt": "2022-07-22T13:43:47.952Z",
    "updatedBy": 432
  }
}