{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments/41558179","id":41558179,"diff_hunk":"@@ -0,0 +1,303 @@\n+# Copyright 2015 Google Inc. All rights reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+\"\"\"Define API Document.\"\"\"\n+\n+import datetime\n+\n+import six\n+\n+from gcloud._helpers import UTC, _RFC3339_MICROS\n+from gcloud.exceptions import NotFound\n+\n+\n+class StringValue(object):\n+    \"\"\"Values hold individual values for a given field\"\"\"\n+\n+    value_type = 'string'\n+\n+    def __init__(self, string_value, string_format=None, language=None):\n+        self.string_value = string_value\n+        self.string_format = string_format\n+        self.language = language\n+\n+\n+class NumberValue(object):\n+    \"\"\"Values hold individual values for a given field\"\"\"\n+\n+    value_type = 'number'\n+\n+    def __init__(self, number_value):\n+        self.number_value = number_value\n+\n+\n+class TimestampValue(object):\n+    \"\"\"Values hold individual values for a given field\"\"\"\n+\n+    value_type = 'timestamp'\n+\n+    def __init__(self, timestamp_value):\n+        self.timestamp_value = timestamp_value\n+\n+\n+class GeoValue(object):\n+    \"\"\"Values hold individual values for a given field\"\"\"\n+\n+    value_type = 'geo'\n+\n+    def __init__(self, geo_value):\n+        self.geo_value = geo_value\n+\n+\n+class Field(object):\n+    \"\"\"Fields hold values for a given document\"\"\"\n+\n+    def __init__(self, name):\n+        self.name = name\n+        self.values = []\n+\n+    def add_value(self, value, **kw):\n+        \"\"\"Add a value to the field.\n+\n+        Selects type of value instance based on type of ``value``.\n+\n+        :type value: string, integer, float, datetime, or tuple (float, float)\n+        :param value: the field value to add.\n+\n+        :param kw: extra keyword arguments to be passed to the value instance\n+                   constructor.\n+\n+        :raises: ValueError if unable to match the type of ``value``.\n+        \"\"\"\n+        if isinstance(value, six.string_types):\n+            self.values.append(StringValue(value, **kw))\n+        elif isinstance(value, (six.integer_types, float)):\n+            self.values.append(NumberValue(value, **kw))\n+        elif isinstance(value, datetime.datetime):\n+            self.values.append(TimestampValue(value, **kw))\n+        elif isinstance(value, tuple):\n+            self.values.append(GeoValue(value, **kw))\n+        else:\n+            raise ValueError(\"Couldn't determine value type: %s\" % value)","path":"gcloud/search/document.py","position":92,"original_position":92,"commit_id":"9210830691765fe825a6510d5f64fe8ffe795798","original_commit_id":"9210830691765fe825a6510d5f64fe8ffe795798","user":{"login":"dhermes","id":520669,"avatar_url":"https://avatars.githubusercontent.com/u/520669?v=3","gravatar_id":"","url":"https://api.github.com/users/dhermes","html_url":"https://github.com/dhermes","followers_url":"https://api.github.com/users/dhermes/followers","following_url":"https://api.github.com/users/dhermes/following{/other_user}","gists_url":"https://api.github.com/users/dhermes/gists{/gist_id}","starred_url":"https://api.github.com/users/dhermes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhermes/subscriptions","organizations_url":"https://api.github.com/users/dhermes/orgs","repos_url":"https://api.github.com/users/dhermes/repos","events_url":"https://api.github.com/users/dhermes/events{/privacy}","received_events_url":"https://api.github.com/users/dhermes/received_events","type":"User","site_admin":false},"body":"Small nit: pass a tuple to `%`","created_at":"2015-10-08T19:37:32Z","updated_at":"2015-10-08T19:37:32Z","html_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1173#discussion_r41558179","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1173","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments/41558179"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1173#discussion_r41558179"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1173"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1173","id":47193465,"html_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1173","diff_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1173.diff","patch_url":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1173.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/1173","number":1173,"state":"open","locked":false,"title":"Add document/field/value support.","user":{"login":"tseaver","id":242750,"avatar_url":"https://avatars.githubusercontent.com/u/242750?v=3","gravatar_id":"","url":"https://api.github.com/users/tseaver","html_url":"https://github.com/tseaver","followers_url":"https://api.github.com/users/tseaver/followers","following_url":"https://api.github.com/users/tseaver/following{/other_user}","gists_url":"https://api.github.com/users/tseaver/gists{/gist_id}","starred_url":"https://api.github.com/users/tseaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tseaver/subscriptions","organizations_url":"https://api.github.com/users/tseaver/orgs","repos_url":"https://api.github.com/users/tseaver/repos","events_url":"https://api.github.com/users/tseaver/events{/privacy}","received_events_url":"https://api.github.com/users/tseaver/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-08T19:10:37Z","updated_at":"2015-10-08T19:37:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52124c002043f4dce61e7677471777dcb22f7465","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1173/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1173/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/1173/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/statuses/9210830691765fe825a6510d5f64fe8ffe795798","head":{"label":"tseaver:search-document","ref":"search-document","sha":"9210830691765fe825a6510d5f64fe8ffe795798","user":{"login":"tseaver","id":242750,"avatar_url":"https://avatars.githubusercontent.com/u/242750?v=3","gravatar_id":"","url":"https://api.github.com/users/tseaver","html_url":"https://github.com/tseaver","followers_url":"https://api.github.com/users/tseaver/followers","following_url":"https://api.github.com/users/tseaver/following{/other_user}","gists_url":"https://api.github.com/users/tseaver/gists{/gist_id}","starred_url":"https://api.github.com/users/tseaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tseaver/subscriptions","organizations_url":"https://api.github.com/users/tseaver/orgs","repos_url":"https://api.github.com/users/tseaver/repos","events_url":"https://api.github.com/users/tseaver/events{/privacy}","received_events_url":"https://api.github.com/users/tseaver/received_events","type":"User","site_admin":false},"repo":{"id":23322104,"name":"gcloud-python","full_name":"tseaver/gcloud-python","owner":{"login":"tseaver","id":242750,"avatar_url":"https://avatars.githubusercontent.com/u/242750?v=3","gravatar_id":"","url":"https://api.github.com/users/tseaver","html_url":"https://github.com/tseaver","followers_url":"https://api.github.com/users/tseaver/followers","following_url":"https://api.github.com/users/tseaver/following{/other_user}","gists_url":"https://api.github.com/users/tseaver/gists{/gist_id}","starred_url":"https://api.github.com/users/tseaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tseaver/subscriptions","organizations_url":"https://api.github.com/users/tseaver/orgs","repos_url":"https://api.github.com/users/tseaver/repos","events_url":"https://api.github.com/users/tseaver/events{/privacy}","received_events_url":"https://api.github.com/users/tseaver/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tseaver/gcloud-python","description":"Google Cloud Python Client Library","fork":true,"url":"https://api.github.com/repos/tseaver/gcloud-python","forks_url":"https://api.github.com/repos/tseaver/gcloud-python/forks","keys_url":"https://api.github.com/repos/tseaver/gcloud-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tseaver/gcloud-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tseaver/gcloud-python/teams","hooks_url":"https://api.github.com/repos/tseaver/gcloud-python/hooks","issue_events_url":"https://api.github.com/repos/tseaver/gcloud-python/issues/events{/number}","events_url":"https://api.github.com/repos/tseaver/gcloud-python/events","assignees_url":"https://api.github.com/repos/tseaver/gcloud-python/assignees{/user}","branches_url":"https://api.github.com/repos/tseaver/gcloud-python/branches{/branch}","tags_url":"https://api.github.com/repos/tseaver/gcloud-python/tags","blobs_url":"https://api.github.com/repos/tseaver/gcloud-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tseaver/gcloud-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tseaver/gcloud-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/tseaver/gcloud-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tseaver/gcloud-python/statuses/{sha}","languages_url":"https://api.github.com/repos/tseaver/gcloud-python/languages","stargazers_url":"https://api.github.com/repos/tseaver/gcloud-python/stargazers","contributors_url":"https://api.github.com/repos/tseaver/gcloud-python/contributors","subscribers_url":"https://api.github.com/repos/tseaver/gcloud-python/subscribers","subscription_url":"https://api.github.com/repos/tseaver/gcloud-python/subscription","commits_url":"https://api.github.com/repos/tseaver/gcloud-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/tseaver/gcloud-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/tseaver/gcloud-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/tseaver/gcloud-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/tseaver/gcloud-python/contents/{+path}","compare_url":"https://api.github.com/repos/tseaver/gcloud-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tseaver/gcloud-python/merges","archive_url":"https://api.github.com/repos/tseaver/gcloud-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tseaver/gcloud-python/downloads","issues_url":"https://api.github.com/repos/tseaver/gcloud-python/issues{/number}","pulls_url":"https://api.github.com/repos/tseaver/gcloud-python/pulls{/number}","milestones_url":"https://api.github.com/repos/tseaver/gcloud-python/milestones{/number}","notifications_url":"https://api.github.com/repos/tseaver/gcloud-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tseaver/gcloud-python/labels{/name}","releases_url":"https://api.github.com/repos/tseaver/gcloud-python/releases{/id}","created_at":"2014-08-25T17:19:33Z","updated_at":"2015-04-10T19:42:56Z","pushed_at":"2015-10-08T19:10:09Z","git_url":"git://github.com/tseaver/gcloud-python.git","ssh_url":"git@github.com:tseaver/gcloud-python.git","clone_url":"https://github.com/tseaver/gcloud-python.git","svn_url":"https://github.com/tseaver/gcloud-python","homepage":"http://googlecloudplatform.github.io/gcloud-python/","size":10243,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"04dca83892723ee1bc70da41043ddde3a1996885","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":16316451,"name":"gcloud-python","full_name":"GoogleCloudPlatform/gcloud-python","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/gcloud-python","description":"Google Cloud Client Library for Python","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/releases{/id}","created_at":"2014-01-28T15:51:47Z","updated_at":"2015-09-30T12:49:34Z","pushed_at":"2015-10-08T19:10:37Z","git_url":"git://github.com/GoogleCloudPlatform/gcloud-python.git","ssh_url":"git@github.com:GoogleCloudPlatform/gcloud-python.git","clone_url":"https://github.com/GoogleCloudPlatform/gcloud-python.git","svn_url":"https://github.com/GoogleCloudPlatform/gcloud-python","homepage":"https://googlecloudplatform.github.io/gcloud-python/","size":41507,"stargazers_count":203,"watchers_count":203,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":111,"mirror_url":null,"open_issues_count":93,"forks":111,"open_issues":93,"watchers":203,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1173"},"html":{"href":"https://github.com/GoogleCloudPlatform/gcloud-python/pull/1173"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/1173"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/issues/1173/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1173/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/pulls/1173/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/gcloud-python/statuses/9210830691765fe825a6510d5f64fe8ffe795798"}}}}