{"action":"created","comment":{"url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/comments/93412149","pull_request_review_id":13930934,"id":93412149,"diff_hunk":"@@ -638,41 +642,40 @@ public static ClientBuilder bluemix() {\n      * service instance.\n      * <P>\n      * Note: Specifying a service name is only required when multiple Cloudant services are\n-     * available. If there is only a single bound Cloudant service instance then {@link #bluemix()}\n-     * can also be used.\n+     * available. If there is only a single bound Cloudant service instance then\n+     * {@link #bluemix(String)} can also be used.\n      * </P>\n      *\n-     * @param serviceName name of Bluemix service instance or {@code null} to try to use the only\n+     * @param vcapServices contents of VCAP_SERVICES environment variable\n+     * @param instanceName name of Bluemix service instance or {@code null} to try to use the only\n      *                    available Cloudant service\n      * @return a new ClientBuilder for the account\n      *\n      * @throws IllegalArgumentException if the Cloudant service instance is not available\n-     * @throws IllegalStateException    if the VCAP_SERVICES environment variable is invalid or missing\n      */\n-    public static ClientBuilder bluemix(String serviceName) {\n+    public static ClientBuilder bluemix(String vcapServices, String instanceName) {\n         Gson gson = new GsonBuilder().create();\n \n-        String vcap_env = System.getenv(\"VCAP_SERVICES\");\n-        if (vcap_env == null) {\n-            throw new IllegalStateException(\"VCAP_SERVICES is not present.\");\n+        if (vcapServices == null) {\n+            throw new IllegalArgumentException(\"VCAP_SERVICES is not present.\");\n         }\n \n         CloudFoundryServices services;\n         try {\n-            services = gson.fromJson(vcap_env, CloudFoundryServices.class);\n+            services = gson.fromJson(vcapServices, CloudFoundryServices.class);\n         } catch (JsonParseException e){\n-            throw new IllegalStateException(\"VCAP_SERVICES is not valid JSON.\", e);\n+            throw new IllegalArgumentException(\"VCAP_SERVICES is not valid JSON.\", e);\n         }\n \n         if (services.cloudantNoSQLDB == null || services.cloudantNoSQLDB.size() == 0) {\n-            throw new IllegalStateException(\"No Cloudant services present.\");\n+            throw new IllegalArgumentException(\"No Cloudant services present.\");\n         }\n \n-        if (serviceName == null) {\n+        if (instanceName == null) {\n             if (services.cloudantNoSQLDB.size() == 1) {\n                 CloudFoundryServices.CloudFoundryService service = services.cloudantNoSQLDB.get(0);\n                 if (service.credentials == null || service.credentials.url == null) {\n-                    throw new IllegalStateException(\"Invalid VCAP_SERVICES services.\");\n+                    throw new IllegalArgumentException(\"Invalid VCAP_SERVICES services.\");","path":"cloudant-client/src/main/java/com/cloudant/client/api/ClientBuilder.java","position":71,"original_position":71,"commit_id":"7ae1d6f57409ec2d410ed39672a4ea2713a8cfe7","original_commit_id":"7ae1d6f57409ec2d410ed39672a4ea2713a8cfe7","user":{"login":"ricellis","id":10698320,"avatar_url":"https://avatars.githubusercontent.com/u/10698320?v=3","gravatar_id":"","url":"https://api.github.com/users/ricellis","html_url":"https://github.com/ricellis","followers_url":"https://api.github.com/users/ricellis/followers","following_url":"https://api.github.com/users/ricellis/following{/other_user}","gists_url":"https://api.github.com/users/ricellis/gists{/gist_id}","starred_url":"https://api.github.com/users/ricellis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricellis/subscriptions","organizations_url":"https://api.github.com/users/ricellis/orgs","repos_url":"https://api.github.com/users/ricellis/repos","events_url":"https://api.github.com/users/ricellis/events{/privacy}","received_events_url":"https://api.github.com/users/ricellis/received_events","type":"User","site_admin":false},"body":"Maybe:\r\nThe Cloudant service instance information was invalid.","created_at":"2016-12-21T10:23:50Z","updated_at":"2016-12-21T10:38:33Z","html_url":"https://github.com/cloudant/java-cloudant/pull/330#discussion_r93412149","pull_request_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/330","_links":{"self":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/comments/93412149"},"html":{"href":"https://github.com/cloudant/java-cloudant/pull/330#discussion_r93412149"},"pull_request":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/330"}}},"pull_request":{"url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/330","id":98729759,"html_url":"https://github.com/cloudant/java-cloudant/pull/330","diff_url":"https://github.com/cloudant/java-cloudant/pull/330.diff","patch_url":"https://github.com/cloudant/java-cloudant/pull/330.patch","issue_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/330","number":330,"state":"open","locked":false,"title":"323 pass vcap as builder arg","user":{"login":"smithsz","id":5632401,"avatar_url":"https://avatars.githubusercontent.com/u/5632401?v=3","gravatar_id":"","url":"https://api.github.com/users/smithsz","html_url":"https://github.com/smithsz","followers_url":"https://api.github.com/users/smithsz/followers","following_url":"https://api.github.com/users/smithsz/following{/other_user}","gists_url":"https://api.github.com/users/smithsz/gists{/gist_id}","starred_url":"https://api.github.com/users/smithsz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smithsz/subscriptions","organizations_url":"https://api.github.com/users/smithsz/orgs","repos_url":"https://api.github.com/users/smithsz/repos","events_url":"https://api.github.com/users/smithsz/events{/privacy}","received_events_url":"https://api.github.com/users/smithsz/received_events","type":"User","site_admin":false},"body":"## What\r\nPass the VCAP_SERVICES variable as an argument rather than pulling it\r\nfrom the environment. This allows the application to retrieve it from\r\ndifferent sources and avoids the library dictating deployment policy to\r\nthe consuming application.\r\n\r\n## How\r\nAdd additional `vcapServices` argument to bluemix builder.\r\n\r\n## Testing\r\nUpdated tests to use new argument.\r\n\r\n## Issues\r\nFixes #323.\r\n","created_at":"2016-12-20T11:16:13Z","updated_at":"2016-12-21T10:38:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c2691a984fa0b505d31185bdbc3f4060d213885","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/330/commits","review_comments_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/330/comments","review_comment_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/330/comments","statuses_url":"https://api.github.com/repos/cloudant/java-cloudant/statuses/7ae1d6f57409ec2d410ed39672a4ea2713a8cfe7","head":{"label":"cloudant:323-pass-vcap-as-builder-arg","ref":"323-pass-vcap-as-builder-arg","sha":"7ae1d6f57409ec2d410ed39672a4ea2713a8cfe7","user":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"repo":{"id":22873328,"name":"java-cloudant","full_name":"cloudant/java-cloudant","owner":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudant/java-cloudant","description":"A Java client for Cloudant","fork":false,"url":"https://api.github.com/repos/cloudant/java-cloudant","forks_url":"https://api.github.com/repos/cloudant/java-cloudant/forks","keys_url":"https://api.github.com/repos/cloudant/java-cloudant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudant/java-cloudant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudant/java-cloudant/teams","hooks_url":"https://api.github.com/repos/cloudant/java-cloudant/hooks","issue_events_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/events{/number}","events_url":"https://api.github.com/repos/cloudant/java-cloudant/events","assignees_url":"https://api.github.com/repos/cloudant/java-cloudant/assignees{/user}","branches_url":"https://api.github.com/repos/cloudant/java-cloudant/branches{/branch}","tags_url":"https://api.github.com/repos/cloudant/java-cloudant/tags","blobs_url":"https://api.github.com/repos/cloudant/java-cloudant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudant/java-cloudant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudant/java-cloudant/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudant/java-cloudant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudant/java-cloudant/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudant/java-cloudant/languages","stargazers_url":"https://api.github.com/repos/cloudant/java-cloudant/stargazers","contributors_url":"https://api.github.com/repos/cloudant/java-cloudant/contributors","subscribers_url":"https://api.github.com/repos/cloudant/java-cloudant/subscribers","subscription_url":"https://api.github.com/repos/cloudant/java-cloudant/subscription","commits_url":"https://api.github.com/repos/cloudant/java-cloudant/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudant/java-cloudant/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudant/java-cloudant/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudant/java-cloudant/contents/{+path}","compare_url":"https://api.github.com/repos/cloudant/java-cloudant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudant/java-cloudant/merges","archive_url":"https://api.github.com/repos/cloudant/java-cloudant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudant/java-cloudant/downloads","issues_url":"https://api.github.com/repos/cloudant/java-cloudant/issues{/number}","pulls_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudant/java-cloudant/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudant/java-cloudant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudant/java-cloudant/labels{/name}","releases_url":"https://api.github.com/repos/cloudant/java-cloudant/releases{/id}","deployments_url":"https://api.github.com/repos/cloudant/java-cloudant/deployments","created_at":"2014-08-12T10:19:56Z","updated_at":"2016-11-30T12:58:22Z","pushed_at":"2016-12-20T16:35:25Z","git_url":"git://github.com/cloudant/java-cloudant.git","ssh_url":"git@github.com:cloudant/java-cloudant.git","clone_url":"https://github.com/cloudant/java-cloudant.git","svn_url":"https://github.com/cloudant/java-cloudant","homepage":null,"size":3658,"stargazers_count":38,"watchers_count":38,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":21,"forks":36,"open_issues":21,"watchers":38,"default_branch":"master"}},"base":{"label":"cloudant:master","ref":"master","sha":"2f1ef23ba0c7bed67e9946a7ff9caeff63f9100e","user":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"repo":{"id":22873328,"name":"java-cloudant","full_name":"cloudant/java-cloudant","owner":{"login":"cloudant","id":44642,"avatar_url":"https://avatars.githubusercontent.com/u/44642?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudant","html_url":"https://github.com/cloudant","followers_url":"https://api.github.com/users/cloudant/followers","following_url":"https://api.github.com/users/cloudant/following{/other_user}","gists_url":"https://api.github.com/users/cloudant/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudant/subscriptions","organizations_url":"https://api.github.com/users/cloudant/orgs","repos_url":"https://api.github.com/users/cloudant/repos","events_url":"https://api.github.com/users/cloudant/events{/privacy}","received_events_url":"https://api.github.com/users/cloudant/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudant/java-cloudant","description":"A Java client for Cloudant","fork":false,"url":"https://api.github.com/repos/cloudant/java-cloudant","forks_url":"https://api.github.com/repos/cloudant/java-cloudant/forks","keys_url":"https://api.github.com/repos/cloudant/java-cloudant/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudant/java-cloudant/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudant/java-cloudant/teams","hooks_url":"https://api.github.com/repos/cloudant/java-cloudant/hooks","issue_events_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/events{/number}","events_url":"https://api.github.com/repos/cloudant/java-cloudant/events","assignees_url":"https://api.github.com/repos/cloudant/java-cloudant/assignees{/user}","branches_url":"https://api.github.com/repos/cloudant/java-cloudant/branches{/branch}","tags_url":"https://api.github.com/repos/cloudant/java-cloudant/tags","blobs_url":"https://api.github.com/repos/cloudant/java-cloudant/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudant/java-cloudant/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudant/java-cloudant/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudant/java-cloudant/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudant/java-cloudant/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudant/java-cloudant/languages","stargazers_url":"https://api.github.com/repos/cloudant/java-cloudant/stargazers","contributors_url":"https://api.github.com/repos/cloudant/java-cloudant/contributors","subscribers_url":"https://api.github.com/repos/cloudant/java-cloudant/subscribers","subscription_url":"https://api.github.com/repos/cloudant/java-cloudant/subscription","commits_url":"https://api.github.com/repos/cloudant/java-cloudant/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudant/java-cloudant/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudant/java-cloudant/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudant/java-cloudant/issues/comments{/number}","contents_url":"https://api.github.com/repos/cloudant/java-cloudant/contents/{+path}","compare_url":"https://api.github.com/repos/cloudant/java-cloudant/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudant/java-cloudant/merges","archive_url":"https://api.github.com/repos/cloudant/java-cloudant/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudant/java-cloudant/downloads","issues_url":"https://api.github.com/repos/cloudant/java-cloudant/issues{/number}","pulls_url":"https://api.github.com/repos/cloudant/java-cloudant/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudant/java-cloudant/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudant/java-cloudant/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudant/java-cloudant/labels{/name}","releases_url":"https://api.github.com/repos/cloudant/java-cloudant/releases{/id}","deployments_url":"https://api.github.com/repos/cloudant/java-cloudant/deployments","created_at":"2014-08-12T10:19:56Z","updated_at":"2016-11-30T12:58:22Z","pushed_at":"2016-12-20T16:35:25Z","git_url":"git://github.com/cloudant/java-cloudant.git","ssh_url":"git@github.com:cloudant/java-cloudant.git","clone_url":"https://github.com/cloudant/java-cloudant.git","svn_url":"https://github.com/cloudant/java-cloudant","homepage":null,"size":3658,"stargazers_count":38,"watchers_count":38,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":21,"forks":36,"open_issues":21,"watchers":38,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/330"},"html":{"href":"https://github.com/cloudant/java-cloudant/pull/330"},"issue":{"href":"https://api.github.com/repos/cloudant/java-cloudant/issues/330"},"comments":{"href":"https://api.github.com/repos/cloudant/java-cloudant/issues/330/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/330/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cloudant/java-cloudant/pulls/330/commits"},"statuses":{"href":"https://api.github.com/repos/cloudant/java-cloudant/statuses/7ae1d6f57409ec2d410ed39672a4ea2713a8cfe7"}}}}
{"actor":{"display_login":"ricellis"}}