Best Python code snippet using localstack_python
get_event_sources.py
Source:get_event_sources.py  
...76            name_regex=self.name_regex,77            names=self.names,78            output_file=self.output_file,79            sources=self.sources)80def get_event_sources(ids: Optional[Sequence[str]] = None,81                      name_regex: Optional[str] = None,82                      output_file: Optional[str] = None,83                      opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetEventSourcesResult:84    """85    This data source provides the Event Bridge Event Sources of the current Alibaba Cloud user.86    > **NOTE:** Available in v1.130.0+.87    ## Example Usage88    Basic Usage89    ```python90    import pulumi91    import pulumi_alicloud as alicloud92    example = alicloud.eventbridge.get_event_sources(ids=["example_value"],93        name_regex="the_resource_name")94    pulumi.export("firstEventBridgeEventSourceId", example.sources[0].id)95    ```96    :param Sequence[str] ids: A list of Event Source IDs.97    :param str name_regex: A regex string to filter results by Event Source name.98    """99    __args__ = dict()100    __args__['ids'] = ids101    __args__['nameRegex'] = name_regex102    __args__['outputFile'] = output_file103    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)104    __ret__ = pulumi.runtime.invoke('alicloud:eventbridge/getEventSources:getEventSources', __args__, opts=opts, typ=GetEventSourcesResult).value105    return AwaitableGetEventSourcesResult(106        id=__ret__.id,107        ids=__ret__.ids,108        name_regex=__ret__.name_regex,109        names=__ret__.names,110        output_file=__ret__.output_file,111        sources=__ret__.sources)112@_utilities.lift_output_func(get_event_sources)113def get_event_sources_output(ids: Optional[pulumi.Input[Optional[Sequence[str]]]] = None,114                             name_regex: Optional[pulumi.Input[Optional[str]]] = None,115                             output_file: Optional[pulumi.Input[Optional[str]]] = None,116                             opts: Optional[pulumi.InvokeOptions] = None) -> pulumi.Output[GetEventSourcesResult]:117    """118    This data source provides the Event Bridge Event Sources of the current Alibaba Cloud user.119    > **NOTE:** Available in v1.130.0+.120    ## Example Usage121    Basic Usage122    ```python123    import pulumi124    import pulumi_alicloud as alicloud125    example = alicloud.eventbridge.get_event_sources(ids=["example_value"],126        name_regex="the_resource_name")127    pulumi.export("firstEventBridgeEventSourceId", example.sources[0].id)128    ```129    :param Sequence[str] ids: A list of Event Source IDs.130    :param str name_regex: A regex string to filter results by Event Source name.131    """...dynamodb_event_source_listener.py
Source:dynamodb_event_source_listener.py  
...17    @staticmethod18    def source_type() -> Optional[str]:19        return "dynamodb"20    def _get_matching_event_sources(self) -> List[Dict]:21        event_sources = get_event_sources(source_arn=r".*:dynamodb:.*")22        return [source for source in event_sources if source["State"] == "Enabled"]23    def _get_stream_client(self, region_name):24        return aws_stack.connect_to_service("dynamodbstreams", region_name=region_name)25    def _get_stream_description(self, stream_client, stream_arn):26        return stream_client.describe_stream(StreamArn=stream_arn)["StreamDescription"]27    def _get_shard_iterator(self, stream_client, stream_arn, shard_id, iterator_type):28        return stream_client.get_shard_iterator(29            StreamArn=stream_arn, ShardId=shard_id, ShardIteratorType=iterator_type30        )["ShardIterator"]31    def _create_lambda_event_payload(self, stream_arn, records, shard_id=None):32        record_payloads = []33        for record in records:34            creation_time = record.get("dynamodb", {}).get("ApproximateCreationDateTime", None)35            if creation_time is not None:...EasyLambdaTrigger.py
Source:EasyLambdaTrigger.py  
...10			self.ENABLING, self.ENABLED, self.DISABLING, self.DISABLED11		]12		self.lambda_name = lambda_name13		self.lambda_client = boto3.client(service_name='lambda', region_name=region_name)14	def get_event_sources(self):15		event_source_mapping = self.lambda_client.list_event_source_mappings(FunctionName=self.lambda_name)16		return event_source_mapping['EventSourceMappings']17	def get_event_sources_uuid(self):18		return [e['UUID'] for e in self.get_event_sources()]19	def get_event_source_state(self, trigger_uuid):20		return self.lambda_client.get_event_source_mapping(UUID=trigger_uuid)['State']21	def update_trigger(self, trigger_uuid, enable, timeout=180, wait=False):22		if enable:23			wait_if_before_state = self.DISABLING24			wait_before_state = self.DISABLED25			return_states = [self.ENABLED, self.ENABLING]26			wait_state = self.ENABLED27		else:28			wait_if_before_state = self.ENABLING29			wait_before_state = self.ENABLED30			return_states = [self.DISABLED, self.DISABLING]31			wait_state = self.DISABLED32		current_state = self.get_event_source_state(trigger_uuid)...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!!
