Skip to content

PR: Feature Request - New Resource Notification Policy and Label selector endpoint #308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Nov 3, 2020

Conversation

samarsinghal
Copy link
Contributor

This PR include the below changes:-

  1. Message policy to send an email notification to org owners. The org owners are configured as "PrimaryOwner" and "SecondaryOwner" labels on each organization.

Copy link
Collaborator

@pacphi pacphi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work here. I think this is the realization of a long-standing feature request, as documented here: #10. But it's not an action-based policy rather only to be used for reporting and notification.

README.md Outdated
{
"message-policies": [
{
"id": "b56fdcce40fd0dbe1c74791343850f6881595b26",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this attribute id truly needed? Probably ok to remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

README.md Outdated
@@ -236,6 +236,17 @@ As mentioned previously the policy file must adhere to a naming convention
See additional property requirements in Query policies and the aforementioned sample Github repository.


#### Message Policies
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Message Policy really the right name for this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What content are we attaching to send to the org owners?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see what you're trying to do. You're trying to add a label filter, right? As in you're trying to implement this feature: #10? Maybe this should be renamed to Label Policy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the name to ResourceNotificationPolicy

@@ -43,6 +43,12 @@ public DbmsOnlyPoliciesController(
.map(ResponseEntity::ok);
}

@DeleteMapping("/policies/message/{id}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not convinced on the policy type = message for this policy. We need to find a better type name.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely message should be renamed to label.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the name to ResourceNotificationPolicy

.scheme("https")
.host(settings.getApiHost())
.path("/v3/{type}")
.queryParam("label_selector", labelSelector)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the crux of what you're wanting to return to the interested party (org owner)? It's the resource(s) that match(es) the label selector?

@@ -153,6 +153,22 @@ public boolean validate(HygienePolicy policy) {
return valid;
}

public boolean validate(MessagePolicy policy) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -74,6 +76,15 @@ public R2dbcPoliciesRepository(
.then();
}

public Mono<Void> deleteMessagePolicyById(String id) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we don't yet have unit tests for each policy type, but we really should add one. Happy to collaborate on authoring one with you. It would go in here: https://github.com/pacphi/cf-butler/tree/master/src/test/java/io/pivotal/cfapp/repository.

Copy link
Collaborator

@pacphi pacphi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions and some wording updates in documentation. We're almost there!

README.md Outdated
@@ -236,6 +236,17 @@ As mentioned previously the policy file must adhere to a naming convention
See additional property requirements in Query policies and the aforementioned sample Github repository.


#### Resource Notification Policies

Resource Notification policies are useful when you wants to send notification for a resource(Org, Apps, Services) to the emailid's configured on the resources as labels.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when you want to generate a report containing resources of a particular type and send that report to email recipients identified by one or more label values ascribed to the those resources.

For example, you might notify primary and/or secondary owners of a collection of a resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

README.md Outdated
"PrimaryOwner",
"SecondaryOwner"
],
"domain": "pivotal.io"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let's be explicit... update domain be email_domain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done changed domain attribute to email-domain

"body": "Please take a moment to review the platform updates and share it with your Org users"
},
"resource-email-metadata": {
"resource": "organizations",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you limited metadata definition to one resource type.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that the resource type is plural form? Or is it really singular form? E.g., instead of organizations would it be organization?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it's actually what's allowed in ResourceType enum. You're good in this example.

@pacphi pacphi changed the title Pull request for message policy and label selector endpoint PR: Feature Request - New Resource Notification Policy and Label selector endpoint Nov 3, 2020
@pacphi pacphi merged commit 845dded into cf-toolsuite:master Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants