{"action":"created","comment":{"url":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/comments/127075019","pull_request_review_id":49623309,"id":127075019,"diff_hunk":"@@ -0,0 +1,114 @@\n+/*\n+ * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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+ * A copy of the License is located at\n+ *\n+ *  http://aws.amazon.com/apache2.0\n+ *\n+ * or in the \"license\" file accompanying this file. This file is distributed\n+ * on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n+ * express or implied. See the License for the specific language governing\n+ * permissions and limitations under the License.\n+ */\n+\n+package software.amazon.awssdk.codegen.poet.client;\n+\n+import com.squareup.javapoet.ClassName;\n+import com.squareup.javapoet.FieldSpec;\n+import com.squareup.javapoet.MethodSpec;\n+import com.squareup.javapoet.TypeSpec;\n+import java.util.List;\n+import javax.lang.model.element.Modifier;\n+import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;\n+import software.amazon.awssdk.codegen.model.intermediate.OperationModel;\n+import software.amazon.awssdk.codegen.poet.ClassSpec;\n+import software.amazon.awssdk.codegen.poet.PoetExtensions;\n+import software.amazon.awssdk.codegen.poet.PoetUtils;\n+import software.amazon.awssdk.regions.Region;\n+\n+public class ClientSimpleMethods implements ClassSpec {\n+\n+    private static final String APPROVED_VERBS = \"(get|list|describe).*\";\n+\n+    private final IntermediateModel model;\n+    private final PoetExtensions poetExtensions;\n+\n+    public ClientSimpleMethods(IntermediateModel model) {\n+        this.model = model;\n+        this.poetExtensions = new PoetExtensions(model);\n+    }\n+\n+    @Override\n+    public TypeSpec poetSpec() {\n+\n+        ClassName className = poetExtensions.getClientClass(\"SimpleMethodsIntegrationTest\");\n+        ClassName interfaceClass = poetExtensions.getClientClass(model.getMetadata().getSyncInterface());\n+        List<String> whitelistedApis = model.getCustomizationConfig().getVerifiedSimpleMethods();\n+\n+        TypeSpec.Builder builder = PoetUtils.createClassBuilder(className)\n+                                            .addModifiers(Modifier.PUBLIC)\n+                                            .addField(FieldSpec.builder(interfaceClass, \"client\")\n+                                                               .addModifiers(Modifier.PRIVATE, Modifier.STATIC)\n+                                                               .build())\n+                                            .addMethod(setup());\n+\n+        model.getOperations().entrySet().stream()\n+             .filter(v -> v.getValue().getInputShape().isSimpleMethod())\n+             .filter(v -> !whitelistedApis.contains(v.getValue().getMethodName()))\n+             .filter(v -> v.getValue().getMethodName().matches(APPROVED_VERBS))\n+             .map(o -> simpleMethodsTest(o.getValue()))\n+             .forEach(builder::addMethod);\n+\n+        return builder.build();\n+    }\n+\n+    @Override\n+    public ClassName className() {\n+        return poetExtensions.getClientClass(\"SimpleMethodsIntegrationTest\");\n+    }\n+\n+    /**\n+     * Creates a setup method for instantiating a new client. If no regions are present for a service,\n+     * us-east-1 will be used. If the service is available in aws-global, that region will be used. If the\n+     * service is not available in aws-global but is in us-east-1, that region will be used. If a service is\n+     * not available in us-east-1 or aws-global, the first region in the available regions for a service will\n+     * be used.\n+     */\n+    private MethodSpec setup() {\n+        ClassName beforeClass = ClassName.get(\"org.junit\", \"BeforeClass\");\n+        ClassName interfaceClass = poetExtensions.getClientClass(model.getMetadata().getSyncInterface());\n+        return MethodSpec.methodBuilder(\"setup\")\n+                         .addAnnotation(beforeClass)\n+                         .addModifiers(Modifier.PUBLIC, Modifier.STATIC)\n+                         .beginControlFlow(\"if ($T.serviceMetadata().regions().isEmpty())\", interfaceClass)\n+                         .addStatement(\"client = $T.builder().region(Region.US_EAST_1).build()\", interfaceClass)","path":"codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/ClientSimpleMethods.java","position":86,"original_position":86,"commit_id":"5dc57aeb9b9f110d26fa57e9de5e9bde2bc2f1c6","original_commit_id":"5dc57aeb9b9f110d26fa57e9de5e9bde2bc2f1c6","user":{"login":"kiiadi","id":4661536,"avatar_url":"https://avatars0.githubusercontent.com/u/4661536?v=3","gravatar_id":"","url":"https://api.github.com/users/kiiadi","html_url":"https://github.com/kiiadi","followers_url":"https://api.github.com/users/kiiadi/followers","following_url":"https://api.github.com/users/kiiadi/following{/other_user}","gists_url":"https://api.github.com/users/kiiadi/gists{/gist_id}","starred_url":"https://api.github.com/users/kiiadi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiiadi/subscriptions","organizations_url":"https://api.github.com/users/kiiadi/orgs","repos_url":"https://api.github.com/users/kiiadi/repos","events_url":"https://api.github.com/users/kiiadi/events{/privacy}","received_events_url":"https://api.github.com/users/kiiadi/received_events","type":"User","site_admin":false},"body":"I don't think performance is *that* critical during generation. I think we should use placeholders in the majority of places to protect ourselves from future refactors.","created_at":"2017-07-12T21:19:53Z","updated_at":"2017-07-12T21:19:53Z","html_url":"https://github.com/aws/aws-sdk-java-v2/pull/9#discussion_r127075019","pull_request_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/comments/127075019"},"html":{"href":"https://github.com/aws/aws-sdk-java-v2/pull/9#discussion_r127075019"},"pull_request":{"href":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/9","id":128241321,"html_url":"https://github.com/aws/aws-sdk-java-v2/pull/9","diff_url":"https://github.com/aws/aws-sdk-java-v2/pull/9.diff","patch_url":"https://github.com/aws/aws-sdk-java-v2/pull/9.patch","issue_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/9","number":9,"state":"open","locked":false,"title":"Adding simple methods for requests that have no required arguments","user":{"login":"spfink","id":20525381,"avatar_url":"https://avatars2.githubusercontent.com/u/20525381?v=3","gravatar_id":"","url":"https://api.github.com/users/spfink","html_url":"https://github.com/spfink","followers_url":"https://api.github.com/users/spfink/followers","following_url":"https://api.github.com/users/spfink/following{/other_user}","gists_url":"https://api.github.com/users/spfink/gists{/gist_id}","starred_url":"https://api.github.com/users/spfink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spfink/subscriptions","organizations_url":"https://api.github.com/users/spfink/orgs","repos_url":"https://api.github.com/users/spfink/repos","events_url":"https://api.github.com/users/spfink/events{/privacy}","received_events_url":"https://api.github.com/users/spfink/received_events","type":"User","site_admin":false},"body":"This PR will add a simple method for all requests that don't have required members. For example, S3 will now have a listBuckets() as well as listBuckets(ListBucketsRequest listBucketsRequest)\r\n\r\nThis does open the door to issues with backwards compatibility. While we always strive to not introduce backwards incompatible changes, if an API does move a member from optional to required, this would lead to potentially breaking customers at compile time if they were using one of these simple methods which would then be removed. The method would already be broken as the request requires a member so it may be better to have a clean compile time break vs a runtime break once they try to use the method.","created_at":"2017-06-29T20:34:14Z","updated_at":"2017-07-12T21:19:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7dd7f46f184fa3ea48d772f381a6bbd2c65fb013","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/9/commits","review_comments_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/9/comments","review_comment_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/9/comments","statuses_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/statuses/5dc57aeb9b9f110d26fa57e9de5e9bde2bc2f1c6","head":{"label":"aws:finks/simplemethods","ref":"finks/simplemethods","sha":"5dc57aeb9b9f110d26fa57e9de5e9bde2bc2f1c6","user":{"login":"aws","id":2232217,"avatar_url":"https://avatars0.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"repo":{"id":95247959,"name":"aws-sdk-java-v2","full_name":"aws/aws-sdk-java-v2","owner":{"login":"aws","id":2232217,"avatar_url":"https://avatars0.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aws/aws-sdk-java-v2","description":"The official AWS SDK for Java - Version 2 (Developer Preview)","fork":false,"url":"https://api.github.com/repos/aws/aws-sdk-java-v2","forks_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/forks","keys_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/teams","hooks_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/hooks","issue_events_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/events{/number}","events_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/events","assignees_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/assignees{/user}","branches_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/branches{/branch}","tags_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/tags","blobs_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/refs{/sha}","trees_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/statuses/{sha}","languages_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/languages","stargazers_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/stargazers","contributors_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/contributors","subscribers_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/subscribers","subscription_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/subscription","commits_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/commits{/sha}","git_commits_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/commits{/sha}","comments_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/comments{/number}","issue_comment_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/comments{/number}","contents_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/contents/{+path}","compare_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/merges","archive_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/downloads","issues_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues{/number}","pulls_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls{/number}","milestones_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/milestones{/number}","notifications_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/labels{/name}","releases_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/releases{/id}","deployments_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/deployments","created_at":"2017-06-23T18:56:01Z","updated_at":"2017-07-11T18:35:17Z","pushed_at":"2017-07-12T17:57:19Z","git_url":"git://github.com/aws/aws-sdk-java-v2.git","ssh_url":"git@github.com:aws/aws-sdk-java-v2.git","clone_url":"https://github.com/aws/aws-sdk-java-v2.git","svn_url":"https://github.com/aws/aws-sdk-java-v2","homepage":"","size":5429,"stargazers_count":41,"watchers_count":41,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":47,"forks":5,"open_issues":47,"watchers":41,"default_branch":"master"}},"base":{"label":"aws:develop","ref":"develop","sha":"45e66ddcf3b4f337e3a5b0f5fe815d5cb06fae47","user":{"login":"aws","id":2232217,"avatar_url":"https://avatars0.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"repo":{"id":95247959,"name":"aws-sdk-java-v2","full_name":"aws/aws-sdk-java-v2","owner":{"login":"aws","id":2232217,"avatar_url":"https://avatars0.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aws/aws-sdk-java-v2","description":"The official AWS SDK for Java - Version 2 (Developer Preview)","fork":false,"url":"https://api.github.com/repos/aws/aws-sdk-java-v2","forks_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/forks","keys_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/teams","hooks_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/hooks","issue_events_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/events{/number}","events_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/events","assignees_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/assignees{/user}","branches_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/branches{/branch}","tags_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/tags","blobs_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/refs{/sha}","trees_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/statuses/{sha}","languages_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/languages","stargazers_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/stargazers","contributors_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/contributors","subscribers_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/subscribers","subscription_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/subscription","commits_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/commits{/sha}","git_commits_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/git/commits{/sha}","comments_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/comments{/number}","issue_comment_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/comments{/number}","contents_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/contents/{+path}","compare_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/merges","archive_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/downloads","issues_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues{/number}","pulls_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls{/number}","milestones_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/milestones{/number}","notifications_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/labels{/name}","releases_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/releases{/id}","deployments_url":"https://api.github.com/repos/aws/aws-sdk-java-v2/deployments","created_at":"2017-06-23T18:56:01Z","updated_at":"2017-07-11T18:35:17Z","pushed_at":"2017-07-12T17:57:19Z","git_url":"git://github.com/aws/aws-sdk-java-v2.git","ssh_url":"git@github.com:aws/aws-sdk-java-v2.git","clone_url":"https://github.com/aws/aws-sdk-java-v2.git","svn_url":"https://github.com/aws/aws-sdk-java-v2","homepage":"","size":5429,"stargazers_count":41,"watchers_count":41,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":47,"forks":5,"open_issues":47,"watchers":41,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/9"},"html":{"href":"https://github.com/aws/aws-sdk-java-v2/pull/9"},"issue":{"href":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/9"},"comments":{"href":"https://api.github.com/repos/aws/aws-sdk-java-v2/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aws/aws-sdk-java-v2/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/aws/aws-sdk-java-v2/statuses/5dc57aeb9b9f110d26fa57e9de5e9bde2bc2f1c6"}}}}
{"actor":{"display_login":"kiiadi"}}