Best Python code snippet using localstack_python
configuration_recorder.py
Source:configuration_recorder.py
...31 def enterprise_edition(self, value: Optional[pulumi.Input[bool]]):32 pulumi.set(self, "enterprise_edition", value)33 @property34 @pulumi.getter(name="resourceTypes")35 def resource_types(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:36 """37 A list of resource types to be monitored. [Resource types that support Cloud Config.](https://www.alibabacloud.com/help/en/doc-detail/127411.htm)38 * If you use an ordinary account, the `resource_types` supports the update operation after the process of creation is completed.39 * If you use an enterprise account, the `resource_types` does not support updating.40 """41 return pulumi.get(self, "resource_types")42 @resource_types.setter43 def resource_types(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):44 pulumi.set(self, "resource_types", value)45@pulumi.input_type46class _ConfigurationRecorderState:47 def __init__(__self__, *,48 enterprise_edition: Optional[pulumi.Input[bool]] = None,49 organization_enable_status: Optional[pulumi.Input[str]] = None,50 organization_master_id: Optional[pulumi.Input[int]] = None,51 resource_types: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,52 status: Optional[pulumi.Input[str]] = None):53 """54 Input properties used for looking up and filtering ConfigurationRecorder resources.55 :param pulumi.Input[str] organization_enable_status: Enterprise version configuration audit enabled status. Values: `REGISTRABLE`: Not enabled, `BUILDING`: Building and `REGISTERED`: Enabled.56 :param pulumi.Input[int] organization_master_id: The ID of the Enterprise management account.57 :param pulumi.Input[Sequence[pulumi.Input[str]]] resource_types: A list of resource types to be monitored. [Resource types that support Cloud Config.](https://www.alibabacloud.com/help/en/doc-detail/127411.htm)58 * If you use an ordinary account, the `resource_types` supports the update operation after the process of creation is completed.59 * If you use an enterprise account, the `resource_types` does not support updating.60 :param pulumi.Input[str] status: Status of resource monitoring. Values: `REGISTRABLE`: Not registered, `BUILDING`: Under construction, `REGISTERED`: Registered and `REBUILDING`: Rebuilding.61 """62 if enterprise_edition is not None:63 pulumi.set(__self__, "enterprise_edition", enterprise_edition)64 if organization_enable_status is not None:65 pulumi.set(__self__, "organization_enable_status", organization_enable_status)66 if organization_master_id is not None:67 pulumi.set(__self__, "organization_master_id", organization_master_id)68 if resource_types is not None:69 pulumi.set(__self__, "resource_types", resource_types)70 if status is not None:71 pulumi.set(__self__, "status", status)72 @property73 @pulumi.getter(name="enterpriseEdition")74 def enterprise_edition(self) -> Optional[pulumi.Input[bool]]:75 return pulumi.get(self, "enterprise_edition")76 @enterprise_edition.setter77 def enterprise_edition(self, value: Optional[pulumi.Input[bool]]):78 pulumi.set(self, "enterprise_edition", value)79 @property80 @pulumi.getter(name="organizationEnableStatus")81 def organization_enable_status(self) -> Optional[pulumi.Input[str]]:82 """83 Enterprise version configuration audit enabled status. Values: `REGISTRABLE`: Not enabled, `BUILDING`: Building and `REGISTERED`: Enabled.84 """85 return pulumi.get(self, "organization_enable_status")86 @organization_enable_status.setter87 def organization_enable_status(self, value: Optional[pulumi.Input[str]]):88 pulumi.set(self, "organization_enable_status", value)89 @property90 @pulumi.getter(name="organizationMasterId")91 def organization_master_id(self) -> Optional[pulumi.Input[int]]:92 """93 The ID of the Enterprise management account.94 """95 return pulumi.get(self, "organization_master_id")96 @organization_master_id.setter97 def organization_master_id(self, value: Optional[pulumi.Input[int]]):98 pulumi.set(self, "organization_master_id", value)99 @property100 @pulumi.getter(name="resourceTypes")101 def resource_types(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:102 """103 A list of resource types to be monitored. [Resource types that support Cloud Config.](https://www.alibabacloud.com/help/en/doc-detail/127411.htm)104 * If you use an ordinary account, the `resource_types` supports the update operation after the process of creation is completed.105 * If you use an enterprise account, the `resource_types` does not support updating.106 """107 return pulumi.get(self, "resource_types")108 @resource_types.setter109 def resource_types(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]):110 pulumi.set(self, "resource_types", value)111 @property112 @pulumi.getter113 def status(self) -> Optional[pulumi.Input[str]]:114 """115 Status of resource monitoring. Values: `REGISTRABLE`: Not registered, `BUILDING`: Under construction, `REGISTERED`: Registered and `REBUILDING`: Rebuilding.116 """117 return pulumi.get(self, "status")118 @status.setter119 def status(self, value: Optional[pulumi.Input[str]]):120 pulumi.set(self, "status", value)121class ConfigurationRecorder(pulumi.CustomResource):122 @overload123 def __init__(__self__,124 resource_name: str,125 opts: Optional[pulumi.ResourceOptions] = None,126 enterprise_edition: Optional[pulumi.Input[bool]] = None,127 resource_types: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,128 __props__=None):129 """130 Provides a Alicloud Config Configuration Recorder resource. Cloud Config is a specialized service for evaluating resources. Cloud Config tracks configuration changes of your resources and evaluates configuration compliance. Cloud Config can help you evaluate numerous resources and maintain the continuous compliance of your cloud infrastructure.131 For information about Alicloud Config Configuration Recorder and how to use it, see [What is Configuration Recorder.](https://www.alibabacloud.com/help/en/doc-detail/153156.html)132 > **NOTE:** Available in v1.99.0+.133 > **NOTE:** The Cloud Config region only support `cn-shanghai` and `ap-southeast-1`.134 ## Example Usage135 ```python136 import pulumi137 import pulumi_alicloud as alicloud138 example = alicloud.cfg.ConfigurationRecorder("example", resource_types=[139 "ACS::ECS::Instance",140 "ACS::ECS::Disk",141 ])142 ```143 ## Import144 Alicloud Config Configuration Recorder can be imported using the id, e.g.145 ```sh146 $ pulumi import alicloud:cfg/configurationRecorder:ConfigurationRecorder example 122378463********147 ```148 :param str resource_name: The name of the resource.149 :param pulumi.ResourceOptions opts: Options for the resource.150 :param pulumi.Input[Sequence[pulumi.Input[str]]] resource_types: A list of resource types to be monitored. [Resource types that support Cloud Config.](https://www.alibabacloud.com/help/en/doc-detail/127411.htm)151 * If you use an ordinary account, the `resource_types` supports the update operation after the process of creation is completed.152 * If you use an enterprise account, the `resource_types` does not support updating.153 """154 ...155 @overload156 def __init__(__self__,157 resource_name: str,158 args: Optional[ConfigurationRecorderArgs] = None,159 opts: Optional[pulumi.ResourceOptions] = None):160 """161 Provides a Alicloud Config Configuration Recorder resource. Cloud Config is a specialized service for evaluating resources. Cloud Config tracks configuration changes of your resources and evaluates configuration compliance. Cloud Config can help you evaluate numerous resources and maintain the continuous compliance of your cloud infrastructure.162 For information about Alicloud Config Configuration Recorder and how to use it, see [What is Configuration Recorder.](https://www.alibabacloud.com/help/en/doc-detail/153156.html)163 > **NOTE:** Available in v1.99.0+.164 > **NOTE:** The Cloud Config region only support `cn-shanghai` and `ap-southeast-1`.165 ## Example Usage166 ```python167 import pulumi168 import pulumi_alicloud as alicloud169 example = alicloud.cfg.ConfigurationRecorder("example", resource_types=[170 "ACS::ECS::Instance",171 "ACS::ECS::Disk",172 ])173 ```174 ## Import175 Alicloud Config Configuration Recorder can be imported using the id, e.g.176 ```sh177 $ pulumi import alicloud:cfg/configurationRecorder:ConfigurationRecorder example 122378463********178 ```179 :param str resource_name: The name of the resource.180 :param ConfigurationRecorderArgs args: The arguments to use to populate this resource's properties.181 :param pulumi.ResourceOptions opts: Options for the resource.182 """183 ...184 def __init__(__self__, resource_name: str, *args, **kwargs):185 resource_args, opts = _utilities.get_resource_args_opts(ConfigurationRecorderArgs, pulumi.ResourceOptions, *args, **kwargs)186 if resource_args is not None:187 __self__._internal_init(resource_name, opts, **resource_args.__dict__)188 else:189 __self__._internal_init(resource_name, *args, **kwargs)190 def _internal_init(__self__,191 resource_name: str,192 opts: Optional[pulumi.ResourceOptions] = None,193 enterprise_edition: Optional[pulumi.Input[bool]] = None,194 resource_types: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,195 __props__=None):196 opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)197 if not isinstance(opts, pulumi.ResourceOptions):198 raise TypeError('Expected resource options to be a ResourceOptions instance')199 if opts.id is None:200 if __props__ is not None:201 raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')202 __props__ = ConfigurationRecorderArgs.__new__(ConfigurationRecorderArgs)203 __props__.__dict__["enterprise_edition"] = enterprise_edition204 __props__.__dict__["resource_types"] = resource_types205 __props__.__dict__["organization_enable_status"] = None206 __props__.__dict__["organization_master_id"] = None207 __props__.__dict__["status"] = None208 super(ConfigurationRecorder, __self__).__init__(209 'alicloud:cfg/configurationRecorder:ConfigurationRecorder',210 resource_name,211 __props__,212 opts)213 @staticmethod214 def get(resource_name: str,215 id: pulumi.Input[str],216 opts: Optional[pulumi.ResourceOptions] = None,217 enterprise_edition: Optional[pulumi.Input[bool]] = None,218 organization_enable_status: Optional[pulumi.Input[str]] = None,219 organization_master_id: Optional[pulumi.Input[int]] = None,220 resource_types: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,221 status: Optional[pulumi.Input[str]] = None) -> 'ConfigurationRecorder':222 """223 Get an existing ConfigurationRecorder resource's state with the given name, id, and optional extra224 properties used to qualify the lookup.225 :param str resource_name: The unique name of the resulting resource.226 :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.227 :param pulumi.ResourceOptions opts: Options for the resource.228 :param pulumi.Input[str] organization_enable_status: Enterprise version configuration audit enabled status. Values: `REGISTRABLE`: Not enabled, `BUILDING`: Building and `REGISTERED`: Enabled.229 :param pulumi.Input[int] organization_master_id: The ID of the Enterprise management account.230 :param pulumi.Input[Sequence[pulumi.Input[str]]] resource_types: A list of resource types to be monitored. [Resource types that support Cloud Config.](https://www.alibabacloud.com/help/en/doc-detail/127411.htm)231 * If you use an ordinary account, the `resource_types` supports the update operation after the process of creation is completed.232 * If you use an enterprise account, the `resource_types` does not support updating.233 :param pulumi.Input[str] status: Status of resource monitoring. Values: `REGISTRABLE`: Not registered, `BUILDING`: Under construction, `REGISTERED`: Registered and `REBUILDING`: Rebuilding.234 """235 opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))236 __props__ = _ConfigurationRecorderState.__new__(_ConfigurationRecorderState)237 __props__.__dict__["enterprise_edition"] = enterprise_edition238 __props__.__dict__["organization_enable_status"] = organization_enable_status239 __props__.__dict__["organization_master_id"] = organization_master_id240 __props__.__dict__["resource_types"] = resource_types241 __props__.__dict__["status"] = status242 return ConfigurationRecorder(resource_name, opts=opts, __props__=__props__)243 @property244 @pulumi.getter(name="enterpriseEdition")245 def enterprise_edition(self) -> pulumi.Output[bool]:246 return pulumi.get(self, "enterprise_edition")247 @property248 @pulumi.getter(name="organizationEnableStatus")249 def organization_enable_status(self) -> pulumi.Output[str]:250 """251 Enterprise version configuration audit enabled status. Values: `REGISTRABLE`: Not enabled, `BUILDING`: Building and `REGISTERED`: Enabled.252 """253 return pulumi.get(self, "organization_enable_status")254 @property255 @pulumi.getter(name="organizationMasterId")256 def organization_master_id(self) -> pulumi.Output[int]:257 """258 The ID of the Enterprise management account.259 """260 return pulumi.get(self, "organization_master_id")261 @property262 @pulumi.getter(name="resourceTypes")263 def resource_types(self) -> pulumi.Output[Sequence[str]]:264 """265 A list of resource types to be monitored. [Resource types that support Cloud Config.](https://www.alibabacloud.com/help/en/doc-detail/127411.htm)266 * If you use an ordinary account, the `resource_types` supports the update operation after the process of creation is completed.267 * If you use an enterprise account, the `resource_types` does not support updating.268 """269 return pulumi.get(self, "resource_types")270 @property271 @pulumi.getter272 def status(self) -> pulumi.Output[str]:273 """274 Status of resource monitoring. Values: `REGISTRABLE`: Not registered, `BUILDING`: Under construction, `REGISTERED`: Registered and `REBUILDING`: Rebuilding.275 """...
test_resource_types.py
Source:test_resource_types.py
1import pytest2import k8v3class TestResourceTypes:4 """Validate various functionality related to the ResourceType behavior."""5 def setup(self) -> None:6 self.expected_types = {7 k8v.resource_types.ResourceType.CLUSTER_ROLES: [8 "clusterrole",9 "clusterroles",10 ],11 k8v.resource_types.ResourceType.CLUSTER_ROLE_BINDINGS: [12 "clusterrolebinding",13 "clusterrolebindings",14 ],15 k8v.resource_types.ResourceType.CONFIG_MAP: [16 "configmap",17 "configmaps",18 "cm",19 "cms",20 ],21 k8v.resource_types.ResourceType.CRONJOBS: [22 "cronjob",23 "cronjobs",24 ],25 k8v.resource_types.ResourceType.DAEMON_SETS: [26 "daemonset",27 "daemonsets",28 "ds",29 ],30 k8v.resource_types.ResourceType.DEPLOYMENTS: [31 "deployment",32 "deployments",33 "deploy",34 "deploys",35 ],36 k8v.resource_types.ResourceType.INGRESS: [37 "ingress",38 "ingresses",39 "ing",40 ],41 k8v.resource_types.ResourceType.JOBS: [42 "job",43 "jobs",44 ],45 k8v.resource_types.ResourceType.NETWORK_POLICY: [46 "networkpolicy",47 "networkpolicies",48 "netpol",49 ],50 k8v.resource_types.ResourceType.PERSISTENT_VOLUME: [51 "persistentvolume",52 "persistentvolumes",53 "pv",54 ],55 k8v.resource_types.ResourceType.PERSISTENT_VOLUME_CLAIM: [56 "persistentvolumeclaim",57 "persistentvolumeclaims",58 "pvc",59 ],60 k8v.resource_types.ResourceType.PODS: [61 "pod",62 "pods",63 "po",64 ],65 k8v.resource_types.ResourceType.REPLICA_SETS: [66 "replicaset",67 "replicasets",68 "rs",69 ],70 k8v.resource_types.ResourceType.ROLES: [71 "role",72 "roles",73 ],74 k8v.resource_types.ResourceType.ROLE_BINDINGS: [75 "rolebinding",76 "rolebindings",77 ],78 k8v.resource_types.ResourceType.SECRETS: [79 "secret",80 "secrets",81 ],82 k8v.resource_types.ResourceType.SERVICES: [83 "service",84 "services",85 "svc",86 "svcs",87 ],88 k8v.resource_types.ResourceType.SERVICE_ACCOUNTS: [89 "serviceaccount",90 "serviceaccounts",91 "sa",92 ],93 k8v.resource_types.ResourceType.STATEFUL_SETS: [94 "statefulset",95 "statefulsets",96 "sts",97 ],98 }99 def test_from_value_valid(self) -> None:100 """Validate that we can use all aliases for a known type."""101 for t, aliases in self.expected_types.items():102 for alias in aliases:103 assert k8v.resource_types.ResourceType.from_value(alias) == t104 def test_from_value_invalid(self) -> None:105 """Validate that we cannot use an invalid alias."""106 assert k8v.resource_types.ResourceType.from_value(TestResourceTypes) == None107 assert k8v.resource_types.ResourceType.from_value(None) == None108 assert k8v.resource_types.ResourceType.from_value(True) == None109 assert k8v.resource_types.ResourceType.from_value(False) == None110 assert k8v.resource_types.ResourceType.from_value("") == None111 assert k8v.resource_types.ResourceType.from_value("configurationmap") == None112 assert k8v.resource_types.ResourceType.from_value("configurationmaps") == None113 def test_supported_types(self) -> None:114 """Validate the supported types by the viewer."""115 types = [t.value[0] for t in k8v.resource_types.ResourceType]116 types.sort()117 assert types == [x[0] for x in self.expected_types.values()]118 def test_type_aliases(self) -> None:119 """Validate that aliases for the supported resource types are supported."""120 for type, aliases in self.expected_types.items():121 for alias in aliases:...
config.py
Source:config.py
1import dataclasses2from io import IOBase3import json4import sys5import k8v6@dataclasses.dataclass7class Config:8 """Configuration variables used for the Viewer."""9 # color scheme10 colors: str = "default"11 # scheme to use at runtime12 color_scheme: dict = dataclasses.field(default_factory=dict)13 # delimeter to use for related resources14 delimeter: str = " "15 # excludes list16 excludes: list = dataclasses.field(default_factory=list)17 # includes list18 includes: list = dataclasses.field(default_factory=list)19 # namespaces to search20 namespaces: list = dataclasses.field(default_factory=list)21 # output mode22 output: str = "default"23 # file used for output (default: STDOUT)24 filename: str = None25 file: IOBase = sys.stdout26 formatter = None27 # include related resources in results28 related: bool = False29 # resource types30 resources: list = dataclasses.field(default_factory=list)31 # label selectors32 selectors: dict = dataclasses.field(default_factory=dict)33 # verbose logging34 verbose: bool = False35 def load(self):36 # determine how to write to our output (Pickle is binary)37 if self.filename is not None:38 if self.output in ["pickle", "p"]:39 self.file = open(self.filename, "wb")40 else:41 self.file = open(self.filename, "w")42 try:43 schemes = json.load(open("etc/color-schemes.json"))["schemes"]44 if self.colors in schemes:45 self.color_scheme = schemes[self.colors]46 else:47 self.color_scheme = None48 self.handlers = json.load(open("etc/handlers.json"))49 except Exception as e:50 print(f"Exception occurred loading color schemes: {e}")51 raise e52 # setup default namespace if no overrides specified53 if self.namespaces is not None and len(self.namespaces) == 0:54 self.namespaces.append("default")55 # determine which resource types to search through56 if self.resources == None:57 self.resources = []58 for type in k8v.resource_types.ResourceType:59 self.resources.append(type)60 elif len(self.resources) == 0:61 self.resources = [62 k8v.resource_types.ResourceType.CONFIG_MAP,63 k8v.resource_types.ResourceType.CRONJOBS,64 k8v.resource_types.ResourceType.DAEMON_SETS,65 k8v.resource_types.ResourceType.DEPLOYMENTS,66 k8v.resource_types.ResourceType.INGRESS,67 k8v.resource_types.ResourceType.JOBS,68 k8v.resource_types.ResourceType.PERSISTENT_VOLUME,69 k8v.resource_types.ResourceType.PERSISTENT_VOLUME_CLAIM,70 k8v.resource_types.ResourceType.PODS,71 k8v.resource_types.ResourceType.REPLICA_SETS,72 k8v.resource_types.ResourceType.SECRETS,73 k8v.resource_types.ResourceType.SERVICES,74 k8v.resource_types.ResourceType.STATEFUL_SETS,75 ]76 # setup the formatter to use77 if self.output in ["brief", "b"]:78 self.formatter = k8v.formatters.brief_formatter.BriefFormatter(self)79 elif self.output in ["json", "j"]:80 self.formatter = k8v.formatters.json_formatter.JsonFormatter(self)81 elif self.output in ["pickle", "p"]:82 self.formatter = k8v.formatters.pickle_formatter.PickleFormatter(self)83 else:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!