How to use get_bucket_notification method in localstack

Best Python code snippet using localstack_python

minio_bucket_info.py

Source:minio_bucket_info.py Github

copy

Full Screen

...219 return client.get_bucket_tags(module.params['bucket'])220 elif module.params['get_bucket_policy']:221 return client.get_bucket_policy(module.params['bucket'])222 elif module.params['get_bucket_notification']:223 _res = client.get_bucket_notification(module.params['bucket'])224 return {225 "cloud_func_config_list": _res.cloud_func_config_list,226 "queue_config_list": _res.queue_config_list,227 "topic_config_list": _res.topic_config_list,228 }229 elif module.params['get_bucket_encryption']:230 _res = client.get_bucket_encryption(module.params['bucket'])231 if _res is not None:232 return {233 "kms_id": _res.rule.kms_master_key_id,234 "sse_algorithm": _res.rule.sse_algorithm,235 "status": "enabled"236 }237 else:...

Full Screen

Full Screen

s3.py

Source:s3.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# Copyright (c) 2014, 2015 Mitch Garnaat3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15import kappa.event_source.base16import logging17LOG = logging.getLogger(__name__)18class S3EventSource(kappa.event_source.base.EventSource):19 def __init__(self, context, config):20 super(S3EventSource, self).__init__(context, config)21 self._s3 = kappa.awsclient.create_client('s3', context.session)22 def _make_notification_id(self, function_name):23 return 'Kappa-%s-notification' % function_name24 def _get_bucket_name(self):25 return self.arn.split(':')[-1]26 def add(self, function):27 notification_spec = {28 'LambdaFunctionConfigurations': [29 {30 'Id': self._make_notification_id(function.name),31 'Events': [e for e in self._config['events']],32 'LambdaFunctionArn': '%s:%s' % (function.arn, function._context.environment),33 }34 ]35 }36 # Add S3 key filters37 if 'key_filters' in self._config:38 filters_spec = { 'Key' : { 'FilterRules' : [] } }39 for filter in self._config['key_filters']:40 if 'type' in filter and 'value' in filter and filter['type'] in ('prefix', 'suffix'):41 rule = { 'Name' : filter['type'], 'Value' : filter['value'] }42 filters_spec['Key']['FilterRules'].append(rule)43 notification_spec['LambdaFunctionConfigurations'][0]['Filter'] = filters_spec44 try:45 response = self._s3.call(46 'put_bucket_notification_configuration',47 Bucket=self._get_bucket_name(),48 NotificationConfiguration=notification_spec)49 LOG.debug(response)50 except Exception as exc:51 LOG.debug(exc.response)52 LOG.exception('Unable to add S3 event source')53 enable = add54 def update(self, function):55 self.add(function)56 def remove(self, function):57 LOG.debug('removing s3 notification')58 response = self._s3.call(59 'get_bucket_notification',60 Bucket=self._get_bucket_name())61 LOG.debug(response)62 if 'CloudFunctionConfiguration' in response:63 fn_arn = response['CloudFunctionConfiguration']['CloudFunction']64 if fn_arn == function.arn:65 del response['CloudFunctionConfiguration']66 del response['ResponseMetadata']67 response = self._s3.call(68 'put_bucket_notification',69 Bucket=self._get_bucket_name(),70 NotificationConfiguration=response)71 LOG.debug(response)72 disable = remove73 def status(self, function):74 LOG.debug('status for s3 notification for %s', function.name)75 response = self._s3.call(76 'get_bucket_notification',77 Bucket=self._get_bucket_name())78 LOG.debug(response)79 if 'CloudFunctionConfiguration' not in response:80 return None81 return {82 'EventSourceArn': response['CloudFunctionConfiguration']['CloudFunction'],83 'State': 'Enabled'...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful