{"action":"created","comment":{"url":"https://api.github.com/repos/node-modules/ali-oss/pulls/comments/25139796","id":25139796,"diff_hunk":"@@ -0,0 +1,335 @@\n+/**!\n+ * ali-oss - lib/bucket.js\n+ *\n+ * Copyright(c) node-modules and other contributors.\n+ * MIT Licensed\n+ *\n+ * Authors:\n+ *   fengmk2 <m@fengmk2.com> (http://fengmk2.com)\n+ */\n+\n+'use strict';\n+\n+/**\n+ * Module dependencies.\n+ */\n+\n+var proto = exports;\n+\n+/**\n+ * Bucket opertaions\n+ */\n+\n+proto.listBuckets = function* (query, options) {\n+  // prefix, marker, max-keys\n+  var result = yield* this.request({\n+    method: 'GET',\n+    resource: '/',\n+    query: query,\n+    timeout: options && options.timeout\n+  });\n+\n+  if (result.status === 200) {\n+    var data = yield this.parseXML(result.data);\n+    var buckets = data.Buckets || null;\n+    if (buckets) {\n+      if (buckets.Bucket) {\n+        buckets = buckets.Bucket;\n+      }\n+      if (!Array.isArray(buckets)) {\n+        buckets = [buckets];\n+      }\n+    }\n+    return {\n+      buckets: buckets,\n+      owner: {\n+        id: data.Owner.ID,\n+        displayName: data.Owner.DisplayName,\n+      },\n+      isTruncated: data.IsTruncated === 'true',\n+      nextMarker: data.NextMarker || null,\n+      res: result.res\n+    };\n+  }\n+\n+  throw yield* this.requestError(result);\n+};\n+\n+proto.useBucket = function (name, region) {\n+  this.options.bucket = name;\n+  if (region) {\n+    this.setRegion(region);\n+  }\n+  return this;\n+};\n+\n+proto.putBucket = function* (name, region, options) {\n+  var params = this._bucketRequestParams('PUT', '/', name, region, options);\n+  if (region) {\n+    params.mime = 'xml';\n+    params.content = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n' +\n+      '<CreateBucketConfiguration><LocationConstraint>' + region +\n+      '</LocationConstraint></CreateBucketConfiguration>';\n+  }\n+  params.successStatuses = [200];\n+  var result = yield this.request(params);\n+  return {\n+    bucket: result.headers.location.substring(1),","path":"lib/bucket.js","position":null,"original_position":77,"commit_id":"80304f4230f70a25b2f36330ce8306e8a79e41ef","original_commit_id":"ac29d35b47ed34d77fadba63c588d03e0bd936c7","user":{"login":"fengmk2","id":156269,"avatar_url":"https://avatars.githubusercontent.com/u/156269?v=3","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false},"body":"done","created_at":"2015-02-23T00:58:08Z","updated_at":"2015-02-23T00:58:08Z","html_url":"https://github.com/node-modules/ali-oss/pull/4#discussion_r25139796","pull_request_url":"https://api.github.com/repos/node-modules/ali-oss/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/node-modules/ali-oss/pulls/comments/25139796"},"html":{"href":"https://github.com/node-modules/ali-oss/pull/4#discussion_r25139796"},"pull_request":{"href":"https://api.github.com/repos/node-modules/ali-oss/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/node-modules/ali-oss/pulls/4","id":29753256,"html_url":"https://github.com/node-modules/ali-oss/pull/4","diff_url":"https://github.com/node-modules/ali-oss/pull/4.diff","patch_url":"https://github.com/node-modules/ali-oss/pull/4.patch","issue_url":"https://api.github.com/repos/node-modules/ali-oss/issues/4","number":4,"state":"open","locked":false,"title":"ali-sdk: oss","user":{"login":"fengmk2","id":156269,"avatar_url":"https://avatars.githubusercontent.com/u/156269?v=3","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false},"body":"Refactor all according to https://github.com/node-modules/ali-sdk/blob/master/docs/oss.md\r\n\r\nFixes node-modules/ali-sdk#1","created_at":"2015-02-21T12:48:20Z","updated_at":"2015-02-23T00:58:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"877730182d7a8ae6d55a91b349a7f655b5b662c4","assignee":{"login":"dead-horse","id":985607,"avatar_url":"https://avatars.githubusercontent.com/u/985607?v=3","gravatar_id":"","url":"https://api.github.com/users/dead-horse","html_url":"https://github.com/dead-horse","followers_url":"https://api.github.com/users/dead-horse/followers","following_url":"https://api.github.com/users/dead-horse/following{/other_user}","gists_url":"https://api.github.com/users/dead-horse/gists{/gist_id}","starred_url":"https://api.github.com/users/dead-horse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dead-horse/subscriptions","organizations_url":"https://api.github.com/users/dead-horse/orgs","repos_url":"https://api.github.com/users/dead-horse/repos","events_url":"https://api.github.com/users/dead-horse/events{/privacy}","received_events_url":"https://api.github.com/users/dead-horse/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/node-modules/ali-oss/pulls/4/commits","review_comments_url":"https://api.github.com/repos/node-modules/ali-oss/pulls/4/comments","review_comment_url":"https://api.github.com/repos/node-modules/ali-oss/pulls/comments{/number}","comments_url":"https://api.github.com/repos/node-modules/ali-oss/issues/4/comments","statuses_url":"https://api.github.com/repos/node-modules/ali-oss/statuses/80304f4230f70a25b2f36330ce8306e8a79e41ef","head":{"label":"node-modules:ali-sdk","ref":"ali-sdk","sha":"80304f4230f70a25b2f36330ce8306e8a79e41ef","user":{"login":"node-modules","id":7125868,"avatar_url":"https://avatars.githubusercontent.com/u/7125868?v=3","gravatar_id":"","url":"https://api.github.com/users/node-modules","html_url":"https://github.com/node-modules","followers_url":"https://api.github.com/users/node-modules/followers","following_url":"https://api.github.com/users/node-modules/following{/other_user}","gists_url":"https://api.github.com/users/node-modules/gists{/gist_id}","starred_url":"https://api.github.com/users/node-modules/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/node-modules/subscriptions","organizations_url":"https://api.github.com/users/node-modules/orgs","repos_url":"https://api.github.com/users/node-modules/repos","events_url":"https://api.github.com/users/node-modules/events{/privacy}","received_events_url":"https://api.github.com/users/node-modules/received_events","type":"Organization","site_admin":false},"repo":{"id":18427025,"name":"ali-oss","full_name":"node-modules/ali-oss","owner":{"login":"node-modules","id":7125868,"avatar_url":"https://avatars.githubusercontent.com/u/7125868?v=3","gravatar_id":"","url":"https://api.github.com/users/node-modules","html_url":"https://github.com/node-modules","followers_url":"https://api.github.com/users/node-modules/followers","following_url":"https://api.github.com/users/node-modules/following{/other_user}","gists_url":"https://api.github.com/users/node-modules/gists{/gist_id}","starred_url":"https://api.github.com/users/node-modules/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/node-modules/subscriptions","organizations_url":"https://api.github.com/users/node-modules/orgs","repos_url":"https://api.github.com/users/node-modules/repos","events_url":"https://api.github.com/users/node-modules/events{/privacy}","received_events_url":"https://api.github.com/users/node-modules/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/node-modules/ali-oss","description":"aliyun OSS(open storage service) node client","fork":false,"url":"https://api.github.com/repos/node-modules/ali-oss","forks_url":"https://api.github.com/repos/node-modules/ali-oss/forks","keys_url":"https://api.github.com/repos/node-modules/ali-oss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/node-modules/ali-oss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/node-modules/ali-oss/teams","hooks_url":"https://api.github.com/repos/node-modules/ali-oss/hooks","issue_events_url":"https://api.github.com/repos/node-modules/ali-oss/issues/events{/number}","events_url":"https://api.github.com/repos/node-modules/ali-oss/events","assignees_url":"https://api.github.com/repos/node-modules/ali-oss/assignees{/user}","branches_url":"https://api.github.com/repos/node-modules/ali-oss/branches{/branch}","tags_url":"https://api.github.com/repos/node-modules/ali-oss/tags","blobs_url":"https://api.github.com/repos/node-modules/ali-oss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/node-modules/ali-oss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/node-modules/ali-oss/git/refs{/sha}","trees_url":"https://api.github.com/repos/node-modules/ali-oss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/node-modules/ali-oss/statuses/{sha}","languages_url":"https://api.github.com/repos/node-modules/ali-oss/languages","stargazers_url":"https://api.github.com/repos/node-modules/ali-oss/stargazers","contributors_url":"https://api.github.com/repos/node-modules/ali-oss/contributors","subscribers_url":"https://api.github.com/repos/node-modules/ali-oss/subscribers","subscription_url":"https://api.github.com/repos/node-modules/ali-oss/subscription","commits_url":"https://api.github.com/repos/node-modules/ali-oss/commits{/sha}","git_commits_url":"https://api.github.com/repos/node-modules/ali-oss/git/commits{/sha}","comments_url":"https://api.github.com/repos/node-modules/ali-oss/comments{/number}","issue_comment_url":"https://api.github.com/repos/node-modules/ali-oss/issues/comments{/number}","contents_url":"https://api.github.com/repos/node-modules/ali-oss/contents/{+path}","compare_url":"https://api.github.com/repos/node-modules/ali-oss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/node-modules/ali-oss/merges","archive_url":"https://api.github.com/repos/node-modules/ali-oss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/node-modules/ali-oss/downloads","issues_url":"https://api.github.com/repos/node-modules/ali-oss/issues{/number}","pulls_url":"https://api.github.com/repos/node-modules/ali-oss/pulls{/number}","milestones_url":"https://api.github.com/repos/node-modules/ali-oss/milestones{/number}","notifications_url":"https://api.github.com/repos/node-modules/ali-oss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/node-modules/ali-oss/labels{/name}","releases_url":"https://api.github.com/repos/node-modules/ali-oss/releases{/id}","created_at":"2014-04-04T04:04:08Z","updated_at":"2015-02-05T09:39:49Z","pushed_at":"2015-02-23T00:57:35Z","git_url":"git://github.com/node-modules/ali-oss.git","ssh_url":"git@github.com:node-modules/ali-oss.git","clone_url":"https://github.com/node-modules/ali-oss.git","svn_url":"https://github.com/node-modules/ali-oss","homepage":null,"size":259,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":1,"forks":7,"open_issues":1,"watchers":28,"default_branch":"master"}},"base":{"label":"node-modules:master","ref":"master","sha":"001359cb16ecd8fd9629e8d606ac9a164010c993","user":{"login":"node-modules","id":7125868,"avatar_url":"https://avatars.githubusercontent.com/u/7125868?v=3","gravatar_id":"","url":"https://api.github.com/users/node-modules","html_url":"https://github.com/node-modules","followers_url":"https://api.github.com/users/node-modules/followers","following_url":"https://api.github.com/users/node-modules/following{/other_user}","gists_url":"https://api.github.com/users/node-modules/gists{/gist_id}","starred_url":"https://api.github.com/users/node-modules/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/node-modules/subscriptions","organizations_url":"https://api.github.com/users/node-modules/orgs","repos_url":"https://api.github.com/users/node-modules/repos","events_url":"https://api.github.com/users/node-modules/events{/privacy}","received_events_url":"https://api.github.com/users/node-modules/received_events","type":"Organization","site_admin":false},"repo":{"id":18427025,"name":"ali-oss","full_name":"node-modules/ali-oss","owner":{"login":"node-modules","id":7125868,"avatar_url":"https://avatars.githubusercontent.com/u/7125868?v=3","gravatar_id":"","url":"https://api.github.com/users/node-modules","html_url":"https://github.com/node-modules","followers_url":"https://api.github.com/users/node-modules/followers","following_url":"https://api.github.com/users/node-modules/following{/other_user}","gists_url":"https://api.github.com/users/node-modules/gists{/gist_id}","starred_url":"https://api.github.com/users/node-modules/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/node-modules/subscriptions","organizations_url":"https://api.github.com/users/node-modules/orgs","repos_url":"https://api.github.com/users/node-modules/repos","events_url":"https://api.github.com/users/node-modules/events{/privacy}","received_events_url":"https://api.github.com/users/node-modules/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/node-modules/ali-oss","description":"aliyun OSS(open storage service) node client","fork":false,"url":"https://api.github.com/repos/node-modules/ali-oss","forks_url":"https://api.github.com/repos/node-modules/ali-oss/forks","keys_url":"https://api.github.com/repos/node-modules/ali-oss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/node-modules/ali-oss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/node-modules/ali-oss/teams","hooks_url":"https://api.github.com/repos/node-modules/ali-oss/hooks","issue_events_url":"https://api.github.com/repos/node-modules/ali-oss/issues/events{/number}","events_url":"https://api.github.com/repos/node-modules/ali-oss/events","assignees_url":"https://api.github.com/repos/node-modules/ali-oss/assignees{/user}","branches_url":"https://api.github.com/repos/node-modules/ali-oss/branches{/branch}","tags_url":"https://api.github.com/repos/node-modules/ali-oss/tags","blobs_url":"https://api.github.com/repos/node-modules/ali-oss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/node-modules/ali-oss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/node-modules/ali-oss/git/refs{/sha}","trees_url":"https://api.github.com/repos/node-modules/ali-oss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/node-modules/ali-oss/statuses/{sha}","languages_url":"https://api.github.com/repos/node-modules/ali-oss/languages","stargazers_url":"https://api.github.com/repos/node-modules/ali-oss/stargazers","contributors_url":"https://api.github.com/repos/node-modules/ali-oss/contributors","subscribers_url":"https://api.github.com/repos/node-modules/ali-oss/subscribers","subscription_url":"https://api.github.com/repos/node-modules/ali-oss/subscription","commits_url":"https://api.github.com/repos/node-modules/ali-oss/commits{/sha}","git_commits_url":"https://api.github.com/repos/node-modules/ali-oss/git/commits{/sha}","comments_url":"https://api.github.com/repos/node-modules/ali-oss/comments{/number}","issue_comment_url":"https://api.github.com/repos/node-modules/ali-oss/issues/comments{/number}","contents_url":"https://api.github.com/repos/node-modules/ali-oss/contents/{+path}","compare_url":"https://api.github.com/repos/node-modules/ali-oss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/node-modules/ali-oss/merges","archive_url":"https://api.github.com/repos/node-modules/ali-oss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/node-modules/ali-oss/downloads","issues_url":"https://api.github.com/repos/node-modules/ali-oss/issues{/number}","pulls_url":"https://api.github.com/repos/node-modules/ali-oss/pulls{/number}","milestones_url":"https://api.github.com/repos/node-modules/ali-oss/milestones{/number}","notifications_url":"https://api.github.com/repos/node-modules/ali-oss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/node-modules/ali-oss/labels{/name}","releases_url":"https://api.github.com/repos/node-modules/ali-oss/releases{/id}","created_at":"2014-04-04T04:04:08Z","updated_at":"2015-02-05T09:39:49Z","pushed_at":"2015-02-23T00:57:35Z","git_url":"git://github.com/node-modules/ali-oss.git","ssh_url":"git@github.com:node-modules/ali-oss.git","clone_url":"https://github.com/node-modules/ali-oss.git","svn_url":"https://github.com/node-modules/ali-oss","homepage":null,"size":259,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":1,"forks":7,"open_issues":1,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/node-modules/ali-oss/pulls/4"},"html":{"href":"https://github.com/node-modules/ali-oss/pull/4"},"issue":{"href":"https://api.github.com/repos/node-modules/ali-oss/issues/4"},"comments":{"href":"https://api.github.com/repos/node-modules/ali-oss/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/node-modules/ali-oss/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/node-modules/ali-oss/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/node-modules/ali-oss/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/node-modules/ali-oss/statuses/80304f4230f70a25b2f36330ce8306e8a79e41ef"}}}}