com.mulesoft.cloudhub.client
Class Connection

java.lang.Object
  extended by com.mulesoft.cloudhub.client.Connection
All Implemented Interfaces:
CloudhubConnection
Direct Known Subclasses:
DomainConnection

public class Connection
extends Object
implements CloudhubConnection

Base class for CloudHub interaction.


Nested Class Summary
static class Connection.ObjectMapper
           
 
Field Summary
static String DEFAULT_URL
           
 
Constructor Summary
Connection(String url, String username, String password)
           
Connection(String url, String username, String password, boolean debug)
           
 
Method Summary
 Notification create(Notification notification)
           Connects to CH to create a notification
 Tenant create(Tenant tenant, String domain)
           Creates a tenant
protected  com.sun.jersey.api.client.WebResource.Builder createBuilder(String path)
           
 Notification createNotification(String text, Notification.Priority priority, String domain, Map<String,String> customProperties)
          Deprecated. 
 void delete(String tenantId, String domain)
           Deletes a given tenant
 void deleteTenants(String domain, List<String> tenantIds)
           Deletes the tenants matching one of many given ids
 void dismissAllNotifications()
           Does what CloudhubConnection.dismissNotification(String) to all the queued notifications in CH
 void dismissNotification(String href)
           Removes the notification form the read queue
protected  String getAPIURL()
           
protected  String getPassword()
           
 Tenant getTenant(String domain, String tenantId)
           Returns an specific tenant
protected  String getUrl()
           
protected  String getUsername()
           
protected  void handleErrors(com.sun.jersey.api.client.ClientResponse response)
           
 List<Application> listApplications()
          
 NotificationResults listNotifications(Integer maxResults, Integer offset, String tenantId)
           Lists all the notifications of an app.
 TenantResults listTenants(String domain, Integer limit, Integer offset, String query)
           Lists tenants for a given domain
 DomainConnection on(String domain)
          
 boolean test()
          
 Tenant update(Tenant tenant, String domain)
           Updates a tenant
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_URL

public static final String DEFAULT_URL
See Also:
Constant Field Values
Constructor Detail

Connection

public Connection(String url,
                  String username,
                  String password)

Connection

public Connection(String url,
                  String username,
                  String password,
                  boolean debug)
Method Detail

getUrl

protected final String getUrl()

getUsername

protected final String getUsername()

getPassword

protected final String getPassword()

getAPIURL

protected final String getAPIURL()

createBuilder

protected com.sun.jersey.api.client.WebResource.Builder createBuilder(String path)

on

public final DomainConnection on(String domain)

Specified by:
on in interface CloudhubConnection
Parameters:
domain -

The domain of the required connection

Returns:

A connection for a specific domain


test

public final boolean test()

Specified by:
test in interface CloudhubConnection
Returns:
true if provided connection details allow to connect; false otherwise

listApplications

public final List<Application> listApplications()

Specified by:
listApplications in interface CloudhubConnection
Returns:
all existing applications

createNotification

@Deprecated
public final Notification createNotification(String text,
                                                        Notification.Priority priority,
                                                        String domain,
                                                        Map<String,String> customProperties)
Deprecated. 

Use CloudhubConnection.create(Notification) instead

Specified by:
createNotification in interface CloudhubConnection

create

public final Notification create(Notification notification)

Connects to CH to create a notification

Specified by:
create in interface CloudhubConnection
Parameters:
notification -

The notification information that needs to be created in CH

Returns:

The created notification


listNotifications

public final NotificationResults listNotifications(Integer maxResults,
                                                   Integer offset,
                                                   String tenantId)

Lists all the notifications of an app.

In the case of a multitenant application those notifications will be filtered by tenant id.

Specified by:
listNotifications in interface CloudhubConnection
Parameters:
maxResults -

Maximum number of results. For pagination.

offset -

Since which notification. For pagination.

tenantId -

Filter by tenant id. If null then don't apply the filter

Returns:

all existing applications


dismissNotification

public final void dismissNotification(String href)

Removes the notification form the read queue

Specified by:
dismissNotification in interface CloudhubConnection
Parameters:
href -

href id of the notification that needs to be dismissed


dismissAllNotifications

public final void dismissAllNotifications()

Does what CloudhubConnection.dismissNotification(String) to all the queued notifications in CH

Specified by:
dismissAllNotifications in interface CloudhubConnection

listTenants

public final TenantResults listTenants(String domain,
                                       Integer limit,
                                       Integer offset,
                                       String query)

Lists tenants for a given domain

Specified by:
listTenants in interface CloudhubConnection
Parameters:
domain - the domain owning the tenants
limit - The maximum number of results to return by default. Maximum of 100.
offset - The offset to start searching at
query - The company name, contact name, and email of the tenant to search form. Performs a case insensitive match to any part of the tenant name.
Returns:
an instance of TenantResults

getTenant

public final Tenant getTenant(String domain,
                              String tenantId)

Returns an specific tenant

Specified by:
getTenant in interface CloudhubConnection
Parameters:
domain - the domain owning the tenants
tenantId - the id of the tenant you want
Returns:
an instance of Tenant

create

public final Tenant create(Tenant tenant,
                           String domain)

Creates a tenant

Specified by:
create in interface CloudhubConnection
Parameters:
tenant - an instance of Tenant representing the tenant
domain - the domain that will own the tenant
Returns:
an instance of Tenant carrying the state of the newly created tenant

update

public final Tenant update(Tenant tenant,
                           String domain)

Updates a tenant

Specified by:
update in interface CloudhubConnection
Parameters:
tenant - an instance of Tenant with the tenant's new state
domain - the domain that will own the tenant
Returns:
an instance of Tenant carrying the tenant's updated state

delete

public final void delete(String tenantId,
                         String domain)

Deletes a given tenant

Specified by:
delete in interface CloudhubConnection
Parameters:
tenantId - the id of the tenant to be deleted
domain - the domain that owns the tenant to be deleted

deleteTenants

public void deleteTenants(String domain,
                          List<String> tenantIds)

Deletes the tenants matching one of many given ids

Specified by:
deleteTenants in interface CloudhubConnection
Parameters:
domain - the domain you want to clear of tenants
tenantIds - a list with tenant ids to be deleted

handleErrors

protected void handleErrors(com.sun.jersey.api.client.ClientResponse response)


Copyright © 2012-2013. All Rights Reserved.