Skip to content

Commit b432950

Browse files
committed
Consistent resource.prop for timestamps and booleans (object store)
This patch set updates all object store objects to use consistent resource.prop for timestamps and booleans. In particular, the following changes were made: - Clarify documentation for timestamp and boolean attributes - Use 'is_' prefix and boolean type for boolean attributes - Use '_at' suffix and timestamp type for timestamp attributes This patch set also include missing documentation for the Account resource. Change-Id: Ibf204bb0ab444e7090c1102acdd3d0e1d9722829 Partial-Bug: #1544584
1 parent 2f2152f commit b432950

File tree

8 files changed

+44
-20
lines changed

8 files changed

+44
-20
lines changed

doc/source/users/resources/object_store/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ Object Store Resources
44
.. toctree::
55
:maxdepth: 1
66

7+
v1/account
78
v1/container
89
v1/obj
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
openstack.object_store.v1.account
2+
=================================
3+
4+
.. automodule:: openstack.object_store.v1.account
5+
6+
The Account Class
7+
-----------------
8+
9+
The ``Account`` class inherits from :class:`~openstack.resource.Resource`.
10+
11+
.. autoclass:: openstack.object_store.v1.account.Account
12+
:members:

openstack/object_store/v1/_proxy.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ def set_container_metadata(self, container, **metadata):
111111
metadata are keys defined by the Object Store
112112
and values defined by the user. The system
113113
metadata keys are:
114+
114115
- `content_type`
115-
- `detect_content_type`
116+
- `is_content_type_detected`
116117
- `versions_location`
117118
- `read_ACL`
118119
- `write_ACL`
@@ -282,12 +283,13 @@ def set_object_metadata(self, obj, container=None, **metadata):
282283
metadata are keys defined by the Object Store
283284
and values defined by the user. The system
284285
metadata keys are:
286+
285287
- `content_type`
286288
- `content_encoding`
287289
- `content_disposition`
288-
- `detect_content_type`
289290
- `delete_after`
290291
- `delete_at`
292+
- `is_content_type_detected`
291293
"""
292294
container_name = self._get_container_name(obj, container)
293295
res = self._get_resource(_obj.Object, obj,

openstack/object_store/v1/account.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ class Account(_base.BaseResource):
4040
#: this header is not returned by this operation.
4141
meta_temp_url_key_2 = resource.header("x-account-meta-temp-url-key-2")
4242
#: The timestamp of the transaction.
43+
#: *Type: datetime object parsed from a UNIX epoch*
4344
timestamp = resource.header("x-timestamp", type=format.UNIXEpoch)

openstack/object_store/v1/container.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Container(_base.BaseResource):
2020
_custom_metadata_prefix = "X-Container-Meta-"
2121
_system_metadata = {
2222
"content_type": "content-type",
23-
"detect_content_type": "x-detect-content-type",
23+
"is_content_type_detected": "x-detect-content-type",
2424
"versions_location": "x-versions-location",
2525
"read_ACL": "x-container-read",
2626
"write_ACL": "x-container-write",
@@ -53,15 +53,16 @@ class Container(_base.BaseResource):
5353
#: The count of bytes used in total.
5454
bytes_used = resource.header("x-container-bytes-used", type=int)
5555
#: The timestamp of the transaction.
56+
#: *Type: datetime object parsed from a UNIX epoch*
5657
timestamp = resource.header("x-timestamp", type=format.UNIXEpoch)
5758

5859
# Request headers (when id=None)
5960
#: If set to True, Object Storage queries all replicas to return the
6061
#: most recent one. If you omit this header, Object Storage responds
6162
#: faster after it finds one valid replica. Because setting this
6263
#: header to True is more expensive for the back end, use it only
63-
#: when it is absolutely needed.
64-
newest = resource.header("x-newest", type=bool)
64+
#: when it is absolutely needed. *Type: bool*
65+
is_newest = resource.header("x-newest", type=bool)
6566

6667
# Request headers (when id=name)
6768
#: The ACL that grants read access. If not set, this header is not
@@ -85,8 +86,9 @@ class Container(_base.BaseResource):
8586
content_type = resource.header("content-type")
8687
#: If set to true, Object Storage guesses the content type based
8788
#: on the file extension and ignores the value sent in the
88-
#: Content-Type header, if present.
89-
detect_content_type = resource.header("x-detect-content-type", type=bool)
89+
#: Content-Type header, if present. *Type: bool*
90+
is_content_type_detected = resource.header("x-detect-content-type",
91+
type=bool)
9092
#: In combination with Expect: 100-Continue, specify an
9193
#: "If-None-Match: \*" header to query whether the server already
9294
#: has a copy of the object before any data is sent.

openstack/object_store/v1/obj.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class Object(_base.BaseResource):
2525
"content_disposition": "content-disposition",
2626
"content_encoding": "content-encoding",
2727
"content_type": "content-type",
28-
"detect_content_type": "x-detect-content-type",
2928
"delete_after": "x-delete-after",
30-
"delete_at": "x-delete-at"
29+
"delete_at": "x-delete-at",
30+
"is_content_type_detected": "x-detect-content-type",
3131
}
3232

3333
base_path = "/%(container)s"
@@ -59,8 +59,8 @@ class Object(_base.BaseResource):
5959
#: the most recent one. If you omit this header, Object Storage
6060
#: responds faster after it finds one valid replica. Because
6161
#: setting this header to True is more expensive for the back end,
62-
#: use it only when it is absolutely needed.
63-
newest = resource.header("x-newest", type=bool)
62+
#: use it only when it is absolutely needed. *Type: bool*
63+
is_newest = resource.header("x-newest", type=bool)
6464
#: TODO(briancurtin) there's a lot of content here...
6565
range = resource.header("range", type=dict)
6666
#: See http://www.ietf.org/rfc/rfc2616.txt.
@@ -82,7 +82,8 @@ class Object(_base.BaseResource):
8282
#: Used with temporary URLs to specify the expiry time of the
8383
#: signature. For more information about temporary URLs, see
8484
#: OpenStack Object Storage API v1 Reference.
85-
expires = resource.header("expires")
85+
#: *Type: datetime object parsed from ISO 8601 formatted string*
86+
expires_at = resource.header("expires", type=format.ISO8601)
8687
#: If you include the multipart-manifest=get query parameter and
8788
#: the object is a large object, the object contents are not
8889
#: returned. Instead, the manifest is returned in the
@@ -113,7 +114,9 @@ class Object(_base.BaseResource):
113114
#: was corrupted, so retry the operation.
114115
etag = resource.header("etag")
115116
#: Set to True if this object is a static large object manifest object.
116-
is_static_large_object = resource.header("x-static-large-object")
117+
#: *Type: bool*
118+
is_static_large_object = resource.header("x-static-large-object",
119+
type=bool)
117120
#: If set, the value of the Content-Encoding metadata.
118121
#: If not set, this header is not returned by this operation.
119122
content_encoding = resource.header("content-encoding")
@@ -130,25 +133,28 @@ class Object(_base.BaseResource):
130133
#: If set, the time when the object will be deleted by the system
131134
#: in the format of a UNIX Epoch timestamp.
132135
#: If not set, this header is not returned by this operation.
136+
#: *Type: datetime object parsed from a UNIX epoch*
133137
delete_at = resource.header("x-delete-at", type=format.UNIXEpoch)
134138
#: If set, to this is a dynamic large object manifest object.
135139
#: The value is the container and object name prefix of the
136140
#: segment objects in the form container/prefix.
137141
object_manifest = resource.header("x-object-manifest")
138142
#: The timestamp of the transaction.
143+
#: *Type: datetime object parsed from a UNIX epoch*
139144
timestamp = resource.header("x-timestamp", type=format.UNIXEpoch)
140145
#: The date and time that the object was created or the last
141146
#: time that the metadata was changed.
142-
last_modified = resource.header("last_modified", alias="last-modified")
147+
last_modified_at = resource.header("last_modified", alias="last-modified")
143148

144149
# Headers for PUT and POST requests
145150
#: Set to chunked to enable chunked transfer encoding. If used,
146151
#: do not set the Content-Length header to a non-zero value.
147152
transfer_encoding = resource.header("transfer-encoding")
148153
#: If set to true, Object Storage guesses the content type based
149154
#: on the file extension and ignores the value sent in the
150-
#: Content-Type header, if present.
151-
detect_content_type = resource.header("x-detect-content-type", type=bool)
155+
#: Content-Type header, if present. *Type: bool*
156+
is_content_type_detected = resource.header("x-detect-content-type",
157+
type=bool)
152158
#: If set, this is the name of an object used to create the new
153159
#: object by copying the X-Copy-From object. The value is in form
154160
#: {container}/{object}. You must UTF-8-encode and then URL-encode

openstack/tests/unit/object_store/v1/test_container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_list(self, fake_list):
138138
def _test_create_update(self, sot, sot_call, sess_method):
139139
sot.read_ACL = "some ACL"
140140
sot.write_ACL = "another ACL"
141-
sot.detect_content_type = True
141+
sot.is_content_type_detected = True
142142
headers = {
143143
"x-container-read": "some ACL",
144144
"x-container-write": "another ACL",

openstack/tests/unit/object_store/v1/test_obj.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_head(self):
9696
headers = DICT_EXAMPLE['headers']
9797
self.assertEqual(headers['content-length'], sot.content_length)
9898
self.assertEqual(headers['accept-ranges'], sot.accept_ranges)
99-
self.assertEqual(headers['last-modified'], sot.last_modified)
99+
self.assertEqual(headers['last-modified'], sot.last_modified_at)
100100
self.assertEqual(headers['etag'], sot.etag)
101101
self.assertEqual(datetime(2016, 1, 21, 22, 10, 56, 281120,
102102
tzinfo=iso8601.UTC),
@@ -108,7 +108,7 @@ def test_head(self):
108108

109109
def test_get(self):
110110
sot = obj.Object.new(container=CONTAINER_NAME, name=OBJECT_NAME)
111-
sot.newest = True
111+
sot.is_newest = True
112112
sot.if_match = {"who": "what"}
113113

114114
rv = sot.get(self.sess)
@@ -127,7 +127,7 @@ def test_get(self):
127127
def _test_create(self, method, data, accept):
128128
sot = obj.Object.new(container=CONTAINER_NAME, name=OBJECT_NAME,
129129
data=data)
130-
sot.newest = True
130+
sot.is_newest = True
131131
headers = {"x-newest": True, "Accept": ""}
132132

133133
rv = sot.create(self.sess)

0 commit comments

Comments
 (0)