Search in sources :

Example 1 with PreferencesClient

use of co.cask.cdap.client.PreferencesClient in project cdap by caskdata.

the class GenerateClientUsageExample method preferencesClient.

public void preferencesClient() throws Exception {
    // Construct the client used to interact with CDAP
    PreferencesClient preferencesClient = new PreferencesClient(clientConfig);
    Map<String, String> propMap = Maps.newHashMap();
    propMap.put("k1", "v1");
    // Set preferences at the Instance level
    preferencesClient.setInstancePreferences(propMap);
    // Get preferences at the Instance level
    preferencesClient.getInstancePreferences();
    // Delete preferences at the Instance level
    preferencesClient.deleteInstancePreferences();
    // Set preferences of MyApp application which is deployed in the Dev namespace
    preferencesClient.setApplicationPreferences(new ApplicationId("Dev", "MyApp"), propMap);
    // Get only the preferences of MyApp application which is deployed in the Dev namespace
    Map<String, String> appPrefs = preferencesClient.getApplicationPreferences(new ApplicationId("Dev", "MyApp"), false);
    // Get the resolved preferences (collapsed with higher level(s) of preferences)
    Map<String, String> resolvedAppPrefs = preferencesClient.getApplicationPreferences(new ApplicationId("Dev", "MyApp"), true);
}
Also used : PreferencesClient(co.cask.cdap.client.PreferencesClient) ApplicationId(co.cask.cdap.proto.id.ApplicationId)

Aggregations

PreferencesClient (co.cask.cdap.client.PreferencesClient)1 ApplicationId (co.cask.cdap.proto.id.ApplicationId)1