Skip to content

Commit

Permalink
Rename adminEmails to admins, viewerEmails to viewers & correcting li…
Browse files Browse the repository at this point in the history
…nks in README (#22758)

* Rename adminEmails to admins, viewerEmails to viewers & correcting links in README

* Remove duplicate logging ref in readme
  • Loading branch information
anuchandy authored Jul 2, 2021
1 parent a92e9fb commit 7919b85
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 69 deletions.
2 changes: 1 addition & 1 deletion sdk/metricsadvisor/azure-ai-metricsadvisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
[logging]: https://github.com/Azure/azure-sdk-for-java/wiki/Logging-with-Azure-SDK
[metrics_advisor_account]: https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesMetricsAdvisor
[metrics_advisor_doc]: https://docs.microsoft.com/azure/cognitive-services/Metrics-advisor/glossary
[mvn_package]: https://search.maven.org/artifact/com.azure/azure-ai-metricsadvisor/1.0.0-beta.1/jar
[mvn_package]: https://search.maven.org/search?q=a:azure-ai-metricsadvisor
[product_documentation]: https://docs.microsoft.com/azure/cognitive-services/metrics-advisor/overview
[register_AAD_application]: https://docs.microsoft.com/azure/cognitive-services/authentication#assign-a-role-to-a-service-principal
[source_code]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/metricsadvisor/azure-ai-metricsadvisor/src
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ Mono<Response<DataFeed>> createDataFeedWithResponse(DataFeed dataFeed, Context c
.setFillMissingPointValue(dataFeedMissingDataPointFillSettings.getCustomFillValue())
.setViewMode(ViewMode.fromString(finalDataFeedOptions.getAccessMode() == null
? null : finalDataFeedOptions.getAccessMode().toString()))
.setViewers(finalDataFeedOptions.getViewerEmails())
.setAdmins(finalDataFeedOptions.getAdminEmails())
.setViewers(finalDataFeedOptions.getViewers())
.setAdmins(finalDataFeedOptions.getAdmins())
.setActionLinkTemplate(finalDataFeedOptions.getActionLinkTemplate()), withTracing)
.flatMap(createDataFeedResponse -> {
final String dataFeedId =
Expand Down Expand Up @@ -353,8 +353,8 @@ Mono<Response<DataFeed>> updateDataFeedWithResponse(DataFeed dataFeed, Context c
dataFeedOptions.getAccessMode() != null
? ViewMode.fromString(dataFeedOptions.getAccessMode().toString())
: null)
.setViewers(dataFeedOptions.getViewerEmails())
.setAdmins(dataFeedOptions.getAdminEmails())
.setViewers(dataFeedOptions.getViewers())
.setAdmins(dataFeedOptions.getAdmins())
.setStatus(
dataFeed.getStatus() != null
? EntityStatus.fromString(dataFeed.getStatus().toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public final class DataFeedOptions {
private DataFeedRollupSettings dataFeedRollupSettings;
private DataFeedMissingDataPointFillSettings dataFeedMissingDataPointFillSettings;
private DataFeedAccessMode dataFeedAccessMode;
private List<String> adminEmails;
private List<String> viewerEmails;
private List<String> admins;
private List<String> viewers;
private String actionLinkTemplate;

/**
Expand Down Expand Up @@ -86,46 +86,46 @@ public DataFeedOptions setAccessMode(DataFeedAccessMode dataFeedAccessMode) {
}

/**
* Get the list of data feed administrator emails.
* Get the list of data feed administrator emails and clientIds.
*
* @return the adminEmails value.
* @return the admins value.
*/
public List<String> getAdminEmails() {
return this.adminEmails == null
? null : Collections.unmodifiableList(this.adminEmails);
public List<String> getAdmins() {
return this.admins == null
? null : Collections.unmodifiableList(this.admins);
}

/**
* Set the list of data feed administrator emails.
* Set the list of data feed administrator emails and clientIds.
*
* @param adminEmails the adminEmails value to set.
* @param admins the admins value to set.
*
* @return the DataFeedOptions object itself.
*/
public DataFeedOptions setAdminEmails(List<String> adminEmails) {
this.adminEmails = adminEmails;
public DataFeedOptions setAdmins(List<String> admins) {
this.admins = admins;
return this;
}

/**
* Get the list of data feed viewer emails.
* Get the list of data feed viewer emails and clientIds.
*
* @return the viewerEmails value.
* @return the viewers value.
*/
public List<String> getViewerEmails() {
return this.viewerEmails == null
? null : Collections.unmodifiableList(this.viewerEmails);
public List<String> getViewers() {
return this.viewers == null
? null : Collections.unmodifiableList(this.viewers);
}

/**
* Set the list of data feed viewer emails.
* Set the list of data feed viewer emails and clientIds.
*
* @param viewerEmails the viewerEmails value to set.
* @param viewers the viewers value to set.
*
* @return the DataFeedOptions object itself.
*/
public DataFeedOptions setViewerEmails(List<String> viewerEmails) {
this.viewerEmails = viewerEmails;
public DataFeedOptions setViewers(List<String> viewers) {
this.viewers = viewers;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ public EmailNotificationHook setExternalLink(String externalLink) {
}

/**
* Sets the user e-mails with administrative rights to manage the hook.
* Sets the user e-mails and clientIds with administrative rights to manage the hook.
*
* @param emails The emails.
* @param emails The emails and clientIds
* @return The EmailNotificationHook object itself.
*/
public EmailNotificationHook setAdminEmails(List<String> emails) {
super.setAdministratorEmails(emails);
public EmailNotificationHook setAdmins(List<String> emails) {
super.setAdministrators(emails);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public abstract class NotificationHook {
private String id;
private List<String> adminEmails;
private List<String> admins;

static {
HookHelper.setAccessor(new HookHelper.HookAccessor() {
Expand All @@ -26,8 +26,8 @@ public void setId(NotificationHook hook, String id) {
}

@Override
public List<String> getAdminEmailsRaw(NotificationHook hook) {
return hook.getAdminEmailsRaw();
public List<String> getAdminsRaw(NotificationHook hook) {
return hook.getAdminsRaw();
}

@Override
Expand Down Expand Up @@ -66,13 +66,13 @@ public String getId() {
public abstract String getDescription();

/**
* The list of user e-mails with administrative rights to manage the hook.
* Gets the list of user e-mails and clientIds with administrative rights to manage the hook.
*
* @return The emails of admins.
*/
public List<String> getAdminEmails() {
if (this.adminEmails != null) {
return Collections.unmodifiableList(this.adminEmails);
public List<String> getAdmins() {
if (this.admins != null) {
return Collections.unmodifiableList(this.admins);
} else {
return Collections.emptyList();
}
Expand All @@ -82,13 +82,13 @@ private void setId(String id) {
this.id = id;
}

private List<String> getAdminEmailsRaw() {
private List<String> getAdminsRaw() {
// Getter that won't translate null admin-emails to empty-list.
return this.adminEmails;
return this.admins;
}

void setAdministratorEmails(List<String> emails) {
this.adminEmails = emails != null ? dedupe(emails) : null;
void setAdministrators(List<String> emails) {
this.admins = emails != null ? dedupe(emails) : null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public String getEndpoint() {
}

/**
* Gets the external link.
* Gets the external link url, this will be included in the notification sent to the users,
* this is usually a reference to any troubleshooting guide.
*
* @return The external link.
*/
Expand Down Expand Up @@ -145,7 +146,8 @@ public WebNotificationHook setDescription(String description) {
}

/**
* Sets the customized external link.
* Sets the customized external link, it will be included in the notification sent to the users,
* this is usually a reference to any troubleshooting guide.
*
* @param externalLink The customized link.
* @return The WebNotificationHook object itself.
Expand Down Expand Up @@ -193,13 +195,13 @@ public WebNotificationHook setHttpHeaders(HttpHeaders httpHeaders) {
}

/**
* Sets the user e-mails with administrative rights to manage the hook.
* Sets the user e-mails and clientIds with administrative rights to manage the hook.
*
* @param emails The emails.
* @param emails The emails and clientIds
* @return The WebNotificationHook object itself.
*/
public WebNotificationHook setAdminEmails(List<String> emails) {
super.setAdministratorEmails(emails);
public WebNotificationHook setAdmins(List<String> emails) {
super.setAdministrators(emails);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ public static DataFeed fromInner(final DataFeedDetail dataFeedDetail) {
.setFillType(DataFeedMissingDataPointFillType.fromString(
dataFeedDetail.getFillMissingPointType().toString())))
.setAccessMode(DataFeedAccessMode.fromString(dataFeedDetail.getViewMode().toString()))
.setAdminEmails(dataFeedDetail.getAdmins())
.setAdmins(dataFeedDetail.getAdmins())
.setRollupSettings(new DataFeedRollupSettings()
.setAlreadyRollup(dataFeedDetail.getAllUpIdentification())
.setAutoRollup(DataFeedAutoRollUpMethod.fromString(dataFeedDetail.getRollUpMethod().toString()),
dataFeedDetail.getRollUpColumns())
.setRollupType(DataFeedRollupType.fromString(dataFeedDetail.getNeedRollup().toString())))
.setActionLinkTemplate(dataFeedDetail.getActionLinkTemplate())
.setViewerEmails(dataFeedDetail.getViewers()));
.setViewers(dataFeedDetail.getViewers()));

DataFeedHelper.setId(dataFeed, dataFeedDetail.getDataFeedId().toString());
DataFeedHelper.setCreatedTime(dataFeed, dataFeedDetail.getCreatedTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private HookHelper() { }
*/
public interface HookAccessor {
void setId(NotificationHook hook, String id);
List<String> getAdminEmailsRaw(NotificationHook hook);
List<String> getAdminsRaw(NotificationHook hook);
List<String> getEmailsToAlertRaw(EmailNotificationHook emailHook);
HttpHeaders getHttpHeadersRaw(WebNotificationHook webHook);
}
Expand All @@ -41,8 +41,8 @@ public static void setId(NotificationHook hook, String id) {
accessor.setId(hook, id);
}

public static List<String> getAdminEmailsRaw(NotificationHook hook) {
return accessor.getAdminEmailsRaw(hook);
public static List<String> getAdminsRaw(NotificationHook hook) {
return accessor.getAdminsRaw(hook);
}

public static List<String> getEmailsToAlertRaw(EmailNotificationHook emailHook) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static HookInfo toInnerForCreate(ClientLogger logger, NotificationHook no
innerEmailHook.setHookParameter(new EmailHookParameter()
.setToList(emailsToAlert));
}
innerEmailHook.setAdmins(HookHelper.getAdminEmailsRaw(emailHook));
innerEmailHook.setAdmins(HookHelper.getAdminsRaw(emailHook));
return innerEmailHook;
} else if (notificationHook instanceof WebNotificationHook) {
WebNotificationHook webHook = (WebNotificationHook) notificationHook;
Expand All @@ -82,7 +82,7 @@ public static HookInfo toInnerForCreate(ClientLogger logger, NotificationHook no
if (headers != null) {
hookParameter.setHeaders(headers.toMap());
}
innerWebHook.setAdmins(HookHelper.getAdminEmailsRaw(webHook));
innerWebHook.setAdmins(HookHelper.getAdminsRaw(webHook));
innerWebHook.setHookParameter(hookParameter);
return innerWebHook;
} else {
Expand All @@ -104,7 +104,7 @@ public static HookInfoPatch toInnerForUpdate(ClientLogger logger, NotificationHo
innerEmailHook.setHookParameter(new EmailHookParameterPatch()
.setToList(emailsToAlert));
}
innerEmailHook.setAdmins(HookHelper.getAdminEmailsRaw(emailHook));
innerEmailHook.setAdmins(HookHelper.getAdminsRaw(emailHook));
return innerEmailHook;
} else if (notificationHook instanceof WebNotificationHook) {
WebNotificationHook webHook = (WebNotificationHook) notificationHook;
Expand All @@ -123,7 +123,7 @@ public static HookInfoPatch toInnerForUpdate(ClientLogger logger, NotificationHo
hookParameter.setHeaders(headers.toMap());
}
innerWebHook.setHookParameter(hookParameter);
innerWebHook.setAdmins(HookHelper.getAdminEmailsRaw(webHook));
innerWebHook.setAdmins(HookHelper.getAdminsRaw(webHook));
return innerWebHook;
} else {
throw logger
Expand All @@ -143,7 +143,7 @@ public static NotificationHook fromInner(ClientLogger logger, HookInfo innerHook

HookHelper.setId(emailHook, innerEmailHook.getHookId().toString());

emailHook.setAdminEmails(innerEmailHook.getAdmins());
emailHook.setAdmins(innerEmailHook.getAdmins());

return emailHook;
} else if (innerHook instanceof WebhookHookInfo) {
Expand All @@ -167,7 +167,7 @@ public static NotificationHook fromInner(ClientLogger logger, HookInfo innerHook

HookHelper.setId(webHook, innerWebHook.getHookId().toString());

webHook.setAdminEmails(innerWebHook.getAdmins());
webHook.setAdmins(innerWebHook.getAdmins());

return webHook;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ public static void main(String[] args) {
Mono<DataFeed> updateDataFeedMono = fetchDataFeedMono
.flatMap(dataFeed -> {
return advisorAdministrationAsyncClient.updateDataFeed(dataFeed
.setOptions(new DataFeedOptions().setAdminEmails(Collections.singletonList("admin1@admin.com"))))
.setOptions(new DataFeedOptions().setAdmins(Collections.singletonList("admin1@admin.com"))))
.doOnSubscribe(__ ->
System.out.printf("Updating data feed: %s%n", dataFeed.getId()))
.doOnSuccess(updatedDataFeed -> {

System.out.printf("Updated data feed%n");
System.out.printf("Updated data feed admin list: %s%n",
String.join(",", updatedDataFeed.getOptions().getAdminEmails()));
String.join(",", updatedDataFeed.getOptions().getAdmins()));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public static void main(String[] args) {
// Update the data feed.
System.out.printf("Updating data feed: %s%n", dataFeed.getId());
dataFeed = advisorAdministrationClient.updateDataFeed(dataFeed.setOptions(new DataFeedOptions()
.setAdminEmails(Collections.singletonList("admin1@admin.com"))
.setAdmins(Collections.singletonList("admin1@admin.com"))
));
System.out.printf("Updated data feed admin list: %s%n",
String.join(",", dataFeed.getOptions().getAdminEmails()));
String.join(",", dataFeed.getOptions().getAdmins()));

// Delete the data feed.
System.out.printf("Deleting data feed: %s%n", dataFeed.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public void listHooksWithOptions() {
System.out.printf("Email Hook Description: %s%n", emailHook.getDescription());
System.out.printf("Email Hook External Link: %s%n", emailHook.getExternalLink());
System.out.printf("Email Hook Emails: %s%n", String.join(",", emailHook.getEmailsToAlert()));
System.out.printf("Email Hook Admins: %s%n", String.join(",", emailHook.getAdminEmails()));
System.out.printf("Email Hook Admins: %s%n", String.join(",", emailHook.getAdmins()));
} else if (notificationHook instanceof WebNotificationHook) {
WebNotificationHook webHook = (WebNotificationHook) notificationHook;
System.out.printf("Web Hook Id: %s%n", webHook.getId());
Expand All @@ -547,7 +547,7 @@ public void listHooksWithOptions() {
System.out.printf("Web Hook External Link: %s%n", webHook.getExternalLink());
System.out.printf("Web Hook Endpoint: %s%n", webHook.getEndpoint());
System.out.printf("Web Hook Headers: %s%n", webHook.getHttpHeaders());
System.out.printf("Web Hook Admins: %s%n", String.join(",", webHook.getAdminEmails()));
System.out.printf("Web Hook Admins: %s%n", String.join(",", webHook.getAdmins()));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public void listHooksWithOptions() {
System.out.printf("Email Hook External Link: %s%n", emailHook.getExternalLink());
System.out.printf("Email Hook Emails: %s%n", String.join(",",
emailHook.getEmailsToAlert()));
System.out.printf("Email Hook Admins: %s%n", String.join(",", emailHook.getAdminEmails()));
System.out.printf("Email Hook Admins: %s%n", String.join(",", emailHook.getAdmins()));
} else if (notificationHook instanceof WebNotificationHook) {
WebNotificationHook webHook = (WebNotificationHook) notificationHook;
System.out.printf("Web Hook Id: %s%n", webHook.getId());
Expand All @@ -532,7 +532,7 @@ public void listHooksWithOptions() {
System.out.printf("Web Hook External Link: %s%n", webHook.getExternalLink());
System.out.printf("Web Hook Endpoint: %s%n", webHook.getEndpoint());
System.out.printf("Web Hook Headers: %s%n", webHook.getHttpHeaders());
System.out.printf("Web Hook Admins: %s%n", String.join(",", webHook.getAdminEmails()));
System.out.printf("Web Hook Admins: %s%n", String.join(",", webHook.getAdmins()));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ private void validateDataFeedOptions(DataFeedOptions expectedOptions, DataFeedOp
if (expectedOptions != null) {
assertEquals(expectedOptions.getDescription(), actualOptions.getDescription());
assertEquals(expectedOptions.getActionLinkTemplate(), actualOptions.getActionLinkTemplate());
assertIterableEquals(expectedOptions.getAdminEmails(), actualOptions.getAdminEmails());
assertIterableEquals(expectedOptions.getViewerEmails(), actualOptions.getViewerEmails());
assertIterableEquals(expectedOptions.getAdmins(), actualOptions.getAdmins());
assertIterableEquals(expectedOptions.getViewers(), actualOptions.getViewers());
assertNotNull(actualOptions.getAccessMode());
if (expectedOptions.getAccessMode() != null) {
assertEquals(expectedOptions.getAccessMode(), actualOptions.getAccessMode());
Expand Down
Loading

0 comments on commit 7919b85

Please sign in to comment.