Skip to content

Commit

Permalink
feat: [advisorynotifications] adding project level methods to advisor…
Browse files Browse the repository at this point in the history
…ynotifications.googleapis.com (#10123)

* feat: adding project level methods to advisorynotifications.googleapis.com

docs: adding docs for new project level methods

adding GetNotification and ListNotifications methods for notifications parented at the project level

PiperOrigin-RevId: 588795150

Source-Link: googleapis/googleapis@967b05b

Source-Link: googleapis/googleapis-gen@bdd6f86
Copy-Tag: eyJwIjoiamF2YS1hZHZpc29yeW5vdGlmaWNhdGlvbnMvLk93bEJvdC55YW1sIiwiaCI6ImJkZDZmODZiODcxYjE3ZGZkNDEwZWMzYTIxNzYxZjNmNjRkODIyNzcifQ==

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Tomo Suzuki <suztomo@google.com>
  • Loading branch information
3 people committed Jan 2, 2024
1 parent 5ea5bee commit 1b5a49d
Show file tree
Hide file tree
Showing 25 changed files with 509 additions and 179 deletions.
2 changes: 1 addition & 1 deletion java-advisorynotifications/README.md
Expand Up @@ -201,7 +201,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-advisorynotifications/java11.html
[stability-image]: https://img.shields.io/badge/stability-preview-yellow
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-advisorynotifications.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-advisorynotifications/0.19.0
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-advisorynotifications/0.20.0
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Expand Up @@ -47,7 +47,9 @@
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
* AdvisoryNotificationsServiceClient.create()) {
* NotificationName name = NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
* NotificationName name =
* NotificationName.ofOrganizationLocationNotificationName(
* "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
* Notification response = advisoryNotificationsServiceClient.getNotification(name);
* }
* }</pre>
Expand Down Expand Up @@ -194,7 +196,7 @@ public AdvisoryNotificationsServiceStub getStub() {
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
* AdvisoryNotificationsServiceClient.create()) {
* LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
* LocationName parent = LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]");
* for (Notification element :
* advisoryNotificationsServiceClient.listNotifications(parent).iterateAll()) {
* // doThingsWith(element);
Expand All @@ -203,7 +205,8 @@ public AdvisoryNotificationsServiceStub getStub() {
* }</pre>
*
* @param parent Required. The parent, which owns this collection of notifications. Must be of the
* form "organizations/{organization}/locations/{location}".
* form "organizations/{organization}/locations/{location}" or
* "projects/{project}/locations/{location}"
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListNotificationsPagedResponse listNotifications(LocationName parent) {
Expand All @@ -228,7 +231,8 @@ public final ListNotificationsPagedResponse listNotifications(LocationName paren
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
* AdvisoryNotificationsServiceClient.create()) {
* String parent = LocationName.of("[ORGANIZATION]", "[LOCATION]").toString();
* String parent =
* LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]").toString();
* for (Notification element :
* advisoryNotificationsServiceClient.listNotifications(parent).iterateAll()) {
* // doThingsWith(element);
Expand All @@ -237,7 +241,8 @@ public final ListNotificationsPagedResponse listNotifications(LocationName paren
* }</pre>
*
* @param parent Required. The parent, which owns this collection of notifications. Must be of the
* form "organizations/{organization}/locations/{location}".
* form "organizations/{organization}/locations/{location}" or
* "projects/{project}/locations/{location}"
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final ListNotificationsPagedResponse listNotifications(String parent) {
Expand All @@ -262,7 +267,9 @@ public final ListNotificationsPagedResponse listNotifications(String parent) {
* AdvisoryNotificationsServiceClient.create()) {
* ListNotificationsRequest request =
* ListNotificationsRequest.newBuilder()
* .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
* .setParent(
* LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]")
* .toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setView(NotificationView.forNumber(0))
Expand Down Expand Up @@ -298,7 +305,9 @@ public final ListNotificationsPagedResponse listNotifications(ListNotificationsR
* AdvisoryNotificationsServiceClient.create()) {
* ListNotificationsRequest request =
* ListNotificationsRequest.newBuilder()
* .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
* .setParent(
* LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]")
* .toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setView(NotificationView.forNumber(0))
Expand Down Expand Up @@ -334,7 +343,9 @@ public final ListNotificationsPagedResponse listNotifications(ListNotificationsR
* AdvisoryNotificationsServiceClient.create()) {
* ListNotificationsRequest request =
* ListNotificationsRequest.newBuilder()
* .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
* .setParent(
* LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]")
* .toString())
* .setPageSize(883849137)
* .setPageToken("pageToken873572522")
* .setView(NotificationView.forNumber(0))
Expand Down Expand Up @@ -375,13 +386,16 @@ public final ListNotificationsPagedResponse listNotifications(ListNotificationsR
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
* AdvisoryNotificationsServiceClient.create()) {
* NotificationName name = NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
* NotificationName name =
* NotificationName.ofOrganizationLocationNotificationName(
* "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
* Notification response = advisoryNotificationsServiceClient.getNotification(name);
* }
* }</pre>
*
* @param name Required. A name of the notification to retrieve. Format:
* organizations/{organization}/locations/{location}/notifications/{notification}.
* organizations/{organization}/locations/{location}/notifications/{notification} or
* projects/{projects}/locations/{location}/notifications/{notification}.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Notification getNotification(NotificationName name) {
Expand All @@ -405,13 +419,16 @@ public final Notification getNotification(NotificationName name) {
* try (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
* AdvisoryNotificationsServiceClient.create()) {
* String name =
* NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]").toString();
* NotificationName.ofOrganizationLocationNotificationName(
* "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]")
* .toString();
* Notification response = advisoryNotificationsServiceClient.getNotification(name);
* }
* }</pre>
*
* @param name Required. A name of the notification to retrieve. Format:
* organizations/{organization}/locations/{location}/notifications/{notification}.
* organizations/{organization}/locations/{location}/notifications/{notification} or
* projects/{projects}/locations/{location}/notifications/{notification}.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final Notification getNotification(String name) {
Expand All @@ -436,7 +453,9 @@ public final Notification getNotification(String name) {
* GetNotificationRequest request =
* GetNotificationRequest.newBuilder()
* .setName(
* NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]").toString())
* NotificationName.ofOrganizationLocationNotificationName(
* "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]")
* .toString())
* .setLanguageCode("languageCode-2092349083")
* .build();
* Notification response = advisoryNotificationsServiceClient.getNotification(request);
Expand Down Expand Up @@ -467,7 +486,9 @@ public final Notification getNotification(GetNotificationRequest request) {
* GetNotificationRequest request =
* GetNotificationRequest.newBuilder()
* .setName(
* NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]").toString())
* NotificationName.ofOrganizationLocationNotificationName(
* "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]")
* .toString())
* .setLanguageCode("languageCode-2092349083")
* .build();
* ApiFuture<Notification> future =
Expand Down
Expand Up @@ -33,7 +33,9 @@
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* try (AdvisoryNotificationsServiceClient advisoryNotificationsServiceClient =
* AdvisoryNotificationsServiceClient.create()) {
* NotificationName name = NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
* NotificationName name =
* NotificationName.ofOrganizationLocationNotificationName(
* "[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
* Notification response = advisoryNotificationsServiceClient.getNotification(name);
* }
* }</pre>
Expand Down
Expand Up @@ -76,6 +76,7 @@ public class HttpJsonAdvisoryNotificationsServiceStub extends AdvisoryNotificati
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setAdditionalPaths("/v1/{parent=projects/*/locations/*}/notifications")
.setQueryParamsExtractor(
request -> {
Map<String, List<String>> fields = new HashMap<>();
Expand Down Expand Up @@ -116,6 +117,7 @@ public class HttpJsonAdvisoryNotificationsServiceStub extends AdvisoryNotificati
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setAdditionalPaths("/v1/{name=projects/*/locations/*/notifications/*}")
.setQueryParamsExtractor(
request -> {
Map<String, List<String>> fields = new HashMap<>();
Expand Down
Expand Up @@ -88,7 +88,7 @@ public void listNotificationsTest() throws Exception {
.build();
mockService.addResponse(expectedResponse);

LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
LocationName parent = LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]");

ListNotificationsPagedResponse pagedListResponse = client.listNotifications(parent);

Expand Down Expand Up @@ -120,7 +120,7 @@ public void listNotificationsExceptionTest() throws Exception {
mockService.addException(exception);

try {
LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
LocationName parent = LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]");
client.listNotifications(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
Expand Down Expand Up @@ -183,15 +183,19 @@ public void getNotificationTest() throws Exception {
Notification expectedResponse =
Notification.newBuilder()
.setName(
NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]").toString())
NotificationName.ofOrganizationLocationNotificationName(
"[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]")
.toString())
.setSubject(Subject.newBuilder().build())
.addAllMessages(new ArrayList<Message>())
.setCreateTime(Timestamp.newBuilder().build())
.setNotificationType(NotificationType.forNumber(0))
.build();
mockService.addResponse(expectedResponse);

NotificationName name = NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
NotificationName name =
NotificationName.ofOrganizationLocationNotificationName(
"[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");

Notification actualResponse = client.getNotification(name);
Assert.assertEquals(expectedResponse, actualResponse);
Expand Down Expand Up @@ -219,7 +223,9 @@ public void getNotificationExceptionTest() throws Exception {
mockService.addException(exception);

try {
NotificationName name = NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
NotificationName name =
NotificationName.ofOrganizationLocationNotificationName(
"[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
client.getNotification(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
Expand All @@ -232,7 +238,9 @@ public void getNotificationTest2() throws Exception {
Notification expectedResponse =
Notification.newBuilder()
.setName(
NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]").toString())
NotificationName.ofOrganizationLocationNotificationName(
"[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]")
.toString())
.setSubject(Subject.newBuilder().build())
.addAllMessages(new ArrayList<Message>())
.setCreateTime(Timestamp.newBuilder().build())
Expand Down
Expand Up @@ -92,7 +92,7 @@ public void listNotificationsTest() throws Exception {
.build();
mockAdvisoryNotificationsService.addResponse(expectedResponse);

LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
LocationName parent = LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]");

ListNotificationsPagedResponse pagedListResponse = client.listNotifications(parent);

Expand All @@ -118,7 +118,7 @@ public void listNotificationsExceptionTest() throws Exception {
mockAdvisoryNotificationsService.addException(exception);

try {
LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
LocationName parent = LocationName.ofOrganizationLocationName("[ORGANIZATION]", "[LOCATION]");
client.listNotifications(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
Expand Down Expand Up @@ -175,15 +175,19 @@ public void getNotificationTest() throws Exception {
Notification expectedResponse =
Notification.newBuilder()
.setName(
NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]").toString())
NotificationName.ofOrganizationLocationNotificationName(
"[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]")
.toString())
.setSubject(Subject.newBuilder().build())
.addAllMessages(new ArrayList<Message>())
.setCreateTime(Timestamp.newBuilder().build())
.setNotificationType(NotificationType.forNumber(0))
.build();
mockAdvisoryNotificationsService.addResponse(expectedResponse);

NotificationName name = NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
NotificationName name =
NotificationName.ofOrganizationLocationNotificationName(
"[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");

Notification actualResponse = client.getNotification(name);
Assert.assertEquals(expectedResponse, actualResponse);
Expand All @@ -205,7 +209,9 @@ public void getNotificationExceptionTest() throws Exception {
mockAdvisoryNotificationsService.addException(exception);

try {
NotificationName name = NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
NotificationName name =
NotificationName.ofOrganizationLocationNotificationName(
"[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]");
client.getNotification(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
Expand All @@ -218,7 +224,9 @@ public void getNotificationTest2() throws Exception {
Notification expectedResponse =
Notification.newBuilder()
.setName(
NotificationName.of("[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]").toString())
NotificationName.ofOrganizationLocationNotificationName(
"[ORGANIZATION]", "[LOCATION]", "[NOTIFICATION]")
.toString())
.setSubject(Subject.newBuilder().build())
.addAllMessages(new ArrayList<Message>())
.setCreateTime(Timestamp.newBuilder().build())
Expand Down

0 comments on commit 1b5a49d

Please sign in to comment.