|
19 | 19 | import com.google.cloud.AsyncPage; |
20 | 20 | import com.google.cloud.GrpcServiceOptions.ExecutorFactory; |
21 | 21 | import com.google.cloud.Page; |
| 22 | +import com.google.cloud.Policy; |
22 | 23 | import com.google.cloud.Service; |
23 | 24 |
|
24 | 25 | import java.util.Iterator; |
@@ -655,7 +656,179 @@ Future<Void> modifyAckDeadlineAsync(String subscription, int deadline, TimeUnit |
655 | 656 | Future<Void> modifyAckDeadlineAsync(String subscription, int deadline, TimeUnit unit, |
656 | 657 | Iterable<String> ackIds); |
657 | 658 |
|
658 | | - // IAM Policy operations: getPolicy, replacePolicy, testPermissions |
659 | | - // Not sure if ready (docs is not up-to-date) |
660 | | - // Looks like policy is per resource (topic or subscription) but not per service? |
| 659 | + /** |
| 660 | + * Returns the IAM access control policy for the specified topic. Returns {@code null} if the |
| 661 | + * topic was not found. |
| 662 | + * |
| 663 | + * @throws PubSubException upon failure |
| 664 | + */ |
| 665 | + Policy getTopicPolicy(String topic); |
| 666 | + |
| 667 | + /** |
| 668 | + * Sends a request for getting the IAM access control policy for the specified topic. This method |
| 669 | + * returns a {@code Future} object to consume the result. {@link Future#get()} returns the |
| 670 | + * requested policy or {@code null} if the topic was not found. |
| 671 | + * |
| 672 | + * @throws PubSubException upon failure |
| 673 | + */ |
| 674 | + Future<Policy> getTopicPolicyAsync(String topic); |
| 675 | + |
| 676 | + /** |
| 677 | + * Sets the IAM access control policy for the specified topic. Replaces any existing policy. This |
| 678 | + * method returns the new policy. |
| 679 | + * |
| 680 | + * <p>It is recommended that you use the read-modify-write pattern. This pattern entails reading |
| 681 | + * the project's current policy, updating it locally, and then sending the modified policy for |
| 682 | + * writing. Cloud IAM solves the problem of conflicting processes simultaneously attempting to |
| 683 | + * modify a policy by using the {@link Policy#etag etag} property. This property is used to |
| 684 | + * verify whether the policy has changed since the last request. When you make a request with an |
| 685 | + * etag value, the value in the request is compared with the existing etag value associated with |
| 686 | + * the policy. The policy is written only if the etag values match. If the etags don't match, a |
| 687 | + * {@code PubSubException} is thrown, denoting that the server aborted update. If an etag is not |
| 688 | + * provided, the policy is overwritten blindly. |
| 689 | + * |
| 690 | + * @throws PubSubException upon failure |
| 691 | + */ |
| 692 | + Policy replaceTopicPolicy(String topic, Policy newPolicy); |
| 693 | + |
| 694 | + /** |
| 695 | + * Sends a request to set the IAM access control policy for the specified topic. Replaces any |
| 696 | + * existing policy. This method returns a {@code Future} object to consume the result. |
| 697 | + * {@link Future#get()} returns the new policy. |
| 698 | + * |
| 699 | + * <p>It is recommended that you use the read-modify-write pattern. This pattern entails reading |
| 700 | + * the project's current policy, updating it locally, and then sending the modified policy for |
| 701 | + * writing. Cloud IAM solves the problem of conflicting processes simultaneously attempting to |
| 702 | + * modify a policy by using the {@link Policy#etag etag} property. This property is used to |
| 703 | + * verify whether the policy has changed since the last request. When you make a request with an |
| 704 | + * etag value, the value in the request is compared with the existing etag value associated with |
| 705 | + * the policy. The policy is written only if the etag values match. If the etags don't match, |
| 706 | + * {@link Future#get()} will throw a {@link java.util.concurrent.ExecutionException} caused by a |
| 707 | + * {@code PubSubException}, denoting that the server aborted update. If an etag is not provided, |
| 708 | + * the policy is overwritten blindly. |
| 709 | + * |
| 710 | + * @throws PubSubException upon failure |
| 711 | + */ |
| 712 | + Future<Policy> replaceTopicPolicyAsync(String topic, Policy newPolicy); |
| 713 | + |
| 714 | + /** |
| 715 | + * Returns the permissions that a caller has on the specified topic. |
| 716 | + * |
| 717 | + * <p>You typically don't call this method if you're using Google Cloud Platform directly to |
| 718 | + * manage permissions. This method is intended for integration with your proprietary software, |
| 719 | + * such as a customized graphical user interface. For example, the Cloud Platform Console tests |
| 720 | + * IAM permissions internally to determine which UI should be available to the logged-in user. |
| 721 | + * |
| 722 | + * @return A list of booleans representing whether the caller has the permissions specified (in |
| 723 | + * the order of the given permissions) |
| 724 | + * @throws PubSubException upon failure |
| 725 | + * @see <a href="https://cloud.google.com/pubsub/docs/access_control#permissions"> |
| 726 | + * Permissions and Roles</a> |
| 727 | + */ |
| 728 | + List<Boolean> testTopicPermissions(String topic, List<String> permissions); |
| 729 | + |
| 730 | + /** |
| 731 | + * Sends a request to get the permissions that a caller has on the specified topic. |
| 732 | + * |
| 733 | + * <p>You typically don't call this method if you're using Google Cloud Platform directly to |
| 734 | + * manage permissions. This method is intended for integration with your proprietary software, |
| 735 | + * such as a customized graphical user interface. For example, the Cloud Platform Console tests |
| 736 | + * IAM permissions internally to determine which UI should be available to the logged-in user. |
| 737 | + * |
| 738 | + * @return A {@code Future} object to consume the result. {@link Future#get()} returns a list of |
| 739 | + * booleans representing whether the caller has the permissions specified (in the order of the |
| 740 | + * given permissions) |
| 741 | + * @throws PubSubException upon failure |
| 742 | + * @see <a href="https://cloud.google.com/pubsub/docs/access_control#permissions"> |
| 743 | + * Permissions and Roles</a> |
| 744 | + */ |
| 745 | + Future<List<Boolean>> testTopicPermissionsAsync(String topic, List<String> permissions); |
| 746 | + |
| 747 | + /** |
| 748 | + * Returns the IAM access control policy for the specified subscription. Returns {@code null} if |
| 749 | + * the subscription was not found. |
| 750 | + * |
| 751 | + * @throws PubSubException upon failure |
| 752 | + */ |
| 753 | + Policy getSubscriptionPolicy(String subscription); |
| 754 | + |
| 755 | + /** |
| 756 | + * Sends a request for getting the IAM access control policy for the specified subscription. This |
| 757 | + * method returns a {@code Future} object to consume the result. {@link Future#get()} returns the |
| 758 | + * requested policy or {@code null} if the subscription was not found. |
| 759 | + * |
| 760 | + * @throws PubSubException upon failure |
| 761 | + */ |
| 762 | + Future<Policy> getSubscriptionPolicyAsync(String subscription); |
| 763 | + |
| 764 | + /** |
| 765 | + * Sets the IAM access control policy for the specified subscription. Replaces any existing |
| 766 | + * policy. This method returns the new policy. |
| 767 | + * |
| 768 | + * <p>It is recommended that you use the read-modify-write pattern. This pattern entails reading |
| 769 | + * the project's current policy, updating it locally, and then sending the modified policy for |
| 770 | + * writing. Cloud IAM solves the problem of conflicting processes simultaneously attempting to |
| 771 | + * modify a policy by using the {@link Policy#etag etag} property. This property is used to |
| 772 | + * verify whether the policy has changed since the last request. When you make a request with an |
| 773 | + * etag value, the value in the request is compared with the existing etag value associated with |
| 774 | + * the policy. The policy is written only if the etag values match. If the etags don't match, a |
| 775 | + * {@code PubSubException} is thrown, denoting that the server aborted update. If an etag is not |
| 776 | + * provided, the policy is overwritten blindly. |
| 777 | + * |
| 778 | + * @throws PubSubException upon failure |
| 779 | + */ |
| 780 | + Policy replaceSubscriptionPolicy(String subscription, Policy newPolicy); |
| 781 | + |
| 782 | + /** |
| 783 | + * Sends a request to set the IAM access control policy for the specified subscription. Replaces |
| 784 | + * any existing policy. This method returns a {@code Future} object to consume the result. |
| 785 | + * {@link Future#get()} returns the new policy. |
| 786 | + * |
| 787 | + * <p>It is recommended that you use the read-modify-write pattern. This pattern entails reading |
| 788 | + * the project's current policy, updating it locally, and then sending the modified policy for |
| 789 | + * writing. Cloud IAM solves the problem of conflicting processes simultaneously attempting to |
| 790 | + * modify a policy by using the {@link Policy#etag etag} property. This property is used to |
| 791 | + * verify whether the policy has changed since the last request. When you make a request with an |
| 792 | + * etag value, the value in the request is compared with the existing etag value associated with |
| 793 | + * the policy. The policy is written only if the etag values match. If the etags don't match, |
| 794 | + * {@link Future#get()} will throw a {@link java.util.concurrent.ExecutionException} caused by a |
| 795 | + * {@code PubSubException}, denoting that the server aborted update. If an etag is not provided, |
| 796 | + * the policy is overwritten blindly. |
| 797 | + * |
| 798 | + * @throws PubSubException upon failure |
| 799 | + */ |
| 800 | + Future<Policy> replaceSubscriptionPolicyAsync(String subscription, Policy newPolicy); |
| 801 | + |
| 802 | + /** |
| 803 | + * Returns the permissions that a caller has on the specified subscription. You typically don't |
| 804 | + * call this method if you're using Google Cloud Platform directly to manage permissions. This |
| 805 | + * method is intended for integration with your proprietary software, such as a customized |
| 806 | + * graphical user interface. For example, the Cloud Platform Console tests IAM permissions |
| 807 | + * internally to determine which UI should be available to the logged-in user. |
| 808 | + * |
| 809 | + * @return A list of booleans representing whether the caller has the permissions specified (in |
| 810 | + * the order of the given permissions) |
| 811 | + * @throws PubSubException upon failure |
| 812 | + * @see <a href="https://cloud.google.com/pubsub/docs/access_control#permissions"> |
| 813 | + * Permissions and Roles</a> |
| 814 | + */ |
| 815 | + List<Boolean> testSubscriptionPermissions(String subscription, List<String> permissions); |
| 816 | + |
| 817 | + /** |
| 818 | + * Sends a request to get the permissions that a caller has on the specified subscription. |
| 819 | + * |
| 820 | + * <p>You typically don't call this method if you're using Google Cloud Platform directly to |
| 821 | + * manage permissions. This method is intended for integration with your proprietary software, |
| 822 | + * such as a customized graphical user interface. For example, the Cloud Platform Console tests |
| 823 | + * IAM permissions internally to determine which UI should be available to the logged-in user. |
| 824 | + * |
| 825 | + * @return A {@code Future} object to consume the result. {@link Future#get()} returns a list of |
| 826 | + * booleans representing whether the caller has the permissions specified (in the order of the |
| 827 | + * given permissions) |
| 828 | + * @throws PubSubException upon failure |
| 829 | + * @see <a href="https://cloud.google.com/pubsub/docs/access_control#permissions"> |
| 830 | + * Permissions and Roles</a> |
| 831 | + */ |
| 832 | + Future<List<Boolean>> testSubscriptionPermissionsAsync(String subscription, |
| 833 | + List<String> permissions); |
661 | 834 | } |
0 commit comments