List bucket contents

    :param awsclient:
    :param bucket:
    :param prefix:
    :return:
183111
def ls(awsclient, bucket, prefix=None):
    
    # this works until 1000 keys!
    params = {'Bucket': bucket}
    if prefix:
        params['Prefix'] = prefix
    client_s3 = awsclient.get_client('s3')
    objects = client_s3.list_objects_v2(**params)
    if objects['KeyCount'] > 0:
        keys = [k['Key'] for k in objects['Contents']]
        return keys
328917
def _list_deployment_instances(awsclient, deployment_id):
    
    client_codedeploy = awsclient.get_client('codedeploy')

    instances = []
    next_token = None

    # TODO refactor generic exhaust_function from this
    while True:
        request = {
            'deploymentId': deployment_id
        }
        if next_token:
            request['nextToken'] = next_token
        response = client_codedeploy.list_deployment_instances(**request)
        instances.extend(response['instancesList'])
        if 'nextToken' not in response:
            break
        next_token = response['nextToken']
    return instances
288714
def listdir(self, path):
        
        bucket, obj = self._path_to_bucket_and_key(path)

        obj_prefix = self._add_path_delimiter(obj)
        if self._is_root(obj_prefix):
            obj_prefix = ''

        obj_prefix_len = len(obj_prefix)
        for it in self._list_iter(bucket, obj_prefix):
            yield self._add_path_delimiter(path) + it['name'][obj_prefix_len:]
170820
def _list_locators(self):
        
        with _handle_oss_error():
            response = _oss.Service(
                self.client, endpoint=self._endpoint).list_buckets()

        for bucket in response.buckets:
            yield bucket.name, self._model_to_dict(bucket, ('name',))
196120
private function listBucket($object_prefix = null) {
    $headers = $this->getOAuthTokenHeader(parent::READ_SCOPE);
    if ($headers === false) {
      if (!$this->quiet) {
        trigger_error("Unable to acquire OAuth token.", E_USER_WARNING);
      }
      return false;
    }

    $query_arr = [
        'delimiter' => parent::DELIMITER,
        'max-keys' => self::MAX_KEYS,
    ];
    if (isset($object_prefix)) {
      $query_arr['prefix'] = $object_prefix;
    }
    if (isset($this->next_marker)) {
      $query_arr['marker'] = $this->next_marker;
    }

    $url = $this->createObjectUrl($this->bucket_name);
    $query_str = http_build_query($query_arr);
    $http_response = $this->makeHttpRequest(sprintf("%s?%s", $url, $query_str),
                                            "GET",
                                            $headers);
    if ($http_response === false) {
      if (!$this->quiet) {
        trigger_error('Unable to connect to the Cloud Storage Service.',
                      E_USER_WARNING);
      }
      return false;
    }

    if (HttpResponse::OK !== $http_response['status_code']) {
      if (!$this->quiet) {
        trigger_error($this->getErrorMessage($http_response['status_code'],
                                             $http_response['body']),
                      E_USER_WARNING);
      }
      return false;
    }

    // Extract the files into the result array.
    $xml = simplexml_load_string($http_response['body']);

    if (isset($xml->NextMarker)) {
      $this->next_marker = (string) $xml->NextMarker;
    } else {
      $this->next_marker = null;
    }

    $results = [];
    foreach($xml->Contents as $content) {
      $results [] = [
          'name' => (string) $content->Key,
          'size' => (string) $content->Size,
          'mtime' => (string) $content->LastModified,
      ];
    }
    // Subdirectories will be returned in the CommonPrefixes section. Refer to
    // https://developers.google.com/storage/docs/reference-methods#getbucket
    foreach($xml->CommonPrefixes as $common_prefix) {
      $results[] = [
          'name' => (string) $common_prefix->Prefix,
      ];
    }
    return $results;
  }
404160
def get_buckets(self, bucket_type=None, timeout=None):
        
        msg_code = riak.pb.messages.MSG_CODE_LIST_BUCKETS_REQ
        codec = self._get_codec(msg_code)
        msg = codec.encode_get_buckets(bucket_type,
                                       timeout, streaming=False)
        resp_code, resp = self._request(msg, codec)
        return resp.buckets
445382
def list(
            self,
            bucket: str,
            prefix: str=None,
            delimiter: str=None,
    ) -> typing.Iterator[str]:
        
        raise NotImplementedError()
267610
def getfiles(self, path, ext=None, start=None, stop=None, recursive=False):
        
        from .utils import connection_with_anon, connection_with_gs

        parse = BotoClient.parse_query(path)

        scheme = parse[0]
        bucket_name = parse[1]

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

        keys = BotoClient.retrieve_keys(
            bucket, parse[2], prefix=parse[3], postfix=parse[4], recursive=recursive)
        keylist = [key.name for key in keys]
        if ext:
            if ext == 'tif' or ext == 'tiff':
                keylist = [keyname for keyname in keylist if keyname.endswith('tif')]
                keylist.append([keyname for keyname in keylist if keyname.endswith('tiff')])
            else:
                keylist = [keyname for keyname in keylist if keyname.endswith(ext)]

        keylist.sort()
        keylist = select(keylist, start, stop)

        return scheme, bucket.name, keylist
500749
def parse_list_buckets(data):
    
    root = S3Element.fromstring('ListBucketsResult', data)

    return [
        Bucket(bucket.get_child_text('Name'),
               bucket.get_localized_time_elem('CreationDate'))
        for buckets in root.findall('Buckets')
        for bucket in buckets.findall('Bucket')
    ]
777443
def _storage_list_buckets(project, pattern):
  
  data = [{'Bucket': 'gs://' + bucket.name, 'Created': bucket.metadata.created_on}
          for bucket in datalab.storage.Buckets(project_id=project)
          if fnmatch.fnmatch(bucket.name, pattern)]
  return datalab.utils.commands.render_dictionary(data, ['Bucket', 'Created'])
136149
def list_bucket(self, bucket):
    
    self.response.write('Listbucket result:\n')

    page_size = 1
    stats = gcs.listbucket(bucket + '/foo', max_keys=page_size)
    while True:
      count = 0
      for stat in stats:
        count += 1
        self.response.write(repr(stat))
        self.response.write('\n')

      if count != page_size or count == 0:
        break
      stats = gcs.listbucket(bucket + '/foo', max_keys=page_size,
                             marker=stat.filename)
903884
def _gcs_list_buckets(project, pattern):
  
  data = [{'Bucket': 'gs://' + bucket.name, 'Created': bucket.metadata.created_on}
          for bucket in google.datalab.storage.Buckets(_make_context(project))
          if fnmatch.fnmatch(bucket.name, pattern)]
  return google.datalab.utils.commands.render_dictionary(data, ['Bucket', 'Created'])
1205613
def _storage_list_keys(bucket, pattern):
  
  data = [{'Name': item.metadata.name,
           'Type': item.metadata.content_type,
           'Size': item.metadata.size,
           'Updated': item.metadata.updated_on}
          for item in _storage_get_keys(bucket, pattern)]
  return datalab.utils.commands.render_dictionary(data, ['Name', 'Type', 'Size', 'Updated'])
340338
def list(self, resource=None, sort=None):
        
        schema = TagSchema()
        resp = self.service.get(self.base, params={'resource': resource, 'sort': sort})
        return self.service.decode(schema, resp, many=True)
840209
def retrieve_keys(bucket, key, prefix='', postfix='', delim='/',
                      directories=False, recursive=False):
        
        if key and prefix:
            assert key.endswith(delim)

        key += prefix
        # check whether key is a directory
        if not key.endswith(delim) and key:
            # check for matching prefix
            if BotoClient.check_prefix(bucket, key + delim, delim=delim):
                # found a directory
                key += delim

        listdelim = delim if not recursive else None
        results = bucket.list(prefix=key, delimiter=listdelim)
        if postfix:
            func = lambda k_: BotoClient.filter_predicate(k_, postfix, inclusive=True)
            return filter(func, results)
        elif not directories:
            func = lambda k_: BotoClient.filter_predicate(k_, delim, inclusive=False)
            return filter(func, results)
        else:
            return results
1245013
def list(cls, path):
        
        file_info = cls.parse_remote(path)
        connection = cls.connect(path)
        bucket = connection.get_bucket(file_info.bucket)
        region = "@%s" % file_info.region if file_info.region else ""

        output = []
        for key in bucket.get_all_keys(prefix=file_info.key):
            output.append(cls._S3_FILE % {"bucket": file_info.bucket,
                                          "key": key.name,
                                          "region": region})
        return output
407212
def list(cls, params=None, custom_headers=None):
        

        if params is None:
            params = {}

        if custom_headers is None:
            custom_headers = {}

        api_client = client.ApiClient(cls._get_api_context())
        endpoint_url = cls._ENDPOINT_URL_LISTING.format(
            cls._determine_user_id())
        response_raw = api_client.get(endpoint_url, params, custom_headers)

        return BunqResponseOauthClientList.cast_from_bunq_response(
            cls._from_json_list(response_raw, cls._OBJECT_TYPE_GET)
        )