container/src/main/java/com/streamsets/datacollector/cli/sch/SchAdmin.java
public static void disableDPM(String userAuthToken, String organizationId, Context context) throws IOException {
    // check if DPM enabled
    if (!context.runtimeInfo.isDPMEnabled()) {
      throw new RuntimeException("disableDPM is supported only when DPM is enabled");
    }

    String dpmBaseURL = normalizeDpmBaseURL(context.configuration.get(RemoteSSOService.DPM_BASE_URL_CONFIG, ""));
    String componentId = context.runtimeInfo.getId();

    // 2. Deactivate Data Collector System Component
    Response response = null;
    try {
      response = ClientBuilder.newClient()
          .target(dpmBaseURL + "/security/rest/v1/organization/" + organizationId + "/components/deactivate")
          .register(new CsrfProtectionFilter("CSRF"))
          .request()
          .header(SSOConstants.X_USER_AUTH_TOKEN, userAuthToken)
          .header(SSOConstants.X_REST_CALL, true)
          .post(Entity.json(ImmutableList.of(componentId)));
      if (response.getStatus() != Response.Status.OK.getStatusCode()) {
        throw new RuntimeException(Utils.format(
            " Deactivate Data Collector System Component from DPM failed, status code '{}': {}",
            response.getStatus(),
            response.readEntity(String.class)
        ));
      }
    } finally {
      if (response != null) {
        response.close();
      }
    }

    // 3. Delete Data Collector System Component
    try {
      response = ClientBuilder.newClient()
          .target(dpmBaseURL + "/security/rest/v1/organization/" + organizationId + "/components/delete")
          .register(new CsrfProtectionFilter("CSRF"))
          .request()
          .header(SSOConstants.X_USER_AUTH_TOKEN, userAuthToken)
          .header(SSOConstants.X_REST_CALL, true)
          .post(Entity.json(ImmutableList.of(componentId)));
      if (response.getStatus() != Response.Status.OK.getStatusCode()) {
        throw new RuntimeException(Utils.format(
            " Deactivate Data Collector System Component from DPM failed, status code '{}': {}",
            response.getStatus(),
            response.readEntity(String.class)
        ));
      }
    } finally {
      if (response != null) {
        response.close();
      }
    }

    // 4. Delete from Job Runner SDC list
    try {
      response = ClientBuilder.newClient()
          .target(dpmBaseURL + "/jobrunner/rest/v1/sdc/" + componentId)
          .register(new CsrfProtectionFilter("CSRF"))
          .request()
          .header(SSOConstants.X_USER_AUTH_TOKEN, userAuthToken)
          .header(SSOConstants.X_REST_CALL, true)
          .delete();
      if (response.getStatus() != Response.Status.OK.getStatusCode()) {
        throw new RuntimeException(Utils.format(
            "Delete from DPM Job Runner SDC list failed, status code '{}': {}",
            response.getStatus(),
            response.readEntity(String.class)
        ));
      }
    } finally {
      if (response != null) {
        response.close();
      }
    }

    // 5. Update App Token file
    updateTokenFile(context, "");

    // 4. Update dpm.properties file
    updateDpmProperties(context, dpmBaseURL, null, false);
  }
public static void disableDPM(String userAuthToken, String organizationId, Context context) throws IOException {
    // check if DPM enabled
    if (!context.runtimeInfo.isDPMEnabled()) {
      throw new RuntimeException("disableDPM is supported only when DPM is enabled");
    }

    String dpmBaseURL = normalizeDpmBaseURL(context.configuration.get(RemoteSSOService.DPM_BASE_URL_CONFIG, ""));
    String componentId = context.runtimeInfo.getId();

    // 2. Deactivate Data Collector System Component
    Response response = null;
    try {
      response = ClientBuilder.newClient()
          .target(dpmBaseURL + "/security/rest/v1/organization/" + organizationId + "/components/deactivate")
          .register(new CsrfProtectionFilter("CSRF"))
          .request()
          .header(SSOConstants.X_USER_AUTH_TOKEN, userAuthToken)
          .header(SSOConstants.X_REST_CALL, true)
          .post(Entity.json(ImmutableList.of(componentId)));
      if (response.getStatus() != Response.Status.OK.getStatusCode()) {
        throw new RuntimeException(Utils.format(
            " Deactivate Data Collector System Component from DPM failed, status code '{}': {}",
            response.getStatus(),
            response.readEntity(String.class)
        ));
      }
    } finally {
      if (response != null) {
        response.close();
      }
    }

    // 3. Delete Data Collector System Component
    try {
      response = ClientBuilder.newClient()
          .target(dpmBaseURL + "/security/rest/v1/organization/" + organizationId + "/components/delete")
          .register(new CsrfProtectionFilter("CSRF"))
          .request()
          .header(SSOConstants.X_USER_AUTH_TOKEN, userAuthToken)
          .header(SSOConstants.X_REST_CALL, true)
          .post(Entity.json(ImmutableList.of(componentId)));
      if (response.getStatus() != Response.Status.OK.getStatusCode()) {
        throw new RuntimeException(Utils.format(
            " Deactivate Data Collector System Component from DPM failed, status code '{}': {}",
            response.getStatus(),
            response.readEntity(String.class)
        ));
      }
    } finally {
      if (response != null) {
        response.close();
      }
    }

    // 4. Delete from Job Runner SDC list
    try {
      response = ClientBuilder.newClient()
          .target(dpmBaseURL + "/jobrunner/rest/v1/sdc/" + componentId)
          .register(new CsrfProtectionFilter("CSRF"))
          .request()
          .header(SSOConstants.X_USER_AUTH_TOKEN, userAuthToken)
          .header(SSOConstants.X_REST_CALL, true)
          .delete();
      if (response.getStatus() != Response.Status.OK.getStatusCode()) {
        throw new RuntimeException(Utils.format(
            "Delete from DPM Job Runner SDC list failed, status code '{}': {}",
            response.getStatus(),
            response.readEntity(String.class)
        ));
      }
    } finally {
      if (response != null) {
        response.close();
      }
    }

    // 5. Update App Token file
    updateTokenFile(context, "");

    // 4. Update dpm.properties file
    updateDpmProperties(context, dpmBaseURL, null, false);
  }
Disable Control Hub on this Data Collector - using existing auth token.