Search in sources :

Example 1 with ApplicationClient

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

the class GenerateClientUsageExample method applicationClient.

public void applicationClient() throws Exception {
    // Construct the client used to interact with CDAP
    ApplicationClient appClient = new ApplicationClient(clientConfig);
    // Fetch the list of applications
    List<ApplicationRecord> apps = appClient.list(NamespaceId.DEFAULT);
    // Deploy an application
    File appJarFile = new File("your-app.jar");
    appClient.deploy(NamespaceId.DEFAULT, appJarFile);
    // Delete an application
    appClient.delete(NamespaceId.DEFAULT.app("Purchase"));
    // List programs belonging to an application
    appClient.listPrograms(NamespaceId.DEFAULT.app("Purchase"));
}
Also used : ApplicationClient(co.cask.cdap.client.ApplicationClient) File(java.io.File) ApplicationRecord(co.cask.cdap.proto.ApplicationRecord)

Example 2 with ApplicationClient

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

the class IntegrationTestBaseTest method testDeployApplicationInNamespace.

@Test
public void testDeployApplicationInNamespace() throws Exception {
    NamespaceId namespace = new NamespaceId("Test1");
    NamespaceMeta namespaceMeta = new NamespaceMeta.Builder().setName(namespace).build();
    getNamespaceClient().create(namespaceMeta);
    ClientConfig clientConfig = new ClientConfig.Builder(getClientConfig()).build();
    deployApplication(namespace, TestApplication.class);
    // Check the default namespaces applications to see whether the application wasn't made in the default namespace
    ClientConfig defaultClientConfig = new ClientConfig.Builder(getClientConfig()).build();
    Assert.assertEquals(0, new ApplicationClient(defaultClientConfig).list(NamespaceId.DEFAULT).size());
    ApplicationClient applicationClient = new ApplicationClient(clientConfig);
    Assert.assertEquals(TestApplication.NAME, applicationClient.list(namespace).get(0).getName());
    applicationClient.delete(namespace.app(TestApplication.NAME));
    Assert.assertEquals(0, new ApplicationClient(clientConfig).list(namespace).size());
}
Also used : ApplicationClient(co.cask.cdap.client.ApplicationClient) NamespaceMeta(co.cask.cdap.proto.NamespaceMeta) NamespaceId(co.cask.cdap.proto.id.NamespaceId) ClientConfig(co.cask.cdap.client.config.ClientConfig) Test(org.junit.Test)

Example 3 with ApplicationClient

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

the class IntegrationTestBase method assertNoApps.

private void assertNoApps(NamespaceId namespace) throws Exception {
    ApplicationClient applicationClient = getApplicationClient();
    List<ApplicationRecord> applicationRecords = applicationClient.list(namespace);
    List<String> applicationIds = Lists.newArrayList();
    for (ApplicationRecord applicationRecord : applicationRecords) {
        applicationIds.add(applicationRecord.getName());
    }
    Assert.assertTrue("Must have no deployed apps, but found the following apps: " + Joiner.on(", ").join(applicationIds), applicationRecords.isEmpty());
}
Also used : ApplicationClient(co.cask.cdap.client.ApplicationClient) ApplicationRecord(co.cask.cdap.proto.ApplicationRecord)

Aggregations

ApplicationClient (co.cask.cdap.client.ApplicationClient)3 ApplicationRecord (co.cask.cdap.proto.ApplicationRecord)2 ClientConfig (co.cask.cdap.client.config.ClientConfig)1 NamespaceMeta (co.cask.cdap.proto.NamespaceMeta)1 NamespaceId (co.cask.cdap.proto.id.NamespaceId)1 File (java.io.File)1 Test (org.junit.Test)1