Skip to content

Commit 6daf366

Browse files
authored
Add region, extra_headers and extra_query_params (#1505)
Signed-off-by: Bala.FA <bala@minio.io>
1 parent 64ed1ef commit 6daf366

File tree

97 files changed

+8714
-4790
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+8714
-4790
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The MinIO Python Client SDK provides high level APIs to access any MinIO Object
55
This Quickstart Guide covers how to install the MinIO client SDK, connect to the object storage service, and create a sample file uploader.
66

77
The example below uses:
8-
- [Python version 3.7+](https://www.python.org/downloads/)
8+
- [Python version 3.9+](https://www.python.org/downloads/)
99
- The [MinIO `mc` command line tool](https://min.io/docs/minio/linux/reference/minio-mc.html)
1010
- The MinIO `play` test server
1111

@@ -17,7 +17,7 @@ For a complete list of APIs and examples, see the [Python Client API Reference](
1717

1818
## Install the MinIO Python SDK
1919

20-
The Python SDK requires Python version 3.7+.
20+
The Python SDK requires Python version 3.9+.
2121
You can install the SDK with `pip` or from the [`minio/minio-py` GitHub repository](https://github.com/minio/minio-py):
2222

2323
### Using `pip`
@@ -49,7 +49,8 @@ For example:
4949
```py
5050
from minio import Minio
5151

52-
client = Minio("play.min.io",
52+
client = Minio(
53+
endpoint="play.min.io",
5354
access_key="Q3AM3UQ867SPQQA43P2F",
5455
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
5556
)
@@ -74,7 +75,8 @@ from minio.error import S3Error
7475
def main():
7576
# Create a client with the MinIO server playground, its access key
7677
# and secret key.
77-
client = Minio("play.min.io",
78+
client = Minio(
79+
endpoint="play.min.io",
7880
access_key="Q3AM3UQ867SPQQA43P2F",
7981
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
8082
)
@@ -87,16 +89,18 @@ def main():
8789
destination_file = "my-test-file.txt"
8890

8991
# Make the bucket if it doesn't exist.
90-
found = client.bucket_exists(bucket_name)
92+
found = client.bucket_exists(bucket_name=bucket_name)
9193
if not found:
92-
client.make_bucket(bucket_name)
94+
client.make_bucket(bucket_name=bucket_name)
9395
print("Created bucket", bucket_name)
9496
else:
9597
print("Bucket", bucket_name, "already exists")
9698

9799
# Upload the file, renaming it in the process
98100
client.fput_object(
99-
bucket_name, destination_file, source_file,
101+
bucket_name=bucket_name,
102+
object_name=destination_file,
103+
file_path=source_file,
100104
)
101105
print(
102106
source_file, "successfully uploaded as object",

docs/API.md

Lines changed: 992 additions & 648 deletions
Large diffs are not rendered by default.

examples/append_object.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,53 @@
1717
import io
1818
from urllib.request import urlopen
1919

20-
from examples.progress import Progress
2120
from minio import Minio
2221

2322
client = Minio(
24-
"play.min.io",
23+
endpoint="play.min.io",
2524
access_key="Q3AM3UQ867SPQQA43P2F",
2625
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
2726
)
2827

2928
# Upload data.
3029
result = client.put_object(
31-
"my-bucket", "my-object", io.BytesIO(b"hello, "), 7,
30+
bucket_name="my-bucket",
31+
object_name="my-object",
32+
data=io.BytesIO(b"hello, "),
33+
length=7,
3234
)
3335
print(f"created {result.object_name} object; etag: {result.etag}")
3436

3537
# Append data.
3638
result = client.append_object(
37-
"my-bucket", "my-object", io.BytesIO(b"world"), 5,
39+
bucket_name="my-bucket",
40+
object_name="my-object",
41+
data=io.BytesIO(b"world"),
42+
length=5,
3843
)
3944
print(f"appended {result.object_name} object; etag: {result.etag}")
4045

4146
# Append data in chunks.
42-
data = urlopen(
47+
with urlopen(
4348
"https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.13.12.tar.xz",
44-
)
45-
result = client.append_object(
46-
"my-bucket", "my-object", data, 148611164, 5*1024*1024,
47-
)
48-
print(f"appended {result.object_name} object; etag: {result.etag}")
49+
) as stream:
50+
result = client.append_object(
51+
bucket_name="my-bucket",
52+
object_name="my-object",
53+
stream=stream,
54+
length=148611164,
55+
chunk_size=5*1024*1024,
56+
)
57+
print(f"appended {result.object_name} object; etag: {result.etag}")
4958

5059
# Append unknown sized data.
51-
data = urlopen(
60+
with urlopen(
5261
"https://www.kernel.org/pub/linux/kernel/v6.x/linux-6.14.3.tar.xz",
53-
)
54-
result = client.append_object(
55-
"my-bucket", "my-object", data, 149426584, 5*1024*1024,
56-
)
57-
print(f"appended {result.object_name} object; etag: {result.etag}")
62+
) as stream:
63+
result = client.append_object(
64+
bucket_name="my-bucket",
65+
object_name="my-object",
66+
stream=stream,
67+
chunk_size=5*1024*1024,
68+
)
69+
print(f"appended {result.object_name} object; etag: {result.etag}")

examples/bucket_exists.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
from minio import Minio
1818

1919
client = Minio(
20-
"play.min.io",
20+
endpoint="play.min.io",
2121
access_key="Q3AM3UQ867SPQQA43P2F",
2222
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
2323
)
2424

25-
if client.bucket_exists("my-bucket"):
25+
if client.bucket_exists(bucket_name="my-bucket"):
2626
print("my-bucket exists")
2727
else:
2828
print("my-bucket does not exist")

examples/compose_object.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,48 @@
1919
from minio.sse import SseS3
2020

2121
client = Minio(
22-
"play.min.io",
22+
endpoint="play.min.io",
2323
access_key="Q3AM3UQ867SPQQA43P2F",
2424
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
2525
)
2626

2727
sources = [
28-
ComposeSource("my-job-bucket", "my-object-part-one"),
29-
ComposeSource("my-job-bucket", "my-object-part-two"),
30-
ComposeSource("my-job-bucket", "my-object-part-three"),
28+
ComposeSource(
29+
bucket_name="my-job-bucket", object_name="my-object-part-one",
30+
),
31+
ComposeSource(
32+
bucket_name="my-job-bucket", object_name="my-object-part-two",
33+
),
34+
ComposeSource(
35+
bucket_name="my-job-bucket", object_name="my-object-part-three",
36+
),
3137
]
3238

3339
# Create my-bucket/my-object by combining source object
3440
# list.
35-
result = client.compose_object("my-bucket", "my-object", sources)
41+
result = client.compose_object(
42+
bucket_name="my-bucket",
43+
object_name="my-object",
44+
sources=sources,
45+
)
3646
print(result.object_name, result.version_id)
3747

3848
# Create my-bucket/my-object with user metadata by combining
3949
# source object list.
4050
result = client.compose_object(
41-
"my-bucket",
42-
"my-object",
43-
sources,
44-
metadata={"test_meta_key": "test_meta_value"},
51+
bucket_name="my-bucket",
52+
object_name="my-object",
53+
sources=sources,
54+
user_metadata={"test_meta_key": "test_meta_value"},
4555
)
4656
print(result.object_name, result.version_id)
4757

4858
# Create my-bucket/my-object with user metadata and
4959
# server-side encryption by combining source object list.
50-
client.compose_object("my-bucket", "my-object", sources, sse=SseS3())
60+
client.compose_object(
61+
bucket_name="my-bucket",
62+
object_name="my-object",
63+
sources=sources,
64+
sse=SseS3(),
65+
)
5166
print(result.object_name, result.version_id)

examples/copy_object.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,41 @@
2020
from minio.commonconfig import REPLACE, CopySource
2121

2222
client = Minio(
23-
"play.min.io",
23+
endpoint="play.min.io",
2424
access_key="Q3AM3UQ867SPQQA43P2F",
2525
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
2626
)
2727

2828
# copy an object from a bucket to another.
2929
result = client.copy_object(
30-
"my-bucket",
31-
"my-object",
32-
CopySource("my-sourcebucket", "my-sourceobject"),
30+
bucket_name="my-bucket",
31+
object_name="my-object",
32+
source=CopySource(
33+
bucket_name="my-sourcebucket", object_name="my-sourceobject",
34+
),
3335
)
3436
print(result.object_name, result.version_id)
3537

3638
# copy an object with condition.
3739
result = client.copy_object(
38-
"my-bucket",
39-
"my-object",
40-
CopySource(
41-
"my-sourcebucket",
42-
"my-sourceobject",
40+
bucket_name="my-bucket",
41+
object_name="my-object",
42+
source=CopySource(
43+
bucket_name="my-sourcebucket",
44+
object_name="my-sourceobject",
4345
modified_since=datetime(2014, 4, 1, tzinfo=timezone.utc),
4446
),
4547
)
4648
print(result.object_name, result.version_id)
4749

4850
# copy an object from a bucket with replacing metadata.
49-
metadata = {"test_meta_key": "test_meta_value"}
5051
result = client.copy_object(
51-
"my-bucket",
52-
"my-object",
53-
CopySource("my-sourcebucket", "my-sourceobject"),
54-
metadata=metadata,
52+
bucket_name="my-bucket",
53+
object_name="my-object",
54+
source=CopySource(
55+
bucket_name="my-sourcebucket", object_name="my-sourceobject",
56+
),
57+
user_metadata={"test_meta_key": "test_meta_value"},
5558
metadata_directive=REPLACE,
5659
)
5760
print(result.object_name, result.version_id)

examples/delete_bucket_encryption.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
from minio import Minio
1818

1919
client = Minio(
20-
"play.min.io",
20+
endpoint="play.min.io",
2121
access_key="Q3AM3UQ867SPQQA43P2F",
2222
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
2323
)
2424

25-
client.delete_bucket_encryption("my-bucket")
25+
client.delete_bucket_encryption(bucket_name="my-bucket")

examples/delete_bucket_lifecycle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
from minio import Minio
1818

1919
client = Minio(
20-
"play.min.io",
20+
endpoint="play.min.io",
2121
access_key="Q3AM3UQ867SPQQA43P2F",
2222
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
2323
)
2424

25-
client.delete_bucket_lifecycle("my-bucket")
25+
client.delete_bucket_lifecycle(bucket_name="my-bucket")

examples/delete_bucket_notification.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
from minio import Minio
1818

1919
client = Minio(
20-
"play.min.io",
20+
endpoint="play.min.io",
2121
access_key="Q3AM3UQ867SPQQA43P2F",
2222
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
2323
)
2424

25-
client.delete_bucket_notification("my-bucket")
25+
client.delete_bucket_notification(bucket_name="my-bucket")

examples/delete_bucket_policy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
from minio import Minio
1818

1919
client = Minio(
20-
"play.min.io",
20+
endpoint="play.min.io",
2121
access_key="Q3AM3UQ867SPQQA43P2F",
2222
secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
2323
)
2424

25-
client.delete_bucket_policy("my-bucket")
25+
client.delete_bucket_policy(bucket_name="my-bucket")

0 commit comments

Comments
 (0)