Repository: minio/minio-py

Issue:
Implement AWS China region support
Our Python Client library should also support  AWS China region s3.cn-north-1.amazonaws.com.cn

It has been implemented in minio-go, implementation reference:  https://github.com/minio/minio-go/commit/190ac7b4b7e7ba8a669553674b748bdcace6c59e

Discussion:

Patch:
diff --git a/docs/API.md b/docs/API.md
index 0a1f8cf..b5d578d 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -110,6 +110,7 @@ __Parameters__
 | | | ap-northeast-1|
 | | | ap-southeast-2|
 | | | sa-east-1|
+| | | cn-north-1|
 
 __Example__
 
diff --git a/minio/helpers.py b/minio/helpers.py
index 071d5d6..c0dd62f 100644
--- a/minio/helpers.py
+++ b/minio/helpers.py
@@ -207,6 +207,7 @@ AWS_S3_ENDPOINT_MAP = {
     'ap-southeast-1': 's3-ap-southeast-1.amazonaws.com',
     'ap-northeast-1': 's3-ap-northeast-1.amazonaws.com',
     'ap-northeast-2': 's3-ap-northeast-2.amazonaws.com',
+    'cn-north-1': 's3.cn-north-1.amazonaws.com.cn'
 }
 
 def get_s3_endpoint(region):


Test patch:
diff --git a/tests/unit/get_s3_endpoint_test.py b/tests/unit/get_s3_endpoint_test.py
new file mode 100644
index 0000000..775a889
--- /dev/null
+++ b/tests/unit/get_s3_endpoint_test.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# Minio Python Library for Amazon S3 Compatible Cloud Storage, (C) 2015 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 unittest import TestCase
+from nose.tools import eq_
+from minio.helpers import get_s3_endpoint, is_valid_endpoint
+
+class GetS3Endpoint(TestCase):
+    def test_get_s3_endpoint(self):
+        eq_('s3.amazonaws.com', get_s3_endpoint('us-east-1'))
+        eq_('s3.amazonaws.com', get_s3_endpoint('foo'))
+        eq_('s3-eu-west-1.amazonaws.com', get_s3_endpoint('eu-west-1'))
+        eq_('s3.cn-north-1.amazonaws.com.cn', get_s3_endpoint('cn-north-1'))
+
+    def test_is_valid_endpoint(self):
+        eq_(True, is_valid_endpoint('s3.amazonaws.com'))
+        eq_(True, is_valid_endpoint('s3.cn-north-1.amazonaws.com.cn'))