copyright | link | is |
---|---|---|
Copyright IBM Corp. 2018 |
create-space-template |
beta |
A user can create a custom space template with the createSpaceTemplate mutation.
At a high level, the createSpaceTemplate mutation looks like this.
type MutationRoot {
...
createSpaceTemplate(input: CreateSpaceTemplateInput!): SpaceTemplateMutation
}
The SpaceTemplateMutation returned has a single property, the space template created:
type SpaceTemplateMutation {
spaceTemplate: SpaceTemplate
}
The input object has three required properties: template name and description strings, and a spaceStatus input object.
The SpaceStatusInput contains a list of acceptable statuses for spaces created using the template. Each SpaceStatusAcceptableValueInput has a single property, displayName. Note that the order in which space status values are supplied is significant. They should be added to the template in the logical sequence through which you would expect a space to progress, e.g., from "New" to "Closed".
type CreateSpaceTemplateInput {
name: String!
description: String!
properties: SpacePropertiesInput
spaceStatus: SpaceStatusInput!
requiredApps: SpaceRequiredAppsInput
}
type SpaceStatusInput {
acceptableValues: [SpaceStatusAcceptableValueInput]!
}
type SpaceStatusAcceptableValueInput {
displayName: String!
}
Custom properties may optionally be added to the template by including a properties field. The SpacePropertiesInput object contains a list of wrapper objects, each containing a single property to be added to the template.
Properties to be added may be of three different types: text, boolean, or list.
type SpacePropertiesInput {
properties: [SpacePropertyWrapperInput]!
}
type SpacePropertyWrapperInput {
listProperty: SpaceListPropertyInput
textProperty: SpaceTextPropertyInput
booleanProperty: SpaceBooleanPropertyInput
}
The SpaceListPropertyInput object contains a displayName for the property and a list of the acceptableValues. Each SpaceListPropertyAcceptableValueInput has a displayName for the value. Note that the first entry in the list will be taken as the default value for the property.
type SpaceListPropertyInput {
displayName: String!
acceptableValues: [SpaceListPropertyAcceptableValueInput]!
}
type SpaceListPropertyAcceptableValueInput {
displayName: String!
}
The SpaceTextPropertyInput and SpaceBooleanPropertyInput objects each contain a displayName and defaultValue for the property in question. If not specified, the default value for a text property will be an empty string and for a boolean property will be false
.
type SpaceTextPropertyInput {
displayName: String!
defaultValue: String
}
type SpaceBooleanPropertyInput {
displayName: String!
defaultValue: Boolean
}
Required apps may optionally be added to the template by including a requiredApps field. The SpaceRequiredAppsInput object contains a list of individual app input objects, each of which contains the ID of an app to be added.
type SpaceRequiredAppsInput {
apps: [SpaceRequiredAppInput]!
}
type SpaceRequiredAppInput {
id: String!
}
Below is an example request to create a space template, including sample space status values, a custom list property and required apps.
Method: POST
URL: https://api.watsonwork.ibm.com/graphql
Headers: 'Content-Type: application/graphql' , 'x-graphql-view: PUBLIC, BETA'
Body:
{
mutation {
createSpaceTemplate(input: {
name: "Template 1"
description: "A test template."
spaceStatus: {
acceptableValues: [
{
displayName: "New"
},
{
displayName: "Close"
}
]
}
properties: {
properties: [
{
listProperty: {
displayName: "Area",
acceptableValues: [
{
displayName: "Supply",
},
{
displayName: "Inventory"
}
]
}
}
]
}
requiredApps: {
apps: [
{
id: "d0c246a0-bced-4bf4-a29d-99cc6ad1ad53"
},
{
id: "e8c0e8ae-49cf-448d-a845-bb453f0bf94a"
}
]
}
}) {
spaceTemplate {
id
}
}
}
}