diff --git a/samples/CreateCoveoSource.java b/samples/CreateCoveoSource.java new file mode 100644 index 00000000..a5dc6215 --- /dev/null +++ b/samples/CreateCoveoSource.java @@ -0,0 +1,27 @@ +import com.coveo.pushapiclient.CatalogSource; +import com.coveo.pushapiclient.PlatformClient; +import com.coveo.pushapiclient.PushSource; +import com.coveo.pushapiclient.SourceVisibility; + +import java.io.IOException; +import java.net.http.HttpResponse; + + + +public class CreateCoveoSource { + public static void main(String[] args) { + PlatformClient platformClient = new PlatformClient("my_api_key", "my_org_id"); + try { + HttpResponse pushResponse = PushSource.create(platformClient, "the_name_of_my_source", SourceVisibility.SHARED); + System.out.println(String.format("Push Source creation status: %s", pushResponse.statusCode())); + System.out.println(String.format("Push Source creation response: %s", pushResponse.body())); + + HttpResponse response = CatalogSource.create(platformClient, "the_name_of_my_source", SourceVisibility.SHARED); + System.out.println(String.format("Catalog Source creation status: %s", response.statusCode())); + System.out.println(String.format("Catalog Source creation response: %s", response.body())); + + } catch (IOException | InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/samples/CreateSource.java b/samples/CreateSource.java index 41b19c5e..9e84669b 100644 --- a/samples/CreateSource.java +++ b/samples/CreateSource.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.net.http.HttpResponse; +// TODO: LENS-844 - Deprecate class public class CreateSource { public static void main(String[] args) { PlatformUrl platformUrl = new PlatformUrlBuilder() diff --git a/samples/InstantiateSource.java b/samples/InstantiateSource.java new file mode 100644 index 00000000..721e1f65 --- /dev/null +++ b/samples/InstantiateSource.java @@ -0,0 +1,20 @@ +import com.coveo.pushapiclient.*; + +import java.net.MalformedURLException; +import java.net.URL; + +public class InstantiateSource { + public static void main(String[] args) throws MalformedURLException { + //create source from url + URL url = new URL("https://api-eu.cloud.coveo.com/push/v1/organizations/my-org-id/sources/my-source-id/documents"); + PushSource pushSource1 = new PushSource("my_api_key", url); + CatalogSource catalogSource1 = new CatalogSource("my_api_key", url); + + + //create source from platform config + PlatformUrl platformUrl = new PlatformUrlBuilder().withEnvironment(Environment.PRODUCTION).withRegion(Region.EU).build(); + PushSource pushSource2 = PushSource.fromPlatformUrl("my_api_key","my_organization_id","my_source_id", platformUrl); + CatalogSource catalogSource2 = CatalogSource.fromPlatformUrl("my_api_key","my_organization_id","my_source_id", platformUrl); + + } +}