| Required role: | TenantReader |
| POST | /api/action-assignments | Assigns an action to a config item | |
|---|---|---|---|
| POST | /action-assignments | Assigns an action to a config item |
import 'package:servicestack/servicestack.dart';
enum ObjectTypes
{
None,
ConfigItem,
Tenant,
Collection,
Resource,
ComputeNode,
VirtualMachine,
PhysicalMachine,
Disk,
Subnet,
IPAddress,
Job,
JobEvent,
FreezePeriod,
ResourceGroup,
Deployment,
ResourceGroupTemplate,
DeploymentTemplate,
ResourceProvider,
GenericResource,
Role,
Permission,
User,
PatchingWindow,
Update,
ReportDefinition,
TimeSeries,
DataPoint,
Action,
ActionAssignment,
UserNote,
}
enum ParameterValueType
{
String,
Number,
Boolean,
SecureString,
}
class ParameterDto implements IConvertible
{
String name = "";
String? description;
/**
* Value in form of a json string (e.g. Number = 1234, String = "foo", Boolean = false). Note: string values need extra quotes
*/
String? value;
/**
* Optional default value for the frontend. Needs to be in the same format as the value
*/
String? Default;
/**
* Optional parameters do not need to have a value. Default -> Optional=false
*/
bool optional;
/**
* The data type of the value and default property
*/
ParameterValueType type;
String? validation;
ParameterDto({this.name,this.description,this.value,this.Default,this.optional,this.type,this.validation});
ParameterDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
name = json['name'];
description = json['description'];
value = json['value'];
Default = json['default'];
optional = json['optional'];
type = JsonConverters.fromJson(json['type'],'ParameterValueType',context!);
validation = json['validation'];
return this;
}
Map<String, dynamic> toJson() => {
'name': name,
'description': description,
'value': value,
'default': Default,
'optional': optional,
'type': JsonConverters.toJson(type,'ParameterValueType',context!),
'validation': validation
};
getTypeName() => "ParameterDto";
TypeContext? context = _ctx;
}
/**
* Adds an action to a config item
*/
// @Api(Description="Adds an action to a config item")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(ActionAssignmentDto), StatusCode=201)
class CreateActionAssignment implements IPost, ISchedulableRequest, IConvertible
{
// @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
// @Validate(Validator="NotEmpty")
String tenantName = "";
/**
* The unique id of the config item
*/
// @ApiMember(DataType="string", Description="The unique id of the config item", Format="guid", IsRequired=true, ParameterType="path")
String configItemId = "";
/**
* The type of the config item (either Deployment, ResourceGroup or Resource)
*/
// @ApiMember(Description="The type of the config item (either Deployment, ResourceGroup or Resource)", IsRequired=true, ParameterType="body")
// @Validate(Validator="NotNull")
ObjectTypes configItemType;
// @ApiMember(DataType="string", Format="guid", IsRequired=true, ParameterType="path")
String actionId = "";
/**
* A unique name for the action
*/
// @ApiMember(DataType="string", Description="A unique name for the action", IsRequired=true, ParameterType="body")
// @Validate(Validator="NotEmpty")
String name = "";
// @ApiMember(DataType="array", ParameterType="body")
List<ParameterDto> parameters = [];
/**
* The cron expression for scheduling the operation
*/
// @ApiMember(DataType="string", Description="The cron expression for scheduling the operation", Format="Cron", ParameterType="body")
String? cronExpression;
/**
* Inform users when the job has finished
*/
// @ApiMember(DataType="bool", Description="Inform users when the job has finished", ParameterType="body")
bool? sendNotifications;
CreateActionAssignment({this.tenantName,this.configItemId,this.configItemType,this.actionId,this.name,this.parameters,this.cronExpression,this.sendNotifications});
CreateActionAssignment.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
tenantName = json['tenantName'];
configItemId = json['configItemId'];
configItemType = JsonConverters.fromJson(json['configItemType'],'ObjectTypes',context!);
actionId = json['actionId'];
name = json['name'];
parameters = JsonConverters.fromJson(json['parameters'],'List<ParameterDto>',context!);
cronExpression = json['cronExpression'];
sendNotifications = json['sendNotifications'];
return this;
}
Map<String, dynamic> toJson() => {
'tenantName': tenantName,
'configItemId': configItemId,
'configItemType': JsonConverters.toJson(configItemType,'ObjectTypes',context!),
'actionId': actionId,
'name': name,
'parameters': JsonConverters.toJson(parameters,'List<ParameterDto>',context!),
'cronExpression': cronExpression,
'sendNotifications': sendNotifications
};
getTypeName() => "CreateActionAssignment";
TypeContext? context = _ctx;
}
class TagDto implements IConvertible
{
String name = "";
String? value;
bool isProtected;
TagDto({this.name,this.value,this.isProtected});
TagDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
name = json['name'];
value = json['value'];
isProtected = json['isProtected'];
return this;
}
Map<String, dynamic> toJson() => {
'name': name,
'value': value,
'isProtected': isProtected
};
getTypeName() => "TagDto";
TypeContext? context = _ctx;
}
class PathItemDto implements IConvertible
{
String label = "";
String link = "";
ObjectTypes objectType;
String objectId = "";
PathItemDto({this.label,this.link,this.objectType,this.objectId});
PathItemDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
label = json['label'];
link = json['link'];
objectType = JsonConverters.fromJson(json['objectType'],'ObjectTypes',context!);
objectId = json['objectId'];
return this;
}
Map<String, dynamic> toJson() => {
'label': label,
'link': link,
'objectType': JsonConverters.toJson(objectType,'ObjectTypes',context!),
'objectId': objectId
};
getTypeName() => "PathItemDto";
TypeContext? context = _ctx;
}
class LinkDto implements IConvertible
{
String caption = "";
String rel = "";
String hRef = "";
String method = "";
LinkDto({this.caption,this.rel,this.hRef,this.method});
LinkDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
caption = json['caption'];
rel = json['rel'];
hRef = json['hRef'];
method = json['method'];
return this;
}
Map<String, dynamic> toJson() => {
'caption': caption,
'rel': rel,
'hRef': hRef,
'method': method
};
getTypeName() => "LinkDto";
TypeContext? context = _ctx;
}
class ConfigItemDto implements IConfigItem, IConvertible
{
String id = "";
String name = "";
String displayName = "";
String? description;
ObjectTypes objectType;
String selfLink = "";
List<TagDto>? tags;
List<PathItemDto>? path;
DateTime created = DateTime(0);
String createUser = "";
String createUserId = "";
DateTime modified = DateTime(0);
String modifyUser = "";
String modifyUserId = "";
bool isDeleted;
DateTime? deleted;
String? deleteUser;
String? deleteUserId;
List<LinkDto>? links;
ConfigItemDto({this.id,this.name,this.displayName,this.description,this.objectType,this.selfLink,this.tags,this.path,this.created,this.createUser,this.createUserId,this.modified,this.modifyUser,this.modifyUserId,this.isDeleted,this.deleted,this.deleteUser,this.deleteUserId,this.links});
ConfigItemDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
displayName = json['displayName'];
description = json['description'];
objectType = JsonConverters.fromJson(json['objectType'],'ObjectTypes',context!);
selfLink = json['selfLink'];
tags = JsonConverters.fromJson(json['tags'],'List<TagDto>',context!);
path = JsonConverters.fromJson(json['path'],'List<PathItemDto>',context!);
created = JsonConverters.fromJson(json['created'],'DateTime',context!);
createUser = json['createUser'];
createUserId = json['createUserId'];
modified = JsonConverters.fromJson(json['modified'],'DateTime',context!);
modifyUser = json['modifyUser'];
modifyUserId = json['modifyUserId'];
isDeleted = json['isDeleted'];
deleted = JsonConverters.fromJson(json['deleted'],'DateTime',context!);
deleteUser = json['deleteUser'];
deleteUserId = json['deleteUserId'];
links = JsonConverters.fromJson(json['links'],'List<LinkDto>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'displayName': displayName,
'description': description,
'objectType': JsonConverters.toJson(objectType,'ObjectTypes',context!),
'selfLink': selfLink,
'tags': JsonConverters.toJson(tags,'List<TagDto>',context!),
'path': JsonConverters.toJson(path,'List<PathItemDto>',context!),
'created': JsonConverters.toJson(created,'DateTime',context!),
'createUser': createUser,
'createUserId': createUserId,
'modified': JsonConverters.toJson(modified,'DateTime',context!),
'modifyUser': modifyUser,
'modifyUserId': modifyUserId,
'isDeleted': isDeleted,
'deleted': JsonConverters.toJson(deleted,'DateTime',context!),
'deleteUser': deleteUser,
'deleteUserId': deleteUserId,
'links': JsonConverters.toJson(links,'List<LinkDto>',context!)
};
getTypeName() => "ConfigItemDto";
TypeContext? context = _ctx;
}
enum ActionScopes
{
Deployment,
ResourceGroup,
Resource,
}
class ActionStepDto implements IConvertible
{
String name = "";
String? displayName;
/**
* The variables which are used in the ansible job
*/
Map<String,dynamic?> variables = {};
/**
* Optional credential to be used in awx (credential stored in awx)
*/
String? credential;
/**
* Ansible limit (optional if Scope is Resource)
*/
String? limit;
/**
* Optional type of the awx action to run (job, workflow, etc.)
*/
String? type;
/**
* Optional ansible module to be used
*/
String? module;
/**
* Optional image for the execution environment which runs the action
*/
String? executionEnvironment;
/**
* Optional inventory
*/
String? inventory;
ActionStepDto({this.name,this.displayName,this.variables,this.credential,this.limit,this.type,this.module,this.executionEnvironment,this.inventory});
ActionStepDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
name = json['name'];
displayName = json['displayName'];
variables = JsonConverters.fromJson(json['variables'],'Map<String,dynamic?>',context!);
credential = json['credential'];
limit = json['limit'];
type = json['type'];
module = json['module'];
executionEnvironment = json['executionEnvironment'];
inventory = json['inventory'];
return this;
}
Map<String, dynamic> toJson() => {
'name': name,
'displayName': displayName,
'variables': JsonConverters.toJson(variables,'Map<String,dynamic?>',context!),
'credential': credential,
'limit': limit,
'type': type,
'module': module,
'executionEnvironment': executionEnvironment,
'inventory': inventory
};
getTypeName() => "ActionStepDto";
TypeContext? context = _ctx;
}
class ActionDto extends ConfigItemDto implements IHasTenantId, IConvertible
{
String tenantId = "";
/**
* The schema version of the attached definition (json/yaml structure)
*/
int schemaVersion = 0;
/**
* The action definition as json/yaml
*/
String? definition;
/**
* Action parameters
*/
List<ParameterDto>? parameters;
/**
* Disabled actions cannot be assigned to a configitem
*/
bool isDisabled;
/**
* This action can anly be assigned to configitems of this type
*/
ActionScopes scope;
/**
* The individual steps of the action
*/
List<ActionStepDto> steps = [];
ActionDto({this.tenantId,this.schemaVersion,this.definition,this.parameters,this.isDisabled,this.scope,this.steps});
ActionDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
tenantId = json['tenantId'];
schemaVersion = json['schemaVersion'];
definition = json['definition'];
parameters = JsonConverters.fromJson(json['parameters'],'List<ParameterDto>',context!);
isDisabled = json['isDisabled'];
scope = JsonConverters.fromJson(json['scope'],'ActionScopes',context!);
steps = JsonConverters.fromJson(json['steps'],'List<ActionStepDto>',context!);
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'tenantId': tenantId,
'schemaVersion': schemaVersion,
'definition': definition,
'parameters': JsonConverters.toJson(parameters,'List<ParameterDto>',context!),
'isDisabled': isDisabled,
'scope': JsonConverters.toJson(scope,'ActionScopes',context!),
'steps': JsonConverters.toJson(steps,'List<ActionStepDto>',context!)
});
getTypeName() => "ActionDto";
TypeContext? context = _ctx;
}
class ScheduledTaskAssignmentDto implements IConvertible
{
String id = "";
String configItemId = "";
ObjectTypes objectType;
String displayName = "";
int taskId = 0;
String taskName = "";
String cronExpression = "";
ScheduledTaskAssignmentDto({this.id,this.configItemId,this.objectType,this.displayName,this.taskId,this.taskName,this.cronExpression});
ScheduledTaskAssignmentDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
configItemId = json['configItemId'];
objectType = JsonConverters.fromJson(json['objectType'],'ObjectTypes',context!);
displayName = json['displayName'];
taskId = json['taskId'];
taskName = json['taskName'];
cronExpression = json['cronExpression'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'configItemId': configItemId,
'objectType': JsonConverters.toJson(objectType,'ObjectTypes',context!),
'displayName': displayName,
'taskId': taskId,
'taskName': taskName,
'cronExpression': cronExpression
};
getTypeName() => "ScheduledTaskAssignmentDto";
TypeContext? context = _ctx;
}
class ActionAssignmentDto implements IConvertible
{
String id = "";
String name = "";
String actionId = "";
ActionDto? action;
String configItemId = "";
String configItemName = "";
ObjectTypes configItemType;
List<ParameterDto> parameters = [];
String selfLink = "";
ActionScopes scope;
String? cronExpression;
List<LinkDto>? links;
String? scheduledTaskAssignmentId;
ScheduledTaskAssignmentDto? scheduledTaskAssignment;
ObjectTypes objectType;
ActionAssignmentDto({this.id,this.name,this.actionId,this.action,this.configItemId,this.configItemName,this.configItemType,this.parameters,this.selfLink,this.scope,this.cronExpression,this.links,this.scheduledTaskAssignmentId,this.scheduledTaskAssignment,this.objectType});
ActionAssignmentDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
actionId = json['actionId'];
action = JsonConverters.fromJson(json['action'],'ActionDto',context!);
configItemId = json['configItemId'];
configItemName = json['configItemName'];
configItemType = JsonConverters.fromJson(json['configItemType'],'ObjectTypes',context!);
parameters = JsonConverters.fromJson(json['parameters'],'List<ParameterDto>',context!);
selfLink = json['selfLink'];
scope = JsonConverters.fromJson(json['scope'],'ActionScopes',context!);
cronExpression = json['cronExpression'];
links = JsonConverters.fromJson(json['links'],'List<LinkDto>',context!);
scheduledTaskAssignmentId = json['scheduledTaskAssignmentId'];
scheduledTaskAssignment = JsonConverters.fromJson(json['scheduledTaskAssignment'],'ScheduledTaskAssignmentDto',context!);
objectType = JsonConverters.fromJson(json['objectType'],'ObjectTypes',context!);
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'actionId': actionId,
'action': JsonConverters.toJson(action,'ActionDto',context!),
'configItemId': configItemId,
'configItemName': configItemName,
'configItemType': JsonConverters.toJson(configItemType,'ObjectTypes',context!),
'parameters': JsonConverters.toJson(parameters,'List<ParameterDto>',context!),
'selfLink': selfLink,
'scope': JsonConverters.toJson(scope,'ActionScopes',context!),
'cronExpression': cronExpression,
'links': JsonConverters.toJson(links,'List<LinkDto>',context!),
'scheduledTaskAssignmentId': scheduledTaskAssignmentId,
'scheduledTaskAssignment': JsonConverters.toJson(scheduledTaskAssignment,'ScheduledTaskAssignmentDto',context!),
'objectType': JsonConverters.toJson(objectType,'ObjectTypes',context!)
};
getTypeName() => "ActionAssignmentDto";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'duneframework.com', types: <String, TypeInfo> {
'ObjectTypes': TypeInfo(TypeOf.Enum, enumValues:ObjectTypes.values),
'ParameterValueType': TypeInfo(TypeOf.Enum, enumValues:ParameterValueType.values),
'ParameterDto': TypeInfo(TypeOf.Class, create:() => ParameterDto()),
'CreateActionAssignment': TypeInfo(TypeOf.Class, create:() => CreateActionAssignment()),
'List<ParameterDto>': TypeInfo(TypeOf.Class, create:() => <ParameterDto>[]),
'TagDto': TypeInfo(TypeOf.Class, create:() => TagDto()),
'PathItemDto': TypeInfo(TypeOf.Class, create:() => PathItemDto()),
'LinkDto': TypeInfo(TypeOf.Class, create:() => LinkDto()),
'ConfigItemDto': TypeInfo(TypeOf.Class, create:() => ConfigItemDto()),
'List<TagDto>': TypeInfo(TypeOf.Class, create:() => <TagDto>[]),
'List<PathItemDto>': TypeInfo(TypeOf.Class, create:() => <PathItemDto>[]),
'List<LinkDto>': TypeInfo(TypeOf.Class, create:() => <LinkDto>[]),
'ActionScopes': TypeInfo(TypeOf.Enum, enumValues:ActionScopes.values),
'ActionStepDto': TypeInfo(TypeOf.Class, create:() => ActionStepDto()),
'Map<String,dynamic?>': TypeInfo(TypeOf.Class, create:() => Map<String,dynamic?>()),
'ActionDto': TypeInfo(TypeOf.Class, create:() => ActionDto()),
'List<ActionStepDto>': TypeInfo(TypeOf.Class, create:() => <ActionStepDto>[]),
'ScheduledTaskAssignmentDto': TypeInfo(TypeOf.Class, create:() => ScheduledTaskAssignmentDto()),
'ActionAssignmentDto': TypeInfo(TypeOf.Class, create:() => ActionAssignmentDto()),
});
Dart CreateActionAssignment DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /api/action-assignments HTTP/1.1
Host: core.starburst.svc
Accept: application/json
Content-Type: application/json
Content-Length: length
{"tenantName":"String","configItemId":"00000000-0000-0000-0000-000000000000","configItemType":"None","actionId":"00000000-0000-0000-0000-000000000000","name":"String","parameters":[{"name":"String","description":"String","value":"String","default":"String","optional":false,"type":"String","validation":"String"}],"cronExpression":"String","sendNotifications":false,"txId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"id":"00000000-0000-0000-0000-000000000000","name":"String","actionId":"00000000-0000-0000-0000-000000000000","action":{"tenantId":"00000000-0000-0000-0000-000000000000","schemaVersion":0,"definition":"String","parameters":null,"isDisabled":false,"scope":"Deployment","steps":[{"name":"String","displayName":"String","variables":{"String":{}},"credential":"String","limit":"String","type":"String","module":"String","executionEnvironment":"String","inventory":"String"}],"id":"00000000-0000-0000-0000-000000000000","name":"String","displayName":"String","description":"String","objectType":"None","selfLink":"String","tags":null,"path":null,"created":"0001-01-01T00:00:00.0000000Z","createUser":"String","createUserId":"String","modified":"0001-01-01T00:00:00.0000000Z","modifyUser":"String","modifyUserId":"String","isDeleted":false,"deleted":"0001-01-01T00:00:00.0000000Z","deleteUser":"String","deleteUserId":"String","links":null},"configItemId":"00000000-0000-0000-0000-000000000000","configItemName":"String","configItemType":"None","parameters":[{"name":"String","description":"String","value":"String","default":"String","optional":false,"type":"String","validation":"String"}],"selfLink":"String","scope":"Deployment","cronExpression":"String","links":[{"caption":"Start","rel":"start","hRef":"/action-assignments/00000000-0000-0000-0000-000000000000/start","method":"POST"},{"caption":"Completed","rel":"completed","hRef":"/action-assignments/00000000-0000-0000-0000-000000000000/completed","method":"PATCH"}],"scheduledTaskAssignmentId":"00000000-0000-0000-0000-000000000000","scheduledTaskAssignment":{"id":"00000000-0000-0000-0000-000000000000","configItemId":"00000000-0000-0000-0000-000000000000","objectType":"None","displayName":"String","taskId":0,"taskName":"String","cronExpression":"String"},"objectType":"ActionAssignment"}