| Required role: | TenantReader |
| GET | /api/subnets/{Id} | returns a subnet by its id | |
|---|---|---|---|
| GET | /subnets/{Id} | returns a subnet by its 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 OperationalStates(str, Enum):
NONE = 'None'
STARTING = 'Starting'
RUNNING = 'Running'
STOPPING = 'Stopping'
STOPPED = 'Stopped'
RESTARTING = 'Restarting'
DELETING = 'Deleting'
UNKNOWN = 'Unknown'
class LifecycleStates(str, Enum):
NEW = 'New'
DEPLOYING = 'Deploying'
DEPLOYED = 'Deployed'
REMOVING = 'Removing'
REMOVED = 'Removed'
FAILURE = 'Failure'
IMPORTED = 'Imported'
class Environments(str, Enum):
LAB = 'Lab'
POC = 'Poc'
DEV = 'Dev'
TEST = 'Test'
INT_ = 'Int'
UAT = 'Uat'
PROD = 'Prod'
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 ValueDataType(str, Enum):
STRING = 'String'
NUMBER = 'Number'
BOOLEAN = 'Boolean'
LIST = 'List'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class VariableDto:
name: Optional[str] = None
value: Optional[str] = None
"""
Value in form of a json string (e.g. Number = 1234, String = "foo", Boolean = false, List = [1,2,3,4]). Note: string values need extra quotes
"""
type: Optional[ValueDataType] = None
"""
The data type of the value property
"""
description: Optional[str] = None
is_inherited: bool = False
environment: Optional[Environments] = None
class ResourceCompositions(str, Enum):
NATIVE = 'Native'
FOREIGN = 'Foreign'
MIXED = 'Mixed'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DeploymentDto(ConfigItemDto, IHasParentDto, IHasTenantId, IEnvironmentSpecific):
operational_state: Optional[OperationalStates] = None
"""
The operational state of the deployment (Running, Stopped, None, Unknown)
"""
resources_running: int = 0
"""
How many start/stop-capable resources are currently running
"""
resources_total: int = 0
"""
Total number of start/stop-capable resources in this deployment
"""
short_id: Optional[str] = None
"""
Shorter id than the guid which can be used for automation (tenant wide unique) prefixed with a 'd'. E.g. dr36x3
"""
name_user_defined_part: Optional[str] = None
"""
The user defined part of the name property {userDefined}_{environment}
"""
tenant_id: Optional[str] = None
"""
The id of the tenant
"""
state: Optional[LifecycleStates] = None
"""
The state of the deployment
"""
environment: Optional[Environments] = None
"""
The environment the deployment is deployed in
"""
template_id: Optional[str] = None
"""
The id of the template which was used to create the deployment
"""
is_template_based: bool = False
"""
Shows if a deployment was rolled out through a dune template or not
"""
parameters: Optional[IList[ParameterDto]] = None
"""
The parameters which were used to create this deployment
"""
variables: Optional[IList[VariableDto]] = None
"""
A deployment scoped list of variables used for deployment of resources
"""
variables_snapshot: Optional[IList[VariableDto]] = None
"""
A snapshot of the varialbs used to create the deployment
"""
parent_id: Optional[str] = None
"""
The id of the parent (collection) of the deployment
"""
parent: Optional[ConfigItemDto] = None
"""
The parent (collection) of the deployment
"""
valid_from: datetime.datetime = datetime.datetime(1, 1, 1)
"""
The Date when the resources got deployed
"""
valid_until: Optional[datetime.datetime] = None
"""
The Date when the deployment expires and has to be reevaluated
"""
is_never_expiring: bool = False
"""
The deployment will never expire
"""
next_patch_date: Optional[datetime.datetime] = None
"""
The date, when the deployments resources will receive updates
"""
default_resource_provider_id: Optional[str] = None
"""
The default resource provider where the resources are deployed
"""
needs_attention: bool = False
"""
Deployments which have issues in Jobs are marked with NeedsAttention
"""
composition: Optional[ResourceCompositions] = None
"""
Composition show if all resources in the deployment are dune native, dune foreign or a mix of both
"""
monthly_budget: Optional[Decimal] = None
"""
The monthly cost budget for the whole collection
"""
send_budget_notification_mails: Optional[bool] = None
"""
Whether to send budget information mails to the collection owners
"""
budget_warning_threshold_percent: Optional[int] = None
"""
A threshold, when to send the first budget warning mail
"""
links: Optional[IList[LinkDto]] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TenantDto(ConfigItemDto):
variables: Optional[IList[VariableDto]] = None
"""
Variables defined on tenant level
"""
allowed_mail_domains: Optional[IList[str]] = None
"""
Allowed email domains used for authentication
"""
licensed_modules: Optional[IList[str]] = None
"""
List of licensed modules for this tenant
"""
default_deployment_lifetime_days: int = 0
"""
Amount of days until a Deployment expires
"""
max_deployment_lifetime_days: int = 0
"""
Max amount of days until a Deployment expires
"""
system_unpatched_warning_days: int = 0
"""
Amount of days without patching until a unpatched warning is shown
"""
system_backup_missing_warning_hours: int = 0
"""
Amount of hours without backup until a backup missing warning is shown
"""
stop_vulnerable_resource_after_days: int = 0
"""
Amount of days until a vulnerable resource is getting stopped
"""
deployment_expiration_warning_days: int = 0
"""
Amount of days before deployment expiration, which triggers the expiration warning
"""
patch_notification_days: int = 0
"""
Amount of days the patch notification is sent out prior to the patch date
"""
use_custom_hostnames: bool = False
"""
Use a pool with your own hostnames (true) or let the hostname be auto generated (false)
"""
remove_inactive_vulnerabilities_after_days: int = 0
"""
After how many days inactive vulnerabilities will be purged from database
"""
links: Optional[IList[LinkDto]] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DeploymentCollectionDto(ConfigItemDto, IHasTenantId):
tenant_id: Optional[str] = None
tenant: Optional[TenantDto] = None
variables: Optional[IList[VariableDto]] = None
"""
A collection scoped list of variables
"""
is_lost_and_found: bool = False
"""
Defines the collection where scanned but not deployed resources will be stored
"""
monthly_budget: Optional[Decimal] = None
"""
The monthly cost budget for the whole collection
"""
send_budget_notification_mails: Optional[bool] = None
"""
Whether to send budget information mails to the collection owners
"""
budget_warning_threshold_percent: Optional[int] = None
"""
A threshold, when to send the first budget warning mail
"""
links: Optional[IList[LinkDto]] = None
class ResourceProviderTypes(str, Enum):
AZURE = 'Azure'
AMAZON_WEB_SERVICES = 'AmazonWebServices'
GOOGLE_CLOUD_PLATFORM = 'GoogleCloudPlatform'
ACTIVE_DIRECTORY_SERVICES = 'ActiveDirectoryServices'
DOMAIN_NAME_SYSTEM = 'DomainNameSystem'
SWISSCOM_E_S_C = 'SwisscomESC'
AZURE_KEY_VAULT = 'AzureKeyVault'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ProviderConfigEntryDto:
name: Optional[str] = None
value: Optional[str] = None
is_secure: bool = False
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ResourceProviderDto(ConfigItemDto, IHasTenantId):
tenant_id: Optional[str] = None
default_environment: Optional[Environments] = None
"""
If environment cannot be detected while scanning, default environment will be used
"""
allowed_environments: Optional[IList[Environments]] = None
"""
List off all allowed environments for this resource provider
"""
type: Optional[ResourceProviderTypes] = None
"""
Defines the provider type (e.g. Azure, Aws)
"""
config: Optional[IList[ProviderConfigEntryDto]] = None
"""
Additional generic data which varies depending on ProviderType
"""
is_disabled: bool = False
"""
Disabled ResourceProviders cannot be selected for new deployments
"""
is_ready_for_deployments: bool = False
"""
Shows if a ResourceProvider has been initialized and can accept deployments (resources)
"""
cost_current_month: Decimal = decimal.Decimal(0)
"""
The cost for the current month
"""
cost_last_month: Decimal = decimal.Decimal(0)
"""
The cost for the last month
"""
cost_currency: Optional[str] = None
"""
The cost currency
"""
class IpVersion(str, Enum):
V4 = 'V4'
V6 = 'V6'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class SubnetDto(ConfigItemDto, IResourceDto):
tenant_id: Optional[str] = None
ext_id: Optional[str] = None
ext_type: Optional[str] = None
ext_name: Optional[str] = None
parent_id: Optional[str] = None
"""
The id of the parent (ResourceGroup)
"""
parent: Optional[ConfigItemDto] = None
"""
The parent (ResourceGroup
"""
deployment_id: Optional[str] = None
"""
The id of the parent (Deployment
"""
deployment: Optional[DeploymentDto] = None
"""
The parent (Deployement
"""
collection_id: Optional[str] = None
"""
The id of the collection the resource belongs to
"""
collection: Optional[DeploymentCollectionDto] = None
"""
The collection the resource belongs to
"""
environment: Optional[Environments] = None
resource_provider_id: Optional[str] = None
"""
The id of the provider of the resource (e.g. Azure Subscription, AWS, other DC provider
"""
resource_provider: Optional[ResourceProviderDto] = None
"""
The provider of the resource (e.g. Azure Subscription, AWS, other DC provider
"""
state: Optional[OperationalStates] = None
variables: Optional[IList[VariableDto]] = None
location: Optional[str] = None
"""
Can be used for dc location
"""
last_seen: Optional[datetime.datetime] = None
"""
Last time the resource was seen/updated by a scan/cfgmgmt run etc.
"""
is_foreign: bool = False
"""
True = scanned (not deployed from dune template), False = deployed from dune with template
"""
network_address: Optional[str] = None
"""
Either a V4 or V6 address (network address)
"""
subnet_bits: int = 0
"""
Bits defining the subnet mask (together with NetworkAddress it defines the subnet range)
"""
cidr: Optional[str] = None
"""
NetworkAddress and subnet bits
"""
version: Optional[IpVersion] = None
"""
Either V4 or V6
"""
config: Dict[str, Object] = field(default_factory=dict)
"""
Can hold additional generic data
"""
is_alerting: bool = False
"""
Is alerting in external monitoring activated
"""
alerting_disabled_id: Optional[str] = None
"""
Used to identify external monitoring maintenance/downtime id
"""
alerting_disabled_reason: Optional[str] = None
"""
Reason why alerting is disabled
"""
is_vulnerable: bool = False
"""
Identifies the resource as vulnerable (security)
"""
vulnerability_reason: Optional[str] = None
"""
Reason why the resource is vulnerable
"""
is_missing_on_provider: bool = False
"""
True if resource is in cmdb but missing on provider/infra
"""
supports_start_stop: bool = False
"""
Shows if a resource can be started/stopped
"""
links: Optional[IList[LinkDto]] = None
cost_current_month: Decimal = decimal.Decimal(0)
"""
The cost for the current month
"""
cost_last_month: Decimal = decimal.Decimal(0)
"""
The cost for the last month
"""
cost_currency: Optional[str] = None
"""
The cost currency
"""
# @Api(Description="Get a subnet")
# @ApiResponse(Description="The request ended successfully", IsDefaultResponse=true, ResponseType=typeof(SubnetDto), StatusCode=200)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class GetSubnet(IGetSingleRequest, IHasTenantName, IGet):
"""
Get a subnet
"""
# @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(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
"""
# @ApiMember(ParameterType="query", Verb="GET")
include_referenced_objects: Optional[bool] = None
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.
GET /api/subnets/{Id} HTTP/1.1
Host: core.starburst.svc
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"tenantId":"00000000-0000-0000-0000-000000000000","extId":"String","extType":"String","extName":"String","parentId":"00000000-0000-0000-0000-000000000000","parent":{"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},"deploymentId":"00000000-0000-0000-0000-000000000000","deployment":{"operationalState":"None","resourcesRunning":0,"resourcesTotal":0,"shortId":"String","nameUserDefinedPart":"String","tenantId":"00000000-0000-0000-0000-000000000000","state":"New","environment":"Lab","templateId":"00000000-0000-0000-0000-000000000000","isTemplateBased":true,"parameters":null,"variables":null,"variablesSnapshot":null,"parentId":"00000000-0000-0000-0000-000000000000","parent":{"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},"validFrom":"0001-01-01T00:00:00.0000000Z","validUntil":"0001-01-01T00:00:00.0000000Z","isNeverExpiring":false,"nextPatchDate":"0001-01-01T00:00:00.0000000Z","defaultResourceProviderId":"00000000-0000-0000-0000-000000000000","needsAttention":false,"composition":"Native","monthlyBudget":0,"sendBudgetNotificationMails":false,"budgetWarningThresholdPercent":0,"links":[{"caption":"Index","rel":"index","hRef":"/deployments/","method":"GET"},{"caption":"Collection","rel":"up","hRef":"/collections/00000000-0000-0000-0000-000000000000","method":"GET"},{"caption":"Resourcegroups","rel":"down","hRef":"/resourcegroups?parentId=00000000-0000-0000-0000-000000000000","method":"GET"}],"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"},"collectionId":"00000000-0000-0000-0000-000000000000","collection":{"tenantId":"00000000-0000-0000-0000-000000000000","tenant":{"variables":null,"allowedMailDomains":null,"licensedModules":null,"defaultDeploymentLifetimeDays":0,"maxDeploymentLifetimeDays":0,"systemUnpatchedWarningDays":0,"systemBackupMissingWarningHours":0,"stopVulnerableResourceAfterDays":0,"deploymentExpirationWarningDays":0,"patchNotificationDays":0,"useCustomHostnames":false,"removeInactiveVulnerabilitiesAfterDays":0,"links":[{"caption":"Collections","rel":"down","hRef":"/collections/","method":"GET"}],"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"},"variables":null,"isLostAndFound":false,"monthlyBudget":0,"sendBudgetNotificationMails":false,"budgetWarningThresholdPercent":0,"links":[{"caption":"Index","rel":"up","hRef":"/collections/","method":"GET"},{"caption":"Deployments","rel":"down","hRef":"/deployments?parentId=00000000-0000-0000-0000-000000000000","method":"GET"}],"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"},"environment":"Lab","resourceProviderId":"00000000-0000-0000-0000-000000000000","resourceProvider":{"tenantId":"00000000-0000-0000-0000-000000000000","defaultEnvironment":"Lab","allowedEnvironments":null,"type":"Azure","config":null,"isDisabled":false,"isReadyForDeployments":false,"costCurrentMonth":0,"costLastMonth":0,"costCurrency":"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},"state":"None","variables":null,"location":"String","lastSeen":"0001-01-01T00:00:00.0000000Z","isForeign":false,"networkAddress":"String","subnetBits":0,"cidr":"String/0","version":"V4","config":{"String":{}},"isAlerting":false,"alertingDisabledId":"String","alertingDisabledReason":"String","isVulnerable":false,"vulnerabilityReason":"String","isMissingOnProvider":false,"supportsStartStop":false,"links":[{"caption":"Index","rel":"index","hRef":"/subnets/","method":"GET"},{"caption":"ResourceGroup","rel":"up","hRef":"/resourcegroups/00000000-0000-0000-0000-000000000000","method":"GET"},{"caption":"Deployment","rel":"up","hRef":"/deployments/00000000-0000-0000-0000-000000000000","method":"GET"}],"costCurrentMonth":0,"costLastMonth":0,"costCurrency":"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"}