Skip to content

Commit e85c73c

Browse files
author
Harrison Unruh
authored
Version 1 release (#5)
1 parent 93edde0 commit e85c73c

File tree

20 files changed

+1121
-24
lines changed

20 files changed

+1121
-24
lines changed

.replit

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
entrypoint = "main.py"
2-
modules = ["python-3.10:v18-20230807-322e88b"]
32

43
hidden = [".pythonlibs"]
54

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.PHONY: docs
2+
docs:
3+
@poetry run pydoc-markdown
4+
15
.PHONY: install
26
install:
37
@poetry install
@@ -16,7 +20,7 @@ test-integration:
1620

1721
.PHONY: test-integration-multi-language
1822
test-integration-multi-language:
19-
@tox
23+
@poetry run tox
2024

2125
.PHONY: test-unit
2226
test-unit:

development.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ To run tests, run:
2323
make test
2424
```
2525

26+
## Docs
27+
28+
To generate the markdown docs, run:
29+
```bash
30+
make docs
31+
```
32+
2633
## Release
2734

2835
To check that the package builds, you can run:

docs/replit/__init__.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# replit
2+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# replit.object\_storage
2+
3+
Public interface for the replit.object_storage library.
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# replit.object\_storage.\_config
2+
3+
Configurations for external interactions managed by the library.
4+
Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
# replit.object\_storage.client
2+
3+
Client for interacting with Object Storage. This is the top-level interface.
4+
5+
Note: this Client is a thin wrapper over the GCS Python Library. As a result,
6+
many docstrings are borrowed from the underlying library.
7+
8+
## Class Client
9+
10+
```python
11+
class Client()
12+
```
13+
14+
Client manages interactions with Replit Object Storage.
15+
16+
If multiple buckets are used within an application, one Client should be used
17+
per bucket
18+
19+
Any method may return one of the following errors:
20+
- `BucketNotFoundError`: If the bucket configured for the client could not be found.
21+
- `DefaultBucketError`: If no bucket was explicitly configured and an error occurred
22+
when resolving the default bucket.
23+
- `ForbiddenError`: If access to the requested resource is not allowed.
24+
- `TooManyRequestsError`: If rate limiting occurs.
25+
- `UnauthorizedError`: If the requested operation is not allowed.
26+
27+
#### \_\_init\_\_
28+
29+
```python
30+
def __init__(bucket_id: Optional[str] = None)
31+
```
32+
33+
Creates a new Client.
34+
35+
**Arguments**:
36+
37+
- `bucket_id` - The ID of the bucket this Client should interface with.
38+
If no ID is defined, the Repl / Deployment's default bucket will be
39+
used.
40+
41+
#### copy
42+
43+
```python
44+
def copy(object_name: str, dest_object_name: str) -> None
45+
```
46+
47+
Copies the specified object within the same bucket.
48+
49+
If an object exists in the same location, it will be overwritten.
50+
51+
**Arguments**:
52+
53+
- `object_name` - The full path of the object to be copied.
54+
- `dest_object_name` - The full path to copy the object to.
55+
56+
57+
**Raises**:
58+
59+
- `ObjectNotFoundError` - If the source object could not be found.
60+
61+
#### delete
62+
63+
```python
64+
def delete(object_name: str, ignore_not_found: bool = False) -> None
65+
```
66+
67+
Deletes an object from Object Storage.
68+
69+
**Arguments**:
70+
71+
- `object_name` - The name of the object to be deleted.
72+
- `ignore_not_found` - Whether an error should be raised if the object does not
73+
exist.
74+
75+
76+
**Raises**:
77+
78+
- `ObjectNotFoundError` - If the object could not be found.
79+
80+
#### download\_as\_bytes
81+
82+
```python
83+
def download_as_bytes(object_name: str) -> bytes
84+
```
85+
86+
Download the contents an object as a bytes object.
87+
88+
**Arguments**:
89+
90+
- `object_name` - The name of the object to be downloaded.
91+
92+
93+
**Returns**:
94+
95+
The raw byte representation of the object's contents.
96+
97+
98+
**Raises**:
99+
100+
- `ObjectNotFoundError` - If the object could not be found.
101+
102+
#### download\_as\_text
103+
104+
```python
105+
def download_as_text(object_name: str) -> str
106+
```
107+
108+
Download the contents an object as a string.
109+
110+
**Arguments**:
111+
112+
- `object_name` - The name of the object to be downloaded.
113+
114+
115+
**Returns**:
116+
117+
The object's contents as a UTF-8 encoded string.
118+
119+
120+
**Raises**:
121+
122+
- `ObjectNotFoundError` - If the object could not be found.
123+
124+
#### download\_to\_filename
125+
126+
```python
127+
def download_to_filename(object_name: str, dest_filename: str) -> None
128+
```
129+
130+
Download the contents an object into a file on the local disk.
131+
132+
**Arguments**:
133+
134+
- `object_name` - The name of the object to be downloaded.
135+
- `dest_filename` - The filename of the file on the local disk to be written.
136+
137+
138+
**Raises**:
139+
140+
- `ObjectNotFoundError` - If the object could not be found.
141+
142+
#### exists
143+
144+
```python
145+
def exists(object_name: str) -> bool
146+
```
147+
148+
Checks if an object exist.
149+
150+
**Arguments**:
151+
152+
- `object_name` - The name of the object to be checked.
153+
154+
155+
**Returns**:
156+
157+
Whether or not the object exists.
158+
159+
#### list
160+
161+
```python
162+
def list(end_offset: Optional[str] = None,
163+
match_glob: Optional[str] = None,
164+
max_results: Optional[int] = None,
165+
prefix: Optional[str] = None,
166+
start_offset: Optional[str] = None) -> List[Object]
167+
```
168+
169+
Lists objects in the bucket.
170+
171+
**Arguments**:
172+
173+
- `end_offset` - Filter results to objects whose names are lexicographically
174+
before end_offset. If start_offset is also set, the objects listed
175+
have names between start_offset (inclusive) and end_offset
176+
(exclusive).
177+
- `match_glob` - Glob pattern used to filter results, for example foo*bar.
178+
- `max_results` - The maximum number of results that can be returned in the
179+
response.
180+
- `prefix` - Filter results to objects who names have the specified prefix.
181+
- `start_offset` - Filter results to objects whose names are
182+
lexicographically equal to or after start_offset. If endOffset is
183+
also set, the objects listed have names between start_offset
184+
(inclusive) and end_offset (exclusive).
185+
186+
187+
**Returns**:
188+
189+
A list of objects matching the given query parameters.
190+
191+
#### upload\_from\_filename
192+
193+
```python
194+
def upload_from_filename(dest_object_name: str, src_filename: str) -> None
195+
```
196+
197+
Upload an object from a file on the local disk.
198+
199+
**Arguments**:
200+
201+
- `dest_object_name` - The name of the object to be uploaded.
202+
- `src_filename` - The filename of a file on the local disk
203+
204+
#### upload\_from\_bytes
205+
206+
```python
207+
def upload_from_bytes(dest_object_name: str, src_data: bytes) -> None
208+
```
209+
210+
Upload an object from bytes.
211+
212+
**Arguments**:
213+
214+
- `dest_object_name` - The name of the object to be uploaded.
215+
- `src_data` - The bytes to be uploaded.
216+
217+
#### upload\_from\_text
218+
219+
```python
220+
def upload_from_text(dest_object_name: str, src_data: Union[bytes,
221+
str]) -> None
222+
```
223+
224+
Upload an object from a string.
225+
226+
**Arguments**:
227+
228+
- `dest_object_name` - The name of the object to be uploaded.
229+
- `src_data` - The text to be uploaded.
230+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# replit.object\_storage.errors
2+
3+
Errors that may be returned by the storage library.
4+
5+
## Class BucketNotFoundError
6+
7+
```python
8+
class BucketNotFoundError(Exception)
9+
```
10+
11+
BucketNotFoundError may occur if the specified bucket could not be found.
12+
13+
## Class DefaultBucketError
14+
15+
```python
16+
class DefaultBucketError(Exception)
17+
```
18+
19+
DefaultBucketError may occur if the default bucket could not be resolved.
20+
21+
## Class ForbiddenError
22+
23+
```python
24+
class ForbiddenError(Exception)
25+
```
26+
27+
ForbiddenError may occur if access to the requested resource is not allowed.
28+
29+
## Class ObjectNotFoundError
30+
31+
```python
32+
class ObjectNotFoundError(Exception)
33+
```
34+
35+
ObjectNotFoundError may occur if the requested object could not be found.
36+
37+
## Class TooManyRequestsError
38+
39+
```python
40+
class TooManyRequestsError(Exception)
41+
```
42+
43+
TooManyRequestsError may occur if the rate of requests exceeds the rate limit.
44+
45+
## Class UnauthorizedError
46+
47+
```python
48+
class UnauthorizedError(Exception)
49+
```
50+
51+
UnauthorizedError may occur if the requested operation is not allowed.
52+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# replit.object\_storage.object
2+
3+
Pythonic representation of an object in Object Storage.
4+
5+
## Class Object
6+
7+
```python
8+
@dataclass
9+
class Object()
10+
```
11+
12+
Object contains metadata about an object.
13+
14+
**Attributes**:
15+
16+
- `name` - The name of the object.
17+

docs/sidebar.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"items": [
3+
{
4+
"items": [
5+
{
6+
"items": [
7+
"replit/object_storage/__init__",
8+
"replit/object_storage/_config",
9+
"replit/object_storage/client",
10+
"replit/object_storage/errors",
11+
"replit/object_storage/object"
12+
],
13+
"label": "replit.object_storage",
14+
"type": "category"
15+
},
16+
"replit/__init__"
17+
],
18+
"label": "replit",
19+
"type": "category"
20+
}
21+
],
22+
"label": "Reference",
23+
"type": "category"
24+
}

0 commit comments

Comments
 (0)