File: pagination.rst

package info (click to toggle)
swift 2.35.1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 22,760 kB
  • sloc: python: 281,901; javascript: 1,059; sh: 619; pascal: 295; makefile: 81; xml: 32
file content (137 lines) | stat: -rw-r--r-- 3,779 bytes parent folder | download | duplicates (4)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
=================================================
Page through large lists of containers or objects
=================================================

If you have a large number of containers or objects, you can use the
``marker``, ``limit``, and ``end_marker`` parameters to control
how many items are returned in a list and where the list starts or ends.
If you want to page backwards you can use the ``reverse`` parameter.

* marker
    When you request a list of containers or objects, Object Storage
    returns a maximum of 10,000 names for each request. To get
    subsequent names, you must make another request with the
    ``marker`` parameter. Set the ``marker`` parameter to the name of
    the last item returned in the previous list. You must URL-encode the
    ``marker`` value before you send the HTTP request. Object Storage
    returns a maximum of 10,000 names starting after the last item
    returned.

* limit
    To return fewer than 10,000 names, use the ``limit`` parameter. If
    the number of names returned equals the specified ``limit`` (or
    10,000 if you omit the ``limit`` parameter), you can assume there
    are more names to list. If the number of names in the list is
    exactly divisible by the ``limit`` value, the last request has no
    content.

* end_marker
    Limits the result set to names that are less than the
    ``end_marker`` parameter value. You must URL-encode the
    ``end_marker`` value before you send the HTTP request.

* reverse
    By default, listings are returned sorted by name, ascending. If you
    include the ``reverse=true`` query parameter, the listing will be
    returned sorted by name, descending.

To page through a large list of containers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Assume the following list of container names:

.. code-block:: console

   apples
   bananas
   kiwis
   oranges
   pears

#. Use a ``limit`` of two:

   .. code-block:: console

      # curl -i $publicURL/?limit=2 -X GET -H "X-Auth-Token: $token"

   .. code-block:: console

      apples
      bananas

   Because two container names are returned, there are more names to
   list.

#. Make another request with a ``marker`` parameter set to the name of
   the last item returned:

   .. code-block:: console

      # curl -i $publicURL/?limit=2&marker=bananas -X GET -H \
        “X-Auth-Token: $token"

   .. code-block:: console

      kiwis
      oranges

   Again, two items are returned, and there might be more.

#. Make another request with a ``marker`` of the last item returned:

   .. code-block:: console

      # curl -i $publicURL/?limit=2&marker=oranges -X GET -H \"
        X-Auth-Token: $token"

   .. code-block:: console

      pears

   You receive a one-item response, which is fewer than the ``limit``
   number of names. This indicates that this is the end of the list.

#. Use the ``end_marker`` parameter to limit the result set to object
   names that are less than the ``end_marker`` parameter value:

   .. code-block:: console

      # curl -i $publicURL/?end_marker=oranges -X GET -H \"
       X-Auth-Token: $token"

   .. code-block:: console

      apples
      bananas
      kiwis

   You receive a result set of all container names before the
   ``end-marker`` value.

#. Use the ``reverse`` parameter to work from the back of the
   list:

   .. code-block:: console

      # curl -i $publicURL/?reverse=true -X GET -H \"
         X-Auth-Token: $token"

   .. code-block:: console

      pears
      oranges
      kiwis
      bananas
      apples

#. You can also combine parameters:

   .. code-block:: console

      # curl -i $publicURL/?reverse=true&end_marker=kiwis -X GET -H \"
         X-Auth-Token: $token"

   .. code-block:: console

      pears
      oranges