{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/comments/27412874","id":27412874,"diff_hunk":"@@ -273,6 +277,193 @@ def listbucket(path_prefix, marker=None, prefix=None, max_keys=None,\n   return _Bucket(api, bucket, options)\n \n \n+# pylint: disable=too-many-locals, too-many-branches, too-many-statements\n+def compose(list_of_files, destination_file, files_metadata=None,\n+            content_type=None, retry_params=None, _account_id=None):\n+  \"\"\"Runs the GCS Compose on the given files.\n+\n+  Merges between 2 and 32 files into one file. Composite files may even\n+    be built from other existing composites, provided that the total\n+    component count does not exceed 1024. See here for details:\n+    https://cloud.google.com/storage/docs/composite-objects\n+  Args:\n+    list_of_files: List of file name strings with no leading slashes or bucket.\n+    destination_file: Path to the desired output file. Must have the bucket in the path.\n+    files_metadata: Optional, file metadata, order must match list_of_files,\n+      see link for available options:\n+      https://cloud.google.com/storage/docs/composite-objects#_Xml\n+    content_type: Optional, used to specify the content-header of the output file.\n+    retry_params: Optional, an api_utils.RetryParams for this call to GCS. If None,\n+      the default one is used.\n+    _account_id: Internal-use only.\n+\n+  Raises:\n+    ValueError: If the number of files is outside the range of 2-32.\n+  \"\"\"\n+  api = storage_api._get_storage_api(retry_params=retry_params,\n+                                     account_id=_account_id)\n+  \"\"\"\n+  Needed until cloudstorage_stub.py is updated to accept compose requests\n+  TODO: When patched remove the True flow from this if.\n+  \"\"\"\n+  if os.getenv('SERVER_SOFTWARE').startswith('Dev'):\n+    def _temp_func(file_list, destination_file, content_type):\n+      \"\"\"Dev server stub, remove when the dev server accepts compose requests.\"\"\"\n+      bucket = '/' + destination_file.split('/')[1] + '/'\n+      with open(destination_file, 'w', content_type=content_type) as gcs_merge:\n+        for source_file in file_list:\n+          try:\n+            with open(bucket + source_file['Name'], 'r') as gcs_source:\n+              gcs_merge.write(gcs_source.read())\n+          except errors.NotFoundError as error:\n+            raise error\n+    compose_object = _temp_func\n+  else:\n+    compose_object = api.compose_object\n+  file_list, _ = _validate_compose_list(destination_file,\n+                                        list_of_files,\n+                                        files_metadata, 32)\n+  compose_object(file_list, destination_file, content_type)\n+\n+\n+def _compose_batch(list_of_files, destination_file, files_metadata=None,","path":"python/src/cloudstorage/cloudstorage_api.py","position":69,"original_position":69,"commit_id":"e9e23359245f9032859198431e53bd0d85c18f91","original_commit_id":"e9e23359245f9032859198431e53bd0d85c18f91","user":{"login":"aozarov","id":8921691,"avatar_url":"https://avatars.githubusercontent.com/u/8921691?v=3","gravatar_id":"","url":"https://api.github.com/users/aozarov","html_url":"https://github.com/aozarov","followers_url":"https://api.github.com/users/aozarov/followers","following_url":"https://api.github.com/users/aozarov/following{/other_user}","gists_url":"https://api.github.com/users/aozarov/gists{/gist_id}","starred_url":"https://api.github.com/users/aozarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aozarov/subscriptions","organizations_url":"https://api.github.com/users/aozarov/orgs","repos_url":"https://api.github.com/users/aozarov/repos","events_url":"https://api.github.com/users/aozarov/events{/privacy}","received_events_url":"https://api.github.com/users/aozarov/received_events","type":"User","site_admin":false},"body":"Such logic should move to the caller (e.g. MR) which can better handle its temporary files (location, name, cleanup) and chunks strategy. ","created_at":"2015-03-30T17:36:10Z","updated_at":"2015-03-30T17:36:10Z","html_url":"https://github.com/GoogleCloudPlatform/appengine-gcs-client/pull/6#discussion_r27412874","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/comments/27412874"},"html":{"href":"https://github.com/GoogleCloudPlatform/appengine-gcs-client/pull/6#discussion_r27412874"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/6","id":31739249,"html_url":"https://github.com/GoogleCloudPlatform/appengine-gcs-client/pull/6","diff_url":"https://github.com/GoogleCloudPlatform/appengine-gcs-client/pull/6.diff","patch_url":"https://github.com/GoogleCloudPlatform/appengine-gcs-client/pull/6.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/issues/6","number":6,"state":"open","locked":false,"title":"Added compose to the cloudstorage library","user":{"login":"rbruyere","id":10036537,"avatar_url":"https://avatars.githubusercontent.com/u/10036537?v=3","gravatar_id":"","url":"https://api.github.com/users/rbruyere","html_url":"https://github.com/rbruyere","followers_url":"https://api.github.com/users/rbruyere/followers","following_url":"https://api.github.com/users/rbruyere/following{/other_user}","gists_url":"https://api.github.com/users/rbruyere/gists{/gist_id}","starred_url":"https://api.github.com/users/rbruyere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbruyere/subscriptions","organizations_url":"https://api.github.com/users/rbruyere/orgs","repos_url":"https://api.github.com/users/rbruyere/repos","events_url":"https://api.github.com/users/rbruyere/events{/privacy}","received_events_url":"https://api.github.com/users/rbruyere/received_events","type":"User","site_admin":false},"body":"Added the compose functionality to the cloudstorage library with a basic\r\ntest site.","created_at":"2015-03-23T14:55:06Z","updated_at":"2015-03-30T17:36:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4677b0d3754e525a7392a2c9b096cc7a3ef23416","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/6/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/6/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/issues/6/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/statuses/e9e23359245f9032859198431e53bd0d85c18f91","head":{"label":"rbruyere:master","ref":"master","sha":"e9e23359245f9032859198431e53bd0d85c18f91","user":{"login":"rbruyere","id":10036537,"avatar_url":"https://avatars.githubusercontent.com/u/10036537?v=3","gravatar_id":"","url":"https://api.github.com/users/rbruyere","html_url":"https://github.com/rbruyere","followers_url":"https://api.github.com/users/rbruyere/followers","following_url":"https://api.github.com/users/rbruyere/following{/other_user}","gists_url":"https://api.github.com/users/rbruyere/gists{/gist_id}","starred_url":"https://api.github.com/users/rbruyere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbruyere/subscriptions","organizations_url":"https://api.github.com/users/rbruyere/orgs","repos_url":"https://api.github.com/users/rbruyere/repos","events_url":"https://api.github.com/users/rbruyere/events{/privacy}","received_events_url":"https://api.github.com/users/rbruyere/received_events","type":"User","site_admin":false},"repo":{"id":31367258,"name":"appengine-gcs-client","full_name":"rbruyere/appengine-gcs-client","owner":{"login":"rbruyere","id":10036537,"avatar_url":"https://avatars.githubusercontent.com/u/10036537?v=3","gravatar_id":"","url":"https://api.github.com/users/rbruyere","html_url":"https://github.com/rbruyere","followers_url":"https://api.github.com/users/rbruyere/followers","following_url":"https://api.github.com/users/rbruyere/following{/other_user}","gists_url":"https://api.github.com/users/rbruyere/gists{/gist_id}","starred_url":"https://api.github.com/users/rbruyere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbruyere/subscriptions","organizations_url":"https://api.github.com/users/rbruyere/orgs","repos_url":"https://api.github.com/users/rbruyere/repos","events_url":"https://api.github.com/users/rbruyere/events{/privacy}","received_events_url":"https://api.github.com/users/rbruyere/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rbruyere/appengine-gcs-client","description":null,"fork":true,"url":"https://api.github.com/repos/rbruyere/appengine-gcs-client","forks_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/forks","keys_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/teams","hooks_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/hooks","issue_events_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/issues/events{/number}","events_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/events","assignees_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/assignees{/user}","branches_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/branches{/branch}","tags_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/tags","blobs_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/statuses/{sha}","languages_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/languages","stargazers_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/stargazers","contributors_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/contributors","subscribers_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/subscribers","subscription_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/subscription","commits_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/contents/{+path}","compare_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/merges","archive_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/downloads","issues_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/issues{/number}","pulls_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/pulls{/number}","milestones_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/milestones{/number}","notifications_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/labels{/name}","releases_url":"https://api.github.com/repos/rbruyere/appengine-gcs-client/releases{/id}","created_at":"2015-02-26T13:02:40Z","updated_at":"2015-03-30T15:49:36Z","pushed_at":"2015-03-30T15:49:35Z","git_url":"git://github.com/rbruyere/appengine-gcs-client.git","ssh_url":"git@github.com:rbruyere/appengine-gcs-client.git","clone_url":"https://github.com/rbruyere/appengine-gcs-client.git","svn_url":"https://github.com/rbruyere/appengine-gcs-client","homepage":null,"size":4497,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"00ba52e8ef7f9eaba43c6a787e10986506fdd95c","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":24478161,"name":"appengine-gcs-client","full_name":"GoogleCloudPlatform/appengine-gcs-client","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/appengine-gcs-client","description":null,"fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/releases{/id}","created_at":"2014-09-25T22:54:39Z","updated_at":"2015-03-18T19:32:52Z","pushed_at":"2015-03-30T15:49:36Z","git_url":"git://github.com/GoogleCloudPlatform/appengine-gcs-client.git","ssh_url":"git@github.com:GoogleCloudPlatform/appengine-gcs-client.git","clone_url":"https://github.com/GoogleCloudPlatform/appengine-gcs-client.git","svn_url":"https://github.com/GoogleCloudPlatform/appengine-gcs-client","homepage":null,"size":4889,"stargazers_count":24,"watchers_count":24,"language":"Java","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":5,"forks":4,"open_issues":5,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/6"},"html":{"href":"https://github.com/GoogleCloudPlatform/appengine-gcs-client/pull/6"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/issues/6"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/appengine-gcs-client/statuses/e9e23359245f9032859198431e53bd0d85c18f91"}}}}