Пример #1
0
    def test_config(self):
        tags = Tags()
        tags.update({"key1": "value1", "key2": "value2"})
        config = ReplicationConfig(
            "REPLACE-WITH-ACTUAL-ROLE",
            [
                Rule(
                    Destination(
                        "REPLACE-WITH-ACTUAL-DESTINATION-BUCKET-ARN", ),
                    ENABLED,
                    delete_marker_replication=DeleteMarkerReplication(
                        DISABLED, ),
                    rule_filter=Filter(AndOperator("TaxDocs", tags)),
                    rule_id="rule1",
                    priority=1,
                ),
            ],
        )
        xml.marshal(config)

        config = xml.unmarshal(
            ReplicationConfig,
            """<ReplicationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <Role>arn:aws:iam::35667example:role/CrossRegionReplicationRoleForS3</Role>
  <Rule>
    <ID>rule1</ID>
    <Status>Enabled</Status>
    <Priority>1</Priority>
    <DeleteMarkerReplication>
       <Status>Disabled</Status>
    </DeleteMarkerReplication>
    <Filter>
       <And>
           <Prefix>TaxDocs</Prefix>
           <Tag>
             <Key>key1</Key>
             <Value>value1</Value>
           </Tag>
           <Tag>
             <Key>key1</Key>
             <Value>value1</Value>
           </Tag>
       </And>
    </Filter>
    <Destination>
      <Bucket>arn:aws:s3:::exampletargetbucket</Bucket>
    </Destination>
  </Rule>
</ReplicationConfiguration>""",
        )
        xml.marshal(config)
Пример #2
0
    def test_tagging(self):
        tags = Tags()
        tags["Project"] = "Project One"
        tags["User"] = "******"
        tagging = Tagging(tags)
        xml.marshal(tagging)

        config = xml.unmarshal(
            Tagging,
            """<Tagging xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <TagSet>
    <Tag>
      <Key>key1</Key>
      <Value>value1</Value>
    </Tag>
    <Tag>
      <Key>key2</Key>
      <Value>value2</Value>
    </Tag>
  </TagSet>
</Tagging>""",
        )
        xml.marshal(config)
Пример #3
0
# Copyright (C) 2020 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
# dummy values, please replace them with original values.

from minio import Minio
from minio.commonconfig import Tags

client = Minio(
    "play.min.io",
    access_key="Q3AM3UQ867SPQQA43P2F",
    secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

tags = Tags.new_object_tags()
tags["Project"] = "Project One"
tags["User"] = "******"
client.set_object_tags("my-bucketname", "my-objectname", tags)
Пример #4
0
# -*- coding: utf-8 -*-
# MinIO Python Library for Amazon S3 Compatible Cloud Storage.
# Copyright (C) 2020 MinIO, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from minio import Minio
from minio.commonconfig import Tags

client = Minio(
    "play.min.io",
    access_key="Q3AM3UQ867SPQQA43P2F",
    secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

tags = Tags.new_bucket_tags()
tags["Project"] = "Project One"
tags["User"] = "******"
client.set_bucket_tags("my-bucket", tags)
Пример #5
0
)
print(
    "created {0} object; etag: {1}, version-id: {2}".format(
        result.object_name,
        result.etag,
        result.version_id,
    ), )

# Upload data with tags, retention and legal-hold.
date = datetime.utcnow().replace(
    hour=0,
    minute=0,
    second=0,
    microsecond=0,
) + timedelta(days=30)
tags = Tags(for_object=True)
tags["User"] = "******"
result = client.fput_object(
    "my-bucket",
    "my-object",
    "my-filename",
    tags=tags,
    retention=Retention(GOVERNANCE, date),
    legal_hold=True,
)
print(
    "created {0} object; etag: {1}, version-id: {2}".format(
        result.object_name,
        result.etag,
        result.version_id,
    ), )