| Required role: | TenantReader |
| GET | /api/tenants/ | Returns a specific tenant | |
|---|---|---|---|
| GET | /tenants/ | Returns a specific tenant |
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 ValueDataType(str, Enum):
STRING = 'String'
NUMBER = 'Number'
BOOLEAN = 'Boolean'
LIST = 'List'
class Environments(str, Enum):
LAB = 'Lab'
POC = 'Poc'
DEV = 'Dev'
TEST = 'Test'
INT_ = 'Int'
UAT = 'Uat'
PROD = 'Prod'
@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
@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
# @Api(Description="Returns a single tenant")
# @ApiResponse(Description="The tenant", IsDefaultResponse=true, ResponseType=typeof(TenantDto), StatusCode=200)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class GetTenant(IGetSingleRequest, IHasTenantName, IGet):
"""
Returns a single tenant
"""
# @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(ParameterType="query", Verb="GET")
include_deleted: 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/tenants/ HTTP/1.1 Host: core.starburst.svc Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"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"}