| Required role: | TenantReader |
| All Verbs | /api/actions/{Id} | ||
|---|---|---|---|
| All Verbs | /actions/{Id} |
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
Object = TypeVar('Object')
class ObjectTypes(str, Enum):
NONE = 'None'
CONFIG_ITEM = 'ConfigItem'
TENANT = 'Tenant'
COLLECTION = 'Collection'
RESOURCE = 'Resource'
COMPUTE_NODE = 'ComputeNode'
VIRTUAL_MACHINE = 'VirtualMachine'
PHYSICAL_MACHINE = 'PhysicalMachine'
DISK = 'Disk'
SUBNET = 'Subnet'
IP_ADDRESS = 'IPAddress'
JOB = 'Job'
JOB_EVENT = 'JobEvent'
FREEZE_PERIOD = 'FreezePeriod'
RESOURCE_GROUP = 'ResourceGroup'
DEPLOYMENT = 'Deployment'
RESOURCE_GROUP_TEMPLATE = 'ResourceGroupTemplate'
DEPLOYMENT_TEMPLATE = 'DeploymentTemplate'
RESOURCE_PROVIDER = 'ResourceProvider'
GENERIC_RESOURCE = 'GenericResource'
ROLE = 'Role'
PERMISSION = 'Permission'
USER = 'User'
PATCHING_WINDOW = 'PatchingWindow'
UPDATE = 'Update'
REPORT_DEFINITION = 'ReportDefinition'
TIME_SERIES = 'TimeSeries'
DATA_POINT = 'DataPoint'
ACTION = 'Action'
ACTION_ASSIGNMENT = 'ActionAssignment'
USER_NOTE = 'UserNote'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TagDto:
name: Optional[str] = None
value: Optional[str] = None
is_protected: bool = False
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PathItemDto:
label: Optional[str] = None
link: Optional[str] = None
object_type: Optional[ObjectTypes] = None
object_id: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class LinkDto:
caption: Optional[str] = None
rel: Optional[str] = None
h_ref: Optional[str] = None
method: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ConfigItemDto(IConfigItem):
id: Optional[str] = None
name: Optional[str] = None
display_name: Optional[str] = None
description: Optional[str] = None
object_type: Optional[ObjectTypes] = None
self_link: Optional[str] = None
tags: Optional[IList[TagDto]] = None
path: Optional[IList[PathItemDto]] = None
created: datetime.datetime = datetime.datetime(1, 1, 1)
create_user: Optional[str] = None
create_user_id: Optional[str] = None
modified: datetime.datetime = datetime.datetime(1, 1, 1)
modify_user: Optional[str] = None
modify_user_id: Optional[str] = None
is_deleted: bool = False
deleted: Optional[datetime.datetime] = None
delete_user: Optional[str] = None
delete_user_id: Optional[str] = None
links: Optional[IList[LinkDto]] = None
class ParameterValueType(str, Enum):
STRING = 'String'
NUMBER = 'Number'
BOOLEAN = 'Boolean'
SECURE_STRING = 'SecureString'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ParameterDto:
name: Optional[str] = None
description: Optional[str] = None
value: Optional[str] = None
"""
Value in form of a json string (e.g. Number = 1234, String = "foo", Boolean = false). Note: string values need extra quotes
"""
default: Optional[str] = None
"""
Optional default value for the frontend. Needs to be in the same format as the value
"""
optional: bool = False
"""
Optional parameters do not need to have a value. Default -> Optional=false
"""
type: Optional[ParameterValueType] = None
"""
The data type of the value and default property
"""
validation: Optional[str] = None
class ActionScopes(str, Enum):
DEPLOYMENT = 'Deployment'
RESOURCE_GROUP = 'ResourceGroup'
RESOURCE = 'Resource'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ActionStepDto:
name: Optional[str] = None
display_name: Optional[str] = None
variables: Dict[str, Object] = field(default_factory=dict)
"""
The variables which are used in the ansible job
"""
credential: Optional[str] = None
"""
Optional credential to be used in awx (credential stored in awx)
"""
limit: Optional[str] = None
"""
Ansible limit (optional if Scope is Resource)
"""
type: Optional[str] = None
"""
Optional type of the awx action to run (job, workflow, etc.)
"""
module: Optional[str] = None
"""
Optional ansible module to be used
"""
execution_environment: Optional[str] = None
"""
Optional image for the execution environment which runs the action
"""
inventory: Optional[str] = None
"""
Optional inventory
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ActionDto(ConfigItemDto, IHasTenantId):
tenant_id: Optional[str] = None
schema_version: int = 0
"""
The schema version of the attached definition (json/yaml structure)
"""
definition: Optional[str] = None
"""
The action definition as json/yaml
"""
parameters: Optional[IList[ParameterDto]] = None
"""
Action parameters
"""
is_disabled: bool = False
"""
Disabled actions cannot be assigned to a configitem
"""
scope: Optional[ActionScopes] = None
"""
This action can anly be assigned to configitems of this type
"""
steps: List[ActionStepDto] = field(default_factory=list)
"""
The individual steps of the action
"""
# @Api(Description="Returns an action by its id")
# @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(ActionDto), StatusCode=200)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class GetAction(IGetSingleRequest, IHasTenantName, IGet):
"""
Returns an action by its id
"""
# @ApiMember(DataType="string", Format="guid", IsRequired=true, ParameterType="path")
id: Optional[str] = None
# @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
# @Validate(Validator="NotEmpty")
tenant_name: Optional[str] = None
# @ApiMember(ParameterType="query", Verb="GET")
include_referenced_objects: Optional[bool] = None
# @ApiMember(Description="If true, also soft deleted items will be returned", ParameterType="query")
include_deleted: Optional[bool] = None
"""
If true, also soft deleted items will be returned
"""
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/actions/{Id} HTTP/1.1
Host: core.starburst.svc
Accept: application/json
Content-Type: application/json
Content-Length: length
{"id":"00000000-0000-0000-0000-000000000000","tenantName":"String","includeReferencedObjects":false,"includeDeleted":false,"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}