| Required role: | TenantReader |
| POST | /api/action-assignments | Assigns an action to a config item | |
|---|---|---|---|
| POST | /action-assignments | Assigns an action to a config item |
Imports System
Imports System.IO
Imports System.Collections
Imports System.Collections.Generic
Imports System.Runtime.Serialization
Imports ServiceStack
Imports ServiceStack.DataAnnotations
Imports CoreService.ServiceModel.Dtos.ActionAssignments.Crud
Imports YCO.Dune.Models.Enums
Imports CoreService.ServiceModel.Dtos.Base.Responses
Imports CoreService.ServiceModel.Enums
Imports CoreService.ServiceModel.Dtos.ActionAssignments.Responses
Imports CoreService.ServiceModel.Dtos.Actions.Responses
Namespace Global
Namespace CoreService.ServiceModel.Dtos.ActionAssignments.Crud
'''<Summary>
'''Adds an action to a config item
'''</Summary>
<Api(Description:="Adds an action to a config item")>
<ApiResponse(Description:="Success", IsDefaultResponse:=true, ResponseType:=GetType(ActionAssignmentDto), StatusCode:=201)>
Public Partial Class CreateActionAssignment
Implements IPost
Implements ISchedulableRequest
<ApiMember(DataType:="string", IsRequired:=true, ParameterType:="header")>
<Validate(Validator:="NotEmpty")>
Public Overridable Property TenantName As String
'''<Summary>
'''The unique id of the config item
'''</Summary>
<ApiMember(DataType:="string", Description:="The unique id of the config item", Format:="guid", IsRequired:=true, ParameterType:="path")>
Public Overridable Property ConfigItemId As Guid
'''<Summary>
'''The type of the config item (either Deployment, ResourceGroup or Resource)
'''</Summary>
<ApiMember(Description:="The type of the config item (either Deployment, ResourceGroup or Resource)", IsRequired:=true, ParameterType:="body")>
<Validate(Validator:="NotNull")>
Public Overridable Property ConfigItemType As ObjectTypes
<ApiMember(DataType:="string", Format:="guid", IsRequired:=true, ParameterType:="path")>
Public Overridable Property ActionId As Guid
'''<Summary>
'''A unique name for the action
'''</Summary>
<ApiMember(DataType:="string", Description:="A unique name for the action", IsRequired:=true, ParameterType:="body")>
<Validate(Validator:="NotEmpty")>
Public Overridable Property Name As String
<ApiMember(DataType:="array", ParameterType:="body")>
Public Overridable Property Parameters As List(Of ParameterDto) = New List(Of ParameterDto)
'''<Summary>
'''The cron expression for scheduling the operation
'''</Summary>
<ApiMember(DataType:="string", Description:="The cron expression for scheduling the operation", Format:="Cron", ParameterType:="body")>
Public Overridable Property CronExpression As String Implements ISchedulableRequest.CronExpression
'''<Summary>
'''Inform users when the job has finished
'''</Summary>
<ApiMember(DataType:="bool", Description:="Inform users when the job has finished", ParameterType:="body")>
Public Overridable Property SendNotifications As Boolean?
End Class
End Namespace
Namespace CoreService.ServiceModel.Dtos.ActionAssignments.Responses
Public Partial Class ActionAssignmentDto
Public Overridable Property Id As Guid
Public Overridable Property Name As String
Public Overridable Property ActionId As Guid
Public Overridable Property Action As ActionDto
Public Overridable Property ConfigItemId As Guid
Public Overridable Property ConfigItemName As String
Public Overridable Property ConfigItemType As ObjectTypes
Public Overridable Property Parameters As List(Of ParameterDto) = New List(Of ParameterDto)
Public Overridable Property SelfLink As String
Public Overridable Property Scope As ActionScopes
Public Overridable Property CronExpression As String
Public Overridable Property Links As IList(Of LinkDto)
Public Overridable Property ScheduledTaskAssignmentId As Guid?
Public Overridable Property ScheduledTaskAssignment As ScheduledTaskAssignmentDto
Public Overridable Property ObjectType As ObjectTypes
End Class
End Namespace
Namespace CoreService.ServiceModel.Dtos.Actions.Responses
Public Partial Class ActionDto
Inherits ConfigItemDto
Implements IHasTenantId
Public Overridable Property TenantId As Guid Implements IHasTenantId.TenantId
'''<Summary>
'''The schema version of the attached definition (json/yaml structure)
'''</Summary>
Public Overridable Property SchemaVersion As Integer
'''<Summary>
'''The action definition as json/yaml
'''</Summary>
Public Overridable Property Definition As String
'''<Summary>
'''Action parameters
'''</Summary>
Public Overridable Property Parameters As IList(Of ParameterDto)
'''<Summary>
'''Disabled actions cannot be assigned to a configitem
'''</Summary>
Public Overridable Property IsDisabled As Boolean
'''<Summary>
'''This action can anly be assigned to configitems of this type
'''</Summary>
Public Overridable Property Scope As ActionScopes
'''<Summary>
'''The individual steps of the action
'''</Summary>
Public Overridable Property Steps As List(Of ActionStepDto) = New List(Of ActionStepDto)
End Class
Public Partial Class ActionStepDto
Public Overridable Property Name As String
Public Overridable Property DisplayName As String
'''<Summary>
'''The variables which are used in the ansible job
'''</Summary>
Public Overridable Property Variables As Dictionary(Of String, Object) = New Dictionary(Of String, Object)
'''<Summary>
'''Optional credential to be used in awx (credential stored in awx)
'''</Summary>
Public Overridable Property Credential As String
'''<Summary>
'''Ansible limit (optional if Scope is Resource)
'''</Summary>
Public Overridable Property Limit As String
'''<Summary>
'''Optional type of the awx action to run (job, workflow, etc.)
'''</Summary>
Public Overridable Property Type As String
'''<Summary>
'''Optional ansible module to be used
'''</Summary>
Public Overridable Property [Module] As String
'''<Summary>
'''Optional image for the execution environment which runs the action
'''</Summary>
Public Overridable Property ExecutionEnvironment As String
'''<Summary>
'''Optional inventory
'''</Summary>
Public Overridable Property Inventory As String
End Class
End Namespace
Namespace CoreService.ServiceModel.Dtos.Base.Responses
Public Partial Class ConfigItemDto
Implements IConfigItem
Public Overridable Property Id As Guid
Public Overridable Property Name As String
Public Overridable Property DisplayName As String Implements IConfigItem.DisplayName
Public Overridable Property Description As String Implements IConfigItem.Description
Public Overridable Property ObjectType As ObjectTypes
Public Overridable Property SelfLink As String Implements IConfigItem.SelfLink
Public Overridable Property Tags As IList(Of TagDto) Implements IConfigItem.Tags
Public Overridable Property Path As IList(Of PathItemDto)
Public Overridable Property Created As Date
Public Overridable Property CreateUser As String
Public Overridable Property CreateUserId As String
Public Overridable Property Modified As Date
Public Overridable Property ModifyUser As String
Public Overridable Property ModifyUserId As String
Public Overridable Property IsDeleted As Boolean
Public Overridable Property Deleted As Date?
Public Overridable Property DeleteUser As String
Public Overridable Property DeleteUserId As String
Public Overridable Property Links As IList(Of LinkDto)
End Class
Public Partial Class LinkDto
Public Overridable Property Caption As String
Public Overridable Property Rel As String
Public Overridable Property HRef As String
Public Overridable Property Method As String
End Class
Public Partial Class ParameterDto
Public Overridable Property Name As String
Public Overridable Property Description As String
'''<Summary>
'''Value in form of a json string (e.g. Number = 1234, String = "foo", Boolean = false). Note: string values need extra quotes
'''</Summary>
Public Overridable Property Value As String
'''<Summary>
'''Optional default value for the frontend. Needs to be in the same format as the value
'''</Summary>
Public Overridable Property [Default] As String
'''<Summary>
'''Optional parameters do not need to have a value. Default -> Optional=false
'''</Summary>
Public Overridable Property [Optional] As Boolean
'''<Summary>
'''The data type of the value and default property
'''</Summary>
Public Overridable Property Type As ParameterValueType
Public Overridable Property Validation As String
End Class
Public Partial Class PathItemDto
Public Overridable Property Label As String
Public Overridable Property Link As String
Public Overridable Property ObjectType As ObjectTypes
Public Overridable Property ObjectId As Guid
End Class
Public Partial Class ScheduledTaskAssignmentDto
Public Overridable Property Id As Guid
Public Overridable Property ConfigItemId As Guid
Public Overridable Property ObjectType As ObjectTypes
Public Overridable Property DisplayName As String
Public Overridable Property TaskId As Long
Public Overridable Property TaskName As String
Public Overridable Property CronExpression As String
End Class
Public Partial Class TagDto
Public Overridable Property Name As String
Public Overridable Property Value As String
Public Overridable Property IsProtected As Boolean
End Class
End Namespace
Namespace CoreService.ServiceModel.Enums
Public Enum ActionScopes
Deployment
ResourceGroup
Resource
End Enum
Public Enum ParameterValueType
[String]
Number
[Boolean]
SecureString
End Enum
End Namespace
Namespace YCO.Dune.Models.Enums
Public 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
End Enum
End Namespace
End Namespace
VB.NET 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"}