File: list_objects.rb

package info (click to toggle)
ruby-fog-google 1.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,568 kB
  • sloc: ruby: 16,775; makefile: 3
file content (48 lines) | stat: -rw-r--r-- 1,578 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Fog
  module Storage
    class GoogleJSON
      class Real
        # Lists objects in a bucket matching some criteria.
        #
        # @param bucket [String] Name of bucket to list
        # @param options [Hash] Optional hash of options
        # @option options [String] :delimiter Delimiter to collapse objects
        #   under to emulate a directory-like mode
        # @option options [Integer] :max_results Maximum number of results to
        #   retrieve
        # @option options [String] :page_token Token to select a particular page
        #   of results
        # @option options [String] :prefix String that an object must begin with
        #   in order to be returned
        # @option options ["full", "noAcl"] :projection Set of properties to
        #   return (defaults to "noAcl")
        # @option options [Boolean] :versions If true, lists all versions of an
        #   object as distinct results (defaults to False)
        # @return [Google::Apis::StorageV1::Objects]
        def list_objects(bucket, options = {})
          allowed_opts = %i(
            delimiter
            max_results
            page_token
            prefix
            projection
            versions
          )

          @storage_json.list_objects(
            bucket,
            **options.select { |k, _| allowed_opts.include? k }
          )
        end
      end

      class Mock
        def list_objects(_bucket, _options = {})
          # :no-coverage:
          Fog::Mock.not_implemented
          # :no-coverage:
        end
      end
    end
  end
end