Do the set-up that's needed to access Amazon S3.
775382
private void init() {
        validatePreSignedUrls();

        try {
            conn = new AWSAuthConnection(access_key, secret_access_key);
            // Determine the bucket name if prefix is set or if pre-signed URLs are being used
            if (prefix != null && prefix.length() > 0) {
                ListAllMyBucketsResponse bucket_list = conn.listAllMyBuckets(null);
                List buckets = bucket_list.entries;
                if (buckets != null) {
                    boolean found = false;
                    for (Object tmp : buckets) {
                        if (tmp instanceof Bucket) {
                            Bucket bucket = (Bucket) tmp;
                            if (bucket.name.startsWith(prefix)) {
                                location = bucket.name;
                                found = true;
                            }
                        }
                    }
                    if (!found) {
                        location = prefix + "-" + java.util.UUID.randomUUID().toString();
                    }
                }
            }
            if (usingPreSignedUrls()) {
                PreSignedUrlParser parsedPut = new PreSignedUrlParser(pre_signed_put_url);
                location = parsedPut.getBucket();
            }
            if (!conn.checkBucketExists(location)) {
                conn.createBucket(location, AWSAuthConnection.LOCATION_DEFAULT, null).connection.getResponseMessage();
            }
        } catch (Exception e) {
            throw HostControllerLogger.ROOT_LOGGER.cannotAccessS3Bucket(location, e.getLocalizedMessage());
        }
    }
460360
def configure(self, options, conf):
        
        super(S3Logging, self).configure(options, conf)
        self.options = options
1183389
def activate(self, path, isdirectory):
        
        from .utils import connection_with_anon, connection_with_gs

        parsed = BotoClient.parse_query(path)

        scheme = parsed[0]
        bucket_name = parsed[1]
        key = parsed[2]

        if scheme == 's3' or scheme == 's3n':
            conn = connection_with_anon(self.credentials)
            bucket = conn.get_bucket(bucket_name)
        elif scheme == 'gs':
            conn = connection_with_gs(bucket_name)
            bucket = conn.get_bucket()
        else:
            raise NotImplementedError("No file reader implementation for URL scheme " + scheme)

        if isdirectory and (not key.endswith("/")):
            key += "/"

        self._scheme = scheme
        self._conn = conn
        self._key = key
        self._bucket = bucket
        self._active = True
1287412
def s3(self, url, account_acessor=None, access=None, secret=None):
        """"""
        from ambry.util.ambrys3 import AmbryS3FS
        from ambry.util import parse_url_to_dict
        import ssl

        pd = parse_url_to_dict(url)

        if account_acessor:
            account = account_acessor(pd['hostname'])

            assert account['account_id'] == pd['hostname']
            aws_access_key = account['access_key'],
            aws_secret_key = account['secret']
        else:
            aws_access_key = access
            aws_secret_key = secret

        assert access, url
        assert secret, url

        s3 = AmbryS3FS(
            bucket=pd['netloc'],
            prefix=pd['path'].strip('/')+'/',
            aws_access_key=aws_access_key,
            aws_secret_key=aws_secret_key,

        )

        return s3
44581
def extra_prepare_after_activation(self, configuration, args_dict):
        """"""
        aws_syncr = configuration['aws_syncr']
        configuration["amazon"] = Amazon(configuration['aws_syncr'].environment, configuration['accounts'], debug=aws_syncr.debug, dry_run=aws_syncr.dry_run)
1275859
function S3Adapter (options, schema) {
	var self = this;
	this.options = assign({}, DEFAULT_OPTIONS, options.s3);

	// Check required options are set.
	var requiredOptions = ['key', 'secret', 'bucket'];
	requiredOptions.forEach(function (key) {
		if (!self.options[key]) {
			throw new Error('Configuration error: Missing required option `' + key + '`');
		}
	});

	// Check that `uploadParams` does not include any that we will be setting.
	var restrictedPrams = ['Key', 'Body', 'Bucket', 'ContentType', 'ContentLength'];
	Object.keys(this.options.uploadParams).forEach(function (key) {
		if (restrictedPrams.indexOf(key) !== -1) {
			throw new Error('Configuration error: `' + key + '` must not be set on `uploadParams`.');
		}
	});

	// Ensure the path has a leading "/"
	this.options.path = ensureLeadingSlash(this.options.path);

	// Create the s3 client
	this.s3Client = new S3({
		accessKeyId: this.options.key,
		secretAccessKey: this.options.secret,
		region: this.options.region,
	});

	// Ensure the generateFilename option takes a callback
	this.options.generateFilename = ensureCallback(this.options.generateFilename);
}
520516
def create_api_equipment(self):
        """"""
        return ApiEquipment(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
847120
def _setup_source_conn(self, source_conn_id, source_bucket_name=None):
        
        self.source_conn = BaseHook.get_hook(source_conn_id)
        self.source_conn_id = source_conn_id

        # Workaround for getting hook in case of s3 connection
        # This is needed because get_hook silently returns None for s3 connections
        # See https://issues.apache.org/jira/browse/AIRFLOW-2316 for more info
        connection = BaseHook._get_connection_from_env(source_conn_id)
        self.log.info(connection.extra_dejson)
        if connection.conn_type == 's3':
            self.log.info("Setting up s3 connection {0}".format(source_conn_id))
            self.source_conn = S3Hook(aws_conn_id=source_conn_id)
            # End Workaround
            if source_bucket_name is None:
                raise AttributeError("Missing source bucket for s3 connection")
            self.source_bucket_name = source_bucket_name

        if not isinstance(self.source_conn, DbApiHook) and not isinstance(self.source_conn, S3Hook):
            raise AttributeError(
                "Only s3_csv, local and sql connection types are allowed, not {0}".format(type(self.source_conn)))
1246095
public function setup() {
		$input_keys = array_keys((array) elgg_get_config('input'));
		$request_keys = array_keys((array) $_REQUEST);
		$keys = array_unique(array_merge($input_keys, $request_keys));
		foreach ($keys as $key) {
			if ($key) {
				$this->params->$key = get_input($key);
			}
		}
	}
81553
def setup_rabbitmq(self):
        

        if not self.rabbitmq_key:
            self.rabbitmq_key = '{}:start_urls'.format(self.name)

        self.server = connection.from_settings(self.crawler.settings)
        self.crawler.signals.connect(self.spider_idle, signal=signals.spider_idle)
        self.crawler.signals.connect(self.item_scraped, signal=signals.item_scraped)
436675
def _put_bucket_encryption(self):
        """"""
        if self.s3props['encryption']['enabled']:
            encryption_config = {'Rules': [{}]}
            encryption_config = {
                'Rules': self.s3props['encryption']['encryption_rules']
            }
            LOG.debug(encryption_config)
            _response = self.s3client.put_bucket_encryption(Bucket=self.bucket,
                                                            ServerSideEncryptionConfiguration=encryption_config)
        else:
            _response = self.s3client.delete_bucket_encryption(Bucket=self.bucket)
        LOG.debug('Response setting up S3 encryption: %s', _response)
        LOG.info('S3 encryption configuration updated')
938447
def _setup(self):
        """"""
        super(HyperVNeutronAgent, self)._setup()

        self._sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self._sec_groups_agent = HyperVSecurityAgent(self._context,
                                                     self._sg_plugin_rpc)
        self._vlan_driver = trunk_driver.HyperVTrunkDriver(self._context)
        if CONF.NVGRE.enable_support:
            self._consumers.append([h_constant.TUNNEL, topics.UPDATE])
            self._consumers.append([h_constant.LOOKUP, h_constant.UPDATE])
1350147
function (req, res) {
                var s3 = new AWS.S3(),
                    bucket = req.params.name,
                    key = getFullKeyParam(req.params, req.route),
                    params = {
                        Bucket: bucket,
                        Key: key
                    },
                    handleError = function (err) {
                        res.status(500).send(err);
                    };

                s3.getObject(params).createReadStream().on('error', handleError).pipe(res);

            }
245135
def connect_cloudfront(self):
        ""
        self.conn_cloudfront = connect_cloudfront(self.AWS_ACCESS_KEY_ID, self.AWS_SECRET_ACCESS_KEY, debug=self.S3UTILS_DEBUG_LEVEL)
396714
def ensure_cfn_bucket(self):
        """"""
        if self.bucket_name:
            ensure_s3_bucket(self.s3_conn,
                             self.bucket_name,
                             self.bucket_region)
1081617
def setup(self):
        """"""
        if self.dry_run is not True:
            self.client = self._get_client()
            self._disable_access_key()
1206180
function (req, res) {
                var s3 = new AWS.S3(),
                    handleListBuckets = function (err, data) {
                        if (err) {
                            res.status(500).send(err);
                        } else {
                            // Add link
                            data.Buckets.forEach(function (bucket) {
                                bucket.links = [{
                                    rel: 'self',
                                    href: getBucketLink(req, bucket.Name)
                                }];
                            });
                            
                            res.json(data.Buckets);
                        }
                    };
                
                s3.listBuckets(handleListBuckets);
            }