CoreService

<back to all web services

CreateAction

Action - CRUD

Create a new action

Requires Authentication
Required role:TenantReader
The following routes are available for this service:
POST/api/actions/Create a new action
POST/actions/Create a new action
namespace CoreService.ServiceModel.Dtos.Actions.Crud

open System
open System.IO
open System.Collections
open System.Collections.Generic
open System.Runtime.Serialization
open ServiceStack
open ServiceStack.DataAnnotations

    type ObjectTypes =
        | None = 0
        | ConfigItem = 1
        | Tenant = 2
        | Collection = 3
        | Resource = 4
        | ComputeNode = 5
        | VirtualMachine = 6
        | PhysicalMachine = 7
        | Disk = 8
        | Subnet = 9
        | IPAddress = 10
        | Job = 11
        | JobEvent = 12
        | FreezePeriod = 13
        | ResourceGroup = 14
        | Deployment = 15
        | ResourceGroupTemplate = 16
        | DeploymentTemplate = 17
        | ResourceProvider = 18
        | GenericResource = 19
        | Role = 20
        | Permission = 21
        | User = 22
        | PatchingWindow = 23
        | Update = 24
        | ReportDefinition = 25
        | TimeSeries = 26
        | DataPoint = 27
        | Action = 28
        | ActionAssignment = 29
        | UserNote = 30

    [<AllowNullLiteral>]
    type TagDto() = 
        member val Name:String = null with get,set
        member val Value:String = null with get,set
        member val IsProtected:Boolean = new Boolean() with get,set

    [<AllowNullLiteral>]
    type PathItemDto() = 
        member val Label:String = null with get,set
        member val Link:String = null with get,set
        member val ObjectType:ObjectTypes = new ObjectTypes() with get,set
        member val ObjectId:Guid = new Guid() with get,set

    [<AllowNullLiteral>]
    type LinkDto() = 
        member val Caption:String = null with get,set
        member val Rel:String = null with get,set
        member val HRef:String = null with get,set
        member val Method:String = null with get,set

    [<AllowNullLiteral>]
    type ConfigItemDto() = 
        member val Id:Guid = new Guid() with get,set
        member val Name:String = null with get,set
        member val DisplayName:String = null with get,set
        member val Description:String = null with get,set
        member val ObjectType:ObjectTypes = new ObjectTypes() with get,set
        member val SelfLink:String = null with get,set
        member val Tags:IList<TagDto> = null with get,set
        member val Path:IList<PathItemDto> = null with get,set
        member val Created:DateTime = new DateTime() with get,set
        member val CreateUser:String = null with get,set
        member val CreateUserId:String = null with get,set
        member val Modified:DateTime = new DateTime() with get,set
        member val ModifyUser:String = null with get,set
        member val ModifyUserId:String = null with get,set
        member val IsDeleted:Boolean = new Boolean() with get,set
        member val Deleted:Nullable<DateTime> = new Nullable<DateTime>() with get,set
        member val DeleteUser:String = null with get,set
        member val DeleteUserId:String = null with get,set
        member val Links:IList<LinkDto> = null with get,set

    type ParameterValueType =
        | String = 0
        | Number = 1
        | Boolean = 2
        | SecureString = 3

    [<AllowNullLiteral>]
    type ParameterDto() = 
        member val Name:String = null with get,set
        member val Description:String = null with get,set
        ///<summary>
        ///Value in form of a json string (e.g. Number = 1234, String = "foo", Boolean = false). Note: string values need extra quotes
        ///</summary>
        member val Value:String = null with get,set

        ///<summary>
        ///Optional default value for the frontend. Needs to be in the same format as the value
        ///</summary>
        member val Default:String = null with get,set

        ///<summary>
        ///Optional parameters do not need to have a value. Default -> Optional=false
        ///</summary>
        member val Optional:Boolean = new Boolean() with get,set

        ///<summary>
        ///The data type of the value and default property
        ///</summary>
        member val Type:ParameterValueType = new ParameterValueType() with get,set

        member val Validation:String = null with get,set

    type ActionScopes =
        | Deployment = 0
        | ResourceGroup = 1
        | Resource = 2

    [<AllowNullLiteral>]
    type ActionStepDto() = 
        member val Name:String = null with get,set
        member val DisplayName:String = null with get,set
        ///<summary>
        ///The variables which are used in the ansible job
        ///</summary>
        member val Variables:Dictionary<String, Object> = null with get,set

        ///<summary>
        ///Optional credential to be used in awx (credential stored in awx)
        ///</summary>
        member val Credential:String = null with get,set

        ///<summary>
        ///Ansible limit (optional if Scope is Resource)
        ///</summary>
        member val Limit:String = null with get,set

        ///<summary>
        ///Optional type of the awx action to run (job, workflow, etc.)
        ///</summary>
        member val Type:String = null with get,set

        ///<summary>
        ///Optional ansible module to be used
        ///</summary>
        member val Module:String = null with get,set

        ///<summary>
        ///Optional image for the execution environment which runs the action
        ///</summary>
        member val ExecutionEnvironment:String = null with get,set

        ///<summary>
        ///Optional inventory
        ///</summary>
        member val Inventory:String = null with get,set

    [<AllowNullLiteral>]
    type ActionDto() = 
        inherit ConfigItemDto()
        member val TenantId:Guid = new Guid() with get,set
        ///<summary>
        ///The schema version of the attached definition (json/yaml structure)
        ///</summary>
        member val SchemaVersion:Int32 = new Int32() with get,set

        ///<summary>
        ///The action definition as json/yaml
        ///</summary>
        member val Definition:String = null with get,set

        ///<summary>
        ///Action parameters
        ///</summary>
        member val Parameters:IList<ParameterDto> = null with get,set

        ///<summary>
        ///Disabled actions cannot be assigned to a configitem
        ///</summary>
        member val IsDisabled:Boolean = new Boolean() with get,set

        ///<summary>
        ///This action can anly be assigned to configitems of this type
        ///</summary>
        member val Scope:ActionScopes = new ActionScopes() with get,set

        ///<summary>
        ///The individual steps of the action
        ///</summary>
        member val Steps:ResizeArray<ActionStepDto> = null with get,set

    ///<summary>
    ///Create a new action
    ///</summary>
    [<Api(Description="Create a new action")>]
    [<ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof<ActionDto>, StatusCode=201)>]
    [<AllowNullLiteral>]
    type CreateAction() = 
        interface IPost
        [<ApiMember(DataType="string", IsRequired=true, ParameterType="header")>]
        [<Validate(Validator="NotEmpty")>]
        member val TenantName:String = null with get,set

        ///<summary>
        ///The version of the action structure
        ///</summary>
        [<ApiMember(DataType="integer", Description="The version of the action structure", IsRequired=true, ParameterType="body")>]
        [<Validate(Validator="GreaterThan(0)")>]
        member val SchemaVersion:Int32 = new Int32() with get,set

        ///<summary>
        ///The definition of the action (YAML)
        ///</summary>
        [<ApiMember(DataType="string", Description="The definition of the action (YAML)", Format="yaml", IsRequired=true, ParameterType="body")>]
        [<Validate(Validator="NotEmpty")>]
        member val Definition:String = null with get,set

F# CreateAction 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

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /api/actions/ HTTP/1.1 
Host: core.starburst.svc 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"tenantName":"String","schemaVersion":0,"definition":"String","txId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"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}