Creating Entities

You can use the GraphQL to create Products, Assets, Asset Versions, Artifacts, and Tests.

Pre-Requisites

There are a few things you need to know before you can create entities.

  • Products don't require any other entities to be created before they can be created.
  • Assets also do not require any other entities to be created before they can be created.
  • However, Asset Versions, Artifacts, and Tests all require that the Asset they are associated with already exists.

Creating Products

To create a product, you need to provide the following information:

  • Name (required)
  • Description
  • Vendor Information

To create a product, use the createProduct mutation. The createProduct mutation takes a CreateProductInput, which is specified in the variables section of the GraphQL query.

For details about the available fields in the CreateProductInput, see the CreateProductInput.

mutation CreateProductMutation($input: CreateProductInput!) {
  createProduct(input: $input) {
          id
          name
          vendor {
              name
          }
          group {
              id
              name
          }
          createdBy {
              id
              email
          }
          ctx {
              businessUnit
          }
  }
}

Creating Assets

To create an asset, use the createAsset mutation. The createAsset mutation takes a CreateAssetInput, which is specified in the variables section of the GraphQL query.

For details about the available fields in the CreateAssetInput, see the CreateAssetInput.

mutation CreateAssetMutation($input: CreateAssetInput!) {
    createAsset(input: $input) {
        id
        name
        dependentProducts {
            id
            name
        }
        group {
            id
            name
        }
        createdBy {
            id
            email
        }
        ctx {
            asset
            products
            businessUnits
        }
    }
}

Creating Asset Versions

To create an AssetVersion, use the createAssetVersion mutation. The createAssetVersion mutation takes a CreateAssetVersionInput, which is specified in the variables section of the GraphQL query.

For details about the available fields in the CreateAssetVersionInput, see the CreateAssetVersionInput.

Here is an example:

mutation CreateAssetVersionMutation($input: CreateAssetVersionInput!) {
    createAssetVersion(input: $input) {
        id
        name
        asset {
            id
            name
        }
        createdBy {
            id
            email
        }
        ctx {
            asset
            products
            businessUnits
        }
    }
}

Creating Artifacts

To create an artifact, use the createArtifact mutation. The createArtifact mutation takes a CreateArtifactInput, which is specified in the variables section of the GraphQL query.

For details about the available fields in the CreateArtifactInput, see the CreateArtifactInput.

Here is an example:

mutation CreateArtifactMutation($input: CreateArtifactInput!) {
    createArtifact(input: $input) {
        id
        name
        assetVersion {
            id
            name
            asset {
                id
                name
            }
        }
        createdBy {
            id
            email
        }
        ctx {
            asset
            products
            businessUnits
        }
    }
}

Creating Tests

When creating a test, you need to provide the type of the test so that any files uploaded for the test will be interpreted correctly by the platform.

Some options for specifying the test type are:

  • testResultFileFormat: cyclonedx
  • testResultFileFormat: finite_state_binary_analysis

To create a test, use the createTest mutation. The createTest mutation takes a CreateTestInput, which is specified in the variables section of the GraphQL query.

For details about the available fields in the CreateTestInput, see the CreateTestInput.

Here is an example:

mutation CreateTestMutation($input: CreateTestInput!) {
    createTest(input: $input) {
        id
        name
        artifactUnderTest {
            id
            name
            assetVersion {
                id
                name
                asset {
                    id
                    name
                    dependentProducts {
                        id
                        name
                    }
                }
            }
        }
        createdBy {
            id
            email
        }
        ctx {
            asset
            products
            businessUnits
        }
    }
}