Example of enabling Requester pays on a bucket.
558975
public Bucket enableRequesterPays(String bucketName) throws StorageException {
    // [START enable_requester_pays]
    // Instantiate a Google Cloud Storage client
    Storage storage = StorageOptions.getDefaultInstance().getService();

    // The name of the existing bucket to enable requester-paying for, e.g. "my-bucket"
    // String bucketName = "my-bucket"
    BucketInfo bucketInfo = BucketInfo.newBuilder(bucketName).setRequesterPays(true).build();

    // Update the bucket, throws StorageException on failure
    Bucket bucket = storage.update(bucketInfo);

    System.out.println("Requester pay status for " + bucketName + ": " + bucket.requesterPays());
    // [END enable_requester_pays]
    return bucket;
  }
1169469
def _queue_task(self, bucket, file_pair_list, transfer_config, subscribers, direction):
        '''  '''
        config = transfer_config if transfer_config else self._transfer_config

        _call_args = CallArgs(bucket=bucket,
                              file_pair_list=file_pair_list,
                              transfer_config=config,
                              subscribers=subscribers,
                              direction=direction,
                              transfer_spec=None,
                              transfer_spec_func=self._create_transfer_spec,
                              transfer_id=str(uuid.uuid4()))

        self._validate_args(_call_args)
        return self._coordinator_controller._queue_task(_call_args)
1265348
function(transaction, bucket, key, values){
		contract(arguments)
			.params('array', 'string', 'string|number','string|array')
			.end()
		;
		
		var self = this;
		var table = '';
		values = Array.isArray(values) ? values : [values]; // we always want to have an array for values
		
		transaction.push(function(cb){
			
			if (bucket.indexOf('allows') != -1) {
				table = self.prefix + self.buckets.permissions;
				self.db
					.select('key', 'value')
					.from(table)
					.where({'key': bucket})
					.then(function(result) {
						if(result.length === 0) {return;}
						
						// update the permissions for the role by removing what was requested
						_.each(values, function(value) {
							result[0].value[key] = _.without(result[0].value[key], value);
						});
						
						//  if no more permissions in the role then remove the role
						if (!result[0].value[key].length) {
							result[0].value = _.omit(result[0].value, key);
						}
						
						return self.db(table)
							.where('key', bucket)
							.update({value: result[0].value})
						;
					})
					.then(function() {
						cb(undefined);
					})
				;
			} else {
				table = self.prefix + bucket;
				self.db
					.select('key', 'value')
					.from(table)
					.where({'key': key})
					.then(function(result) {
						if(result.length === 0) {return;}
						
						var resultValues = result[0].value;
						// if we have found the key in the table then lets remove the values from it
						_.each(values, function(value) {
							resultValues = _.without(resultValues, value);
						});
						return self.db(table)
							.where('key', key)
							.update({value: resultValues})
						;
					})
					.then(function() {
						cb(undefined);
					})
				;
			}
		});
	}
630657
def do_request(self, http_verb, url, headers, data=None):
        
        if data:
            data = json.dumps(data)
        try:
            response = requests.request(http_verb, url, headers=headers, data=data, verify=config.CACERT_PATH)
        except (requests.exceptions.Timeout, requests.exceptions.TooManyRedirects) as exception:
            self._raise_unrecoverable_error_payplug(exception)
        except requests.exceptions.RequestException as exception:
            self._raise_unrecoverable_error_client(exception)

        return response.content, response.status_code, response.headers
1262321
protected Signer createSigner(final Request<?> request,
                                  final String bucketName,
                                  final String key) {
        return createSigner(request, bucketName, key, false);
    }
1111111
function(bucket, username, password) {
    this.bucket = bucket;
    this.username = username;
    this.password = password;

    this.authString = ["Basic", base64.encode([username, password].join(":"))].join(" ");
    this.baseUri = BASE_URI + bucket;

    this.baseHeader = {
        authorization   : this.authString,
        host            : "v0.api.upyun.com"
    };
}
901666
public Acl updateDefaultBucketAcl(String bucketName) {
    // [START updateDefaultBucketAcl]
    Acl acl =
        storage.updateDefaultAcl(bucketName, Acl.of(User.ofAllAuthenticatedUsers(), Role.OWNER));
    // [END updateDefaultBucketAcl]
    return acl;
  }
951745
def request(self, url, method="get", format="json", data=None,
                expected_status=None, headers=None, use_xpost=True, **options):
        
        if expected_status is None:
            if method == "get":
                expected_status = 200
            elif method == "post":
                expected_status = 201
            else:
                raise ValueError("No expected status supplied and method unknown.")

        if not url.startswith("http"):
            url = "{self.host}/api/v4/{url}".format(**locals())
        if format is not None:
            options = dict({'format': format}, **options)
        options = {field: value for field, value in options.items() if value is not None}
        headers = dict(headers or {}, Authorization="Token {}".format(self.token))
        #headers['Accept-encoding'] = 'gzip'

        if method == "get" and use_xpost:
            # If method is purely GET, we can use X-HTTP-METHOD-OVERRIDE to send our
            # query via POST. This allows for a large number of parameters to be supplied
            assert(data is None)

            headers.update({"X-HTTP-METHOD-OVERRIDE": method})
            data = options
            options = None
            method = "post"

        r = requests.request(method, url, data=data, params=options, headers=headers)

        log.debug(
            "HTTP {method} {url} (options={options!r}, data={data!r},"
            "headers={headers}) -> {r.status_code}".format(**locals())
        )
        return check(r, expected_status=expected_status)
241866
def make_requester(self, my_args=None):
        
        LOGGER.debug("zeromq.Driver.make_requester")
        raise exceptions.ArianeNotImplemented(self.__class__.__name__ + ".make_requester")
1117102
public Bucket disableRequesterPays(String bucketName) {
    // [START disable_requester_pays]
    // Instantiate a Google Cloud Storage client
    Storage storage = StorageOptions.getDefaultInstance().getService();

    // The name of the bucket to disable requester-paying for, e.g. "my-bucket"
    // String bucketName = "my-bucket"
    BucketInfo bucketInfo = BucketInfo.newBuilder(bucketName).setRequesterPays(false).build();

    // Update the bucket, throws StorageException on failure
    Bucket bucket = storage.update(bucketInfo);

    System.out.println("Requester pays status for " + bucketName + ": " + bucket.requesterPays());
    // [END disable_requester_pays]
    return bucket;
  }
412781
def describe(Bucket,
             region=None, key=None, keyid=None, profile=None):
    '''
    

    '''

    try:
        conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
        result = {}
        conn_dict = {'ACL': conn.get_bucket_acl,
                     'CORS': conn.get_bucket_cors,
                     'LifecycleConfiguration': conn.get_bucket_lifecycle_configuration,
                     'Location': conn.get_bucket_location,
                     'Logging': conn.get_bucket_logging,
                     'NotificationConfiguration': conn.get_bucket_notification_configuration,
                     'Policy': conn.get_bucket_policy,
                     'Replication': conn.get_bucket_replication,
                     'RequestPayment': conn.get_bucket_request_payment,
                     'Versioning': conn.get_bucket_versioning,
                     'Website': conn.get_bucket_website}

        for key, query in six.iteritems(conn_dict):
            try:
                data = query(Bucket=Bucket)
            except ClientError as e:
                if e.response.get('Error', {}).get('Code') in (
                            'NoSuchLifecycleConfiguration',
                            'NoSuchCORSConfiguration',
                            'NoSuchBucketPolicy',
                            'NoSuchWebsiteConfiguration',
                            'ReplicationConfigurationNotFoundError',
                            'NoSuchTagSet',
                            ):
                    continue
                raise
            if 'ResponseMetadata' in data:
                del data['ResponseMetadata']
            result[key] = data

        tags = {}
        try:
            data = conn.get_bucket_tagging(Bucket=Bucket)
            for tagdef in data.get('TagSet'):
                tags[tagdef.get('Key')] = tagdef.get('Value')
        except ClientError as e:
            if not e.response.get('Error', {}).get('Code') == 'NoSuchTagSet':
                raise
        if tags:
            result['Tagging'] = tags
        return {'bucket': result}
    except ClientError as e:
        err = __utils__['boto3.get_error'](e)
        if e.response.get('Error', {}).get('Code') == 'NoSuchBucket':
            return {'bucket': None}
        return {'error': __utils__['boto3.get_error'](e)}
577555
public Acl createDefaultBucketAcl(String bucketName) {
    // [START createDefaultBucketAcl]
    Acl acl =
        storage.createDefaultAcl(bucketName, Acl.of(User.ofAllAuthenticatedUsers(), Role.READER));
    // [END createDefaultBucketAcl]
    return acl;
  }
178754
def _request(self, method, endpoint, id=None, **kwargs):
        ""
        request = getattr(requests, method, None)
        if not callable(request):
            raise RequestError('Invalid method %s' % method)
        # Find files, separate them out to correct kwarg for requests.
        data = kwargs.get('data')
        if data:
            files = {}
            for name, value in list(data.items()):
                # Value might be a file-like object (with a read method), or it
                # might be a (filename, file-like) tuple.
                if hasattr(value, 'read') or isinstance(value, tuple):
                    files[name] = data.pop(name)
            if files:
                kwargs.setdefault('files', {}).update(files)
        path = ['api', self.version, endpoint]
        # If we received an ID, append it to the path.
        if id:
            path.append(str(id))
        # Join fragments into a URL
        path = '/'.join(path)
        if not path.endswith('/'):
            path += '/'
        while '//' in path:
            path = path.replace('//', '/')
        url = self.url + path
        # Add our user agent.
        kwargs.setdefault('headers', {}).setdefault('User-Agent',
                                                    HTTP_USER_AGENT)
        # Now try the request, if we get throttled, sleep and try again.
        trys, retrys = 0, 3
        while True:
            if trys == retrys:
                raise RequestError('Could not complete request after %s trys.'
                                   % trys)
            trys += 1
            try:
                return self._do_request(request, url, **kwargs)
            except ResponseError as e:
                if self.throttle_wait and e.status_code == 503:
                    m = THROTTLE_PATTERN.match(
                        e.response.headers.get('x-throttle', ''))
                    if m:
                        time.sleep(float(m.group(1)))
                        continue
                # Failed for a reason other than throttling.
                raise
928188
def _do_aws_request(request):
    
    if SHConfig().aws_access_key_id and SHConfig().aws_secret_access_key:
        key_args = dict(aws_access_key_id=SHConfig().aws_access_key_id,
                        aws_secret_access_key=SHConfig().aws_secret_access_key)
    else:
        key_args = {}
    aws_service, _, bucket_name, url_key = request.url.split('/', 3)

    try:
        s3_client = boto3.Session().client(aws_service.strip(':'), **key_args)
        request.s3_client = s3_client  # Storing the client prevents warning about unclosed socket
        DownloadRequest.GLOBAL_AWS_CLIENT = s3_client
    except KeyError:  # Sometimes creation of client fails and we use the global client if it exists
        if DownloadRequest.GLOBAL_AWS_CLIENT is None:
            raise ValueError('Failed to create a client for download from AWS')
        s3_client = DownloadRequest.GLOBAL_AWS_CLIENT

    try:
        return s3_client.get_object(Bucket=bucket_name, Key=url_key, RequestPayer='requester')
    except NoCredentialsError:
        raise ValueError('The requested data is in Requester Pays AWS bucket. In order to download the data please set '
                         'your access key either in AWS credentials file or in sentinelhub config.json file using '
                         'command line:\n'
                         '$ sentinelhub.config --aws_access_key_id <your AWS key> --aws_secret_access_key '
                         '<your AWS secret key>')
    except s3_client.exceptions.NoSuchKey:
        raise AwsDownloadFailedException('File in location %s is missing' % request.url)
    except s3_client.exceptions.NoSuchBucket:
        raise ValueError('Aws bucket %s does not exist' % bucket_name)
544701
def create_bucket(self, name, headers=None):
        
        self.provider.swift_client.put_container(name, headers)
665518
def put_stream(self, bucket, label, stream_object, params={}):
        '''  '''
        self.claim_bucket(bucket) 
        self.connection.put_object(bucket, label, stream_object,
                                   headers=self._convert_to_meta(params))
1260992
def consume(self, key, amount=1, rate=None, capacity=None, **kwargs):
        
        bucket = self.get_bucket(key, rate, capacity, **kwargs)
        return bucket.consume(amount)