Skip to main content

GraphQL Mutations

Mutations in the Klarity ImageFactory GraphQL API allow you to create, update, and delete resources. This page provides a comprehensive reference for all available mutations, including detailed examples for the most common operations.

The GraphQL endpoint is: https://api.imagefactory.nordcloudapp.com

Customer Mutations

createCustomer(input: NewCustomer!): Customer

Creates a new customer entity.

updateCustomer(input: CustomerChanges!): Customer

Updates an existing customer's details.

deleteCustomer(customerId: String!): Boolean

Deletes a customer and all associated resources (accounts, templates, images, etc.). Use with extreme caution.


Account Mutations

createAccount(customerId: String!, input: NewAccount!): Account

Registers a new cloud account (AWS, Azure, GCP, etc.) for a customer.

Example (AWS Account):

mutation CreateAwsAccount($customerId: String!, $input: NewAccount!) {
createAccount(customerId: $customerId, input: $input) {
id
name
status
}
}

Variables:

{
"customerId": "cust-123",
"input": {
"name": "Production AWS",
"provider": "AWS",
"credentials": {
"aws": {
"roleArn": "arn:aws:iam::123456789012:role/ImageFactoryAccess"
}
}
}
}

updateAccount(customerId: String!, input: AccountChanges!): Account

Updates account configuration or credentials.

recheckAccount(customerId: String!, accountId: String!): Account

Triggers an immediate validation of the account's credentials and permissions.

deleteAccount(customerId: String!, accountId: String!): Boolean

Removes an account from ImageFactory.


Template Mutations

createTemplate(customerId: String!, input: NewTemplate!): Template

Creates a new image template. Creating a template automatically triggers the first image build.

Example:

mutation CreateTemplate($customerId: String!, $input: NewTemplate!) {
createTemplate(customerId: $customerId, input: $input) {
id
name
buildStatus
}
}

Variables:

{
"customerId": "cust-123",
"input": {
"name": "Ubuntu 22.04 Hardened",
"osType": "LINUX",
"osSubtype": "UBUNTU",
"provider": "AWS",
"region": "eu-central-1",
"components": [
{ "componentId": "sys-update-all", "version": "1.0.0" },
{ "componentId": "custom-hardening", "version": "latest" }
],
"distributions": [
{ "region": "eu-west-1" },
{ "region": "us-east-1" }
]
}
}

updateTemplate(customerId: String!, input: TemplateChanges!): Template

Updates template configuration.

rebuildTemplate(customerId: String!, templateId: String!): Template

Manually triggers a new image build for the specified template.

deleteTemplate(customerId: String!, templateId: String!): Boolean

Deletes the template and cleans up all associated images in the cloud provider.


Component Mutations

createComponent(customerId: String!, input: NewComponent!): Component

Creates a custom component for a specific customer.

updateComponent(componentId: String!, input: ComponentChanges!): Component

Updates component metadata.

createComponentVersion(componentId: String!, input: NewVersionedContent!): Component

Adds a new version to an existing component.

deleteComponentVersion(componentId: String!, contentVersion: String!): Boolean

Deletes a specific version of a component.

deleteComponent(componentId: String!): Boolean

Deletes a component. This operation will fail if the component is currently used by any template.


Identity and Access Mutations

createRole(customerId: String!, input: NewRole!): Role

Defines a new set of permissions.

updateRole(customerId: String!, input: RoleChanges!): Role

Updates an existing role.

deleteRole(customerId: String!, roleId: String!): Boolean

Deletes a role.

createRoleBinding(customerId: String!, input: NewRoleBinding!): RoleBinding

Assigns a role to a user or an API key.

updateRoleBinding(customerId: String!, input: RoleBindingChanges!): RoleBinding

Updates a role binding.

deleteRoleBinding(customerId: String!, roleBindingId: String!): Boolean

Removes a role assignment.

createApiKey(customerId: String!, input: NewApiKey!): ApiKey

Generates a new API key.

Example:

mutation CreateKey($customerId: String!, $input: NewApiKey!) {
createApiKey(customerId: $customerId, input: $input) {
id
name
secret # This is the ONLY time the secret is returned
}
}

deleteApiKey(customerId: String!, apiKeyId: String!): Boolean

Revokes an API key.


Variable Mutations

createVariable(customerId: String!, input: NewVariable!): Variable

Creates or updates a customer-level variable. Variables can be used in component scripts.

deleteVariable(customerId: String!, name: String!): Boolean

Deletes a variable.


Image Mutations

deleteImage(customerId: String!, templateId: String!, imageId: String!): Boolean

Deletes a specific image and removes it from the cloud provider.