|
16 | 16 | import com.google.api.gax.core.PageAccessor; |
17 | 17 | import com.google.api.gax.grpc.ApiCallable; |
18 | 18 | import com.google.api.gax.protobuf.PathTemplate; |
| 19 | +import com.google.iam.v1.GetIamPolicyRequest; |
| 20 | +import com.google.iam.v1.Policy; |
| 21 | +import com.google.iam.v1.SetIamPolicyRequest; |
| 22 | +import com.google.iam.v1.TestIamPermissionsRequest; |
| 23 | +import com.google.iam.v1.TestIamPermissionsResponse; |
19 | 24 | import com.google.protobuf.ByteString; |
20 | 25 | import com.google.protobuf.Empty; |
21 | 26 | import com.google.pubsub.v1.DeleteTopicRequest; |
@@ -105,6 +110,10 @@ public class PublisherApi implements AutoCloseable { |
105 | 110 | private final ApiCallable<ListTopicSubscriptionsRequest, PageAccessor<String>> |
106 | 111 | listTopicSubscriptionsPagedCallable; |
107 | 112 | private final ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable; |
| 113 | + private final ApiCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable; |
| 114 | + private final ApiCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable; |
| 115 | + private final ApiCallable<TestIamPermissionsRequest, TestIamPermissionsResponse> |
| 116 | + testIamPermissionsCallable; |
108 | 117 |
|
109 | 118 | public final PublisherSettings getSettings() { |
110 | 119 | return settings; |
@@ -204,6 +213,12 @@ protected PublisherApi(PublisherSettings settings) throws IOException { |
204 | 213 | settings.listTopicSubscriptionsSettings(), this.channel, this.executor); |
205 | 214 | this.deleteTopicCallable = |
206 | 215 | ApiCallable.create(settings.deleteTopicSettings(), this.channel, this.executor); |
| 216 | + this.setIamPolicyCallable = |
| 217 | + ApiCallable.create(settings.setIamPolicySettings(), this.channel, this.executor); |
| 218 | + this.getIamPolicyCallable = |
| 219 | + ApiCallable.create(settings.getIamPolicySettings(), this.channel, this.executor); |
| 220 | + this.testIamPermissionsCallable = |
| 221 | + ApiCallable.create(settings.testIamPermissionsSettings(), this.channel, this.executor); |
207 | 222 |
|
208 | 223 | if (settings.getChannelProvider().shouldAutoClose()) { |
209 | 224 | closeables.add( |
@@ -726,6 +741,230 @@ public final ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() { |
726 | 741 | return deleteTopicCallable; |
727 | 742 | } |
728 | 743 |
|
| 744 | + // AUTO-GENERATED DOCUMENTATION AND METHOD |
| 745 | + /** |
| 746 | + * Sets the access control policy on the specified resource. Replaces any |
| 747 | + * existing policy. |
| 748 | + * |
| 749 | + * Sample code: |
| 750 | + * <pre><code> |
| 751 | + * try (PublisherApi publisherApi = PublisherApi.create()) { |
| 752 | + * String formattedResource = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); |
| 753 | + * Policy policy = Policy.newBuilder().build(); |
| 754 | + * Policy response = publisherApi.setIamPolicy(formattedResource, policy); |
| 755 | + * } |
| 756 | + * </code></pre> |
| 757 | + * |
| 758 | + * @param resource REQUIRED: The resource for which policy is being specified. |
| 759 | + * Resource is usually specified as a path, such as, |
| 760 | + * projects/{project}/zones/{zone}/disks/{disk}. |
| 761 | + * @param policy REQUIRED: The complete policy to be applied to the 'resource'. The size of |
| 762 | + * the policy is limited to a few 10s of KB. An empty policy is in general a |
| 763 | + * valid policy but certain services (like Projects) might reject them. |
| 764 | + * @throws com.google.api.gax.grpc.ApiException if the remote call fails |
| 765 | + */ |
| 766 | + public final Policy setIamPolicy(String resource, Policy policy) { |
| 767 | + TOPIC_PATH_TEMPLATE.validate(resource, "setIamPolicy"); |
| 768 | + SetIamPolicyRequest request = |
| 769 | + SetIamPolicyRequest.newBuilder().setResource(resource).setPolicy(policy).build(); |
| 770 | + return setIamPolicy(request); |
| 771 | + } |
| 772 | + |
| 773 | + // AUTO-GENERATED DOCUMENTATION AND METHOD |
| 774 | + /** |
| 775 | + * Sets the access control policy on the specified resource. Replaces any |
| 776 | + * existing policy. |
| 777 | + * |
| 778 | + * Sample code: |
| 779 | + * <pre><code> |
| 780 | + * try (PublisherApi publisherApi = PublisherApi.create()) { |
| 781 | + * String formattedResource = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); |
| 782 | + * Policy policy = Policy.newBuilder().build(); |
| 783 | + * SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() |
| 784 | + * .setResource(formattedResource) |
| 785 | + * .setPolicy(policy) |
| 786 | + * .build(); |
| 787 | + * Policy response = publisherApi.setIamPolicy(request); |
| 788 | + * } |
| 789 | + * </code></pre> |
| 790 | + * |
| 791 | + * @param request The request object containing all of the parameters for the API call. |
| 792 | + * @throws com.google.api.gax.grpc.ApiException if the remote call fails |
| 793 | + */ |
| 794 | + public final Policy setIamPolicy(SetIamPolicyRequest request) { |
| 795 | + return setIamPolicyCallable().call(request); |
| 796 | + } |
| 797 | + |
| 798 | + // AUTO-GENERATED DOCUMENTATION AND METHOD |
| 799 | + /** |
| 800 | + * Sets the access control policy on the specified resource. Replaces any |
| 801 | + * existing policy. |
| 802 | + * |
| 803 | + * Sample code: |
| 804 | + * <pre><code> |
| 805 | + * try (PublisherApi publisherApi = PublisherApi.create()) { |
| 806 | + * String formattedResource = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); |
| 807 | + * Policy policy = Policy.newBuilder().build(); |
| 808 | + * SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() |
| 809 | + * .setResource(formattedResource) |
| 810 | + * .setPolicy(policy) |
| 811 | + * .build(); |
| 812 | + * ListenableFuture<Policy> future = publisherApi.setIamPolicyCallable().futureCall(request); |
| 813 | + * // Do something |
| 814 | + * Policy response = future.get(); |
| 815 | + * } |
| 816 | + * </code></pre> |
| 817 | + */ |
| 818 | + public final ApiCallable<SetIamPolicyRequest, Policy> setIamPolicyCallable() { |
| 819 | + return setIamPolicyCallable; |
| 820 | + } |
| 821 | + |
| 822 | + // AUTO-GENERATED DOCUMENTATION AND METHOD |
| 823 | + /** |
| 824 | + * Gets the access control policy for a resource. Is empty if the |
| 825 | + * policy or the resource does not exist. |
| 826 | + * |
| 827 | + * Sample code: |
| 828 | + * <pre><code> |
| 829 | + * try (PublisherApi publisherApi = PublisherApi.create()) { |
| 830 | + * String formattedResource = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); |
| 831 | + * Policy response = publisherApi.getIamPolicy(formattedResource); |
| 832 | + * } |
| 833 | + * </code></pre> |
| 834 | + * |
| 835 | + * @param resource REQUIRED: The resource for which policy is being requested. Resource |
| 836 | + * is usually specified as a path, such as, projects/{project}. |
| 837 | + * @throws com.google.api.gax.grpc.ApiException if the remote call fails |
| 838 | + */ |
| 839 | + public final Policy getIamPolicy(String resource) { |
| 840 | + TOPIC_PATH_TEMPLATE.validate(resource, "getIamPolicy"); |
| 841 | + GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder().setResource(resource).build(); |
| 842 | + return getIamPolicy(request); |
| 843 | + } |
| 844 | + |
| 845 | + // AUTO-GENERATED DOCUMENTATION AND METHOD |
| 846 | + /** |
| 847 | + * Gets the access control policy for a resource. Is empty if the |
| 848 | + * policy or the resource does not exist. |
| 849 | + * |
| 850 | + * Sample code: |
| 851 | + * <pre><code> |
| 852 | + * try (PublisherApi publisherApi = PublisherApi.create()) { |
| 853 | + * String formattedResource = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); |
| 854 | + * GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() |
| 855 | + * .setResource(formattedResource) |
| 856 | + * .build(); |
| 857 | + * Policy response = publisherApi.getIamPolicy(request); |
| 858 | + * } |
| 859 | + * </code></pre> |
| 860 | + * |
| 861 | + * @param request The request object containing all of the parameters for the API call. |
| 862 | + * @throws com.google.api.gax.grpc.ApiException if the remote call fails |
| 863 | + */ |
| 864 | + private final Policy getIamPolicy(GetIamPolicyRequest request) { |
| 865 | + return getIamPolicyCallable().call(request); |
| 866 | + } |
| 867 | + |
| 868 | + // AUTO-GENERATED DOCUMENTATION AND METHOD |
| 869 | + /** |
| 870 | + * Gets the access control policy for a resource. Is empty if the |
| 871 | + * policy or the resource does not exist. |
| 872 | + * |
| 873 | + * Sample code: |
| 874 | + * <pre><code> |
| 875 | + * try (PublisherApi publisherApi = PublisherApi.create()) { |
| 876 | + * String formattedResource = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); |
| 877 | + * GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() |
| 878 | + * .setResource(formattedResource) |
| 879 | + * .build(); |
| 880 | + * ListenableFuture<Policy> future = publisherApi.getIamPolicyCallable().futureCall(request); |
| 881 | + * // Do something |
| 882 | + * Policy response = future.get(); |
| 883 | + * } |
| 884 | + * </code></pre> |
| 885 | + */ |
| 886 | + public final ApiCallable<GetIamPolicyRequest, Policy> getIamPolicyCallable() { |
| 887 | + return getIamPolicyCallable; |
| 888 | + } |
| 889 | + |
| 890 | + // AUTO-GENERATED DOCUMENTATION AND METHOD |
| 891 | + /** |
| 892 | + * Returns permissions that a caller has on the specified resource. |
| 893 | + * |
| 894 | + * Sample code: |
| 895 | + * <pre><code> |
| 896 | + * try (PublisherApi publisherApi = PublisherApi.create()) { |
| 897 | + * String formattedResource = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); |
| 898 | + * List<String> permissions = new ArrayList<>(); |
| 899 | + * TestIamPermissionsResponse response = publisherApi.testIamPermissions(formattedResource, permissions); |
| 900 | + * } |
| 901 | + * </code></pre> |
| 902 | + * |
| 903 | + * @param resource REQUIRED: The resource for which policy detail is being requested. |
| 904 | + * Resource is usually specified as a path, such as, projects/{project}. |
| 905 | + * @param permissions The set of permissions to check for the 'resource'. Permissions with |
| 906 | + * wildcards (such as '*' or 'storage.*') are not allowed. |
| 907 | + * @throws com.google.api.gax.grpc.ApiException if the remote call fails |
| 908 | + */ |
| 909 | + public final TestIamPermissionsResponse testIamPermissions( |
| 910 | + String resource, List<String> permissions) { |
| 911 | + TOPIC_PATH_TEMPLATE.validate(resource, "testIamPermissions"); |
| 912 | + TestIamPermissionsRequest request = |
| 913 | + TestIamPermissionsRequest.newBuilder() |
| 914 | + .setResource(resource) |
| 915 | + .addAllPermissions(permissions) |
| 916 | + .build(); |
| 917 | + return testIamPermissions(request); |
| 918 | + } |
| 919 | + |
| 920 | + // AUTO-GENERATED DOCUMENTATION AND METHOD |
| 921 | + /** |
| 922 | + * Returns permissions that a caller has on the specified resource. |
| 923 | + * |
| 924 | + * Sample code: |
| 925 | + * <pre><code> |
| 926 | + * try (PublisherApi publisherApi = PublisherApi.create()) { |
| 927 | + * String formattedResource = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); |
| 928 | + * List<String> permissions = new ArrayList<>(); |
| 929 | + * TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() |
| 930 | + * .setResource(formattedResource) |
| 931 | + * .addAllPermissions(permissions) |
| 932 | + * .build(); |
| 933 | + * TestIamPermissionsResponse response = publisherApi.testIamPermissions(request); |
| 934 | + * } |
| 935 | + * </code></pre> |
| 936 | + * |
| 937 | + * @param request The request object containing all of the parameters for the API call. |
| 938 | + * @throws com.google.api.gax.grpc.ApiException if the remote call fails |
| 939 | + */ |
| 940 | + public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request) { |
| 941 | + return testIamPermissionsCallable().call(request); |
| 942 | + } |
| 943 | + |
| 944 | + // AUTO-GENERATED DOCUMENTATION AND METHOD |
| 945 | + /** |
| 946 | + * Returns permissions that a caller has on the specified resource. |
| 947 | + * |
| 948 | + * Sample code: |
| 949 | + * <pre><code> |
| 950 | + * try (PublisherApi publisherApi = PublisherApi.create()) { |
| 951 | + * String formattedResource = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]"); |
| 952 | + * List<String> permissions = new ArrayList<>(); |
| 953 | + * TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() |
| 954 | + * .setResource(formattedResource) |
| 955 | + * .addAllPermissions(permissions) |
| 956 | + * .build(); |
| 957 | + * ListenableFuture<TestIamPermissionsResponse> future = publisherApi.testIamPermissionsCallable().futureCall(request); |
| 958 | + * // Do something |
| 959 | + * TestIamPermissionsResponse response = future.get(); |
| 960 | + * } |
| 961 | + * </code></pre> |
| 962 | + */ |
| 963 | + public final ApiCallable<TestIamPermissionsRequest, TestIamPermissionsResponse> |
| 964 | + testIamPermissionsCallable() { |
| 965 | + return testIamPermissionsCallable; |
| 966 | + } |
| 967 | + |
729 | 968 | /** |
730 | 969 | * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately |
731 | 970 | * cancelled. |
|
0 commit comments