@Test public void getDashboardByName() throws Exception { DashboardObject dashboardObj = ImmutableDashboardObject.builder().name(NAME).ownerName(OWNER_NAME).build(); Response<List<DashboardObject>> response = Response.success(Collections.singletonList(dashboardObj)); @SuppressWarnings("unchecked") Call<List<DashboardObject>>responseCall = mock(Call.class); doReturn(response).when(responseCall).execute(); doReturn(request).when(responseCall).request(); doReturn(responseCall).when(svc).getDashboardByName(any(), anyString(), anyString()); DashboardObject dashboard = argus.getDashboardByName(OWNER_NAME, NAME); assertThat(dashboard.name(), is(NAME)); assertThat(dashboard.ownerName(), is(OWNER_NAME)); }
public DashboardObject getDashboardByName(String owner, String dashboardName) throws UnauthorizedException { Preconditions.checkNotNull(owner, "Owner name must be non-null"); Preconditions.checkArgument(!owner.isEmpty(), "Owner name must non-empty"); Preconditions.checkNotNull(dashboardName, "Dashboard name must be non-null"); Preconditions.checkArgument(!dashboardName.isEmpty(), "Dashboard name must non-empty"); List<DashboardObject> result = executeAndRetrieveBody(svc().getDashboardByName(authorizationHeader(), owner, dashboardName), null); if (isNull(result) || result.isEmpty()) { return null; } return result.get(0); }
ArgusClient extends AbstractRemoteClient<ArgusService> { public DashboardObject getDashboardByName(String owner, String dashboardName) throws UnauthorizedException { Preconditions.checkNotNull(owner, "Owner name must be non-null"); Preconditions.checkArgument(!owner.isEmpty(), "Owner name must non-empty"); Preconditions.checkNotNull(dashboardName, "Dashboard name must be non-null"); Preconditions.checkArgument(!dashboardName.isEmpty(), "Dashboard name must non-empty"); List<DashboardObject> result = executeAndRetrieveBody(svc().getDashboardByName(authorizationHeader(), owner, dashboardName), null); if (isNull(result) || result.isEmpty()) { return null; } return result.get(0); } }
ArgusClient extends AbstractRemoteClient<ArgusService> { public DashboardObject getDashboardByName(String owner, String dashboardName) throws UnauthorizedException { Preconditions.checkNotNull(owner, "Owner name must be non-null"); Preconditions.checkArgument(!owner.isEmpty(), "Owner name must non-empty"); Preconditions.checkNotNull(dashboardName, "Dashboard name must be non-null"); Preconditions.checkArgument(!dashboardName.isEmpty(), "Dashboard name must non-empty"); List<DashboardObject> result = executeAndRetrieveBody(svc().getDashboardByName(authorizationHeader(), owner, dashboardName), null); if (isNull(result) || result.isEmpty()) { return null; } return result.get(0); } ArgusClient(EndpointConnector connector); }
ArgusClient extends AbstractRemoteClient<ArgusService> { public DashboardObject getDashboardByName(String owner, String dashboardName) throws UnauthorizedException { Preconditions.checkNotNull(owner, "Owner name must be non-null"); Preconditions.checkArgument(!owner.isEmpty(), "Owner name must non-empty"); Preconditions.checkNotNull(dashboardName, "Dashboard name must be non-null"); Preconditions.checkArgument(!dashboardName.isEmpty(), "Dashboard name must non-empty"); List<DashboardObject> result = executeAndRetrieveBody(svc().getDashboardByName(authorizationHeader(), owner, dashboardName), null); if (isNull(result) || result.isEmpty()) { return null; } return result.get(0); } ArgusClient(EndpointConnector connector); @Override boolean isAuthenticated(); List<MetricResponse> getMetrics(List<String> expressions); AlertObject createAlert(AlertObject alert); AlertObject updateAlert(AlertObject alert); AlertObject loadAlert(long id); List<AlertObject> loadAllAlerts(); List<AlertObject> loadAlertsByOwner(String ownerName); List<AlertObject> loadAlertsMetadataByOwner(String ownerName); void deleteAlert(long alertId); List<TriggerObject> loadTriggersForAlert(long alertId); List<TriggerObject> createTrigger(long alertId, TriggerObject trigger); TriggerObject updateTrigger(long alertId, TriggerObject trigger); void deleteTrigger(long alertId, long triggerId); NotificationObject getNotification(long alertId, long notificationId); List<NotificationObject> getNotificationsForAlert(long alertId); List<NotificationObject> createNotification(long alertId, NotificationObject notification); NotificationObject updateNotification(long alertId, long notificationId, NotificationObject notification); void deleteNotification(long alertId, long notificationId); TriggerObject attachTriggerToNotification(long alertId, long notificationId, long triggerId); void removeTriggerFromNotification(long alertId, long notificationId, long triggerId); List<DashboardObject> getAllDashboards(); DashboardObject getDashboardByName(String owner, String dashboardName); DashboardObject createDashboard(DashboardObject dashboard); DashboardObject updateDashboard(long dashboardId, DashboardObject dashboard); void deleteDashboard(long dashboardId); DashboardObject getDashboardById(long dashboardId); }
ArgusClient extends AbstractRemoteClient<ArgusService> { public DashboardObject getDashboardByName(String owner, String dashboardName) throws UnauthorizedException { Preconditions.checkNotNull(owner, "Owner name must be non-null"); Preconditions.checkArgument(!owner.isEmpty(), "Owner name must non-empty"); Preconditions.checkNotNull(dashboardName, "Dashboard name must be non-null"); Preconditions.checkArgument(!dashboardName.isEmpty(), "Dashboard name must non-empty"); List<DashboardObject> result = executeAndRetrieveBody(svc().getDashboardByName(authorizationHeader(), owner, dashboardName), null); if (isNull(result) || result.isEmpty()) { return null; } return result.get(0); } ArgusClient(EndpointConnector connector); @Override boolean isAuthenticated(); List<MetricResponse> getMetrics(List<String> expressions); AlertObject createAlert(AlertObject alert); AlertObject updateAlert(AlertObject alert); AlertObject loadAlert(long id); List<AlertObject> loadAllAlerts(); List<AlertObject> loadAlertsByOwner(String ownerName); List<AlertObject> loadAlertsMetadataByOwner(String ownerName); void deleteAlert(long alertId); List<TriggerObject> loadTriggersForAlert(long alertId); List<TriggerObject> createTrigger(long alertId, TriggerObject trigger); TriggerObject updateTrigger(long alertId, TriggerObject trigger); void deleteTrigger(long alertId, long triggerId); NotificationObject getNotification(long alertId, long notificationId); List<NotificationObject> getNotificationsForAlert(long alertId); List<NotificationObject> createNotification(long alertId, NotificationObject notification); NotificationObject updateNotification(long alertId, long notificationId, NotificationObject notification); void deleteNotification(long alertId, long notificationId); TriggerObject attachTriggerToNotification(long alertId, long notificationId, long triggerId); void removeTriggerFromNotification(long alertId, long notificationId, long triggerId); List<DashboardObject> getAllDashboards(); DashboardObject getDashboardByName(String owner, String dashboardName); DashboardObject createDashboard(DashboardObject dashboard); DashboardObject updateDashboard(long dashboardId, DashboardObject dashboard); void deleteDashboard(long dashboardId); DashboardObject getDashboardById(long dashboardId);  }