This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git


The following commit(s) were added to refs/heads/master by this push:
     new e9e792f  Initial command line interface implementation
e9e792f is described below

commit e9e792ffe1d8c7dbc46afa6572b2b8b68253b595
Author: Dimuthu Wannipurage <[email protected]>
AuthorDate: Wed Mar 9 16:23:06 2022 -0500

    Initial command line interface implementation
---
 command-line/pom.xml                               | 89 ++++++++++++++++++++++
 .../airavata/mft/command/line/MainRunner.java      | 17 +++++
 .../command/line/sub/s3/S3ResourceSubCommand.java  | 65 ++++++++++++++++
 .../command/line/sub/s3/S3SecretSubCommand.java    | 27 +++++++
 .../mft/command/line/sub/s3/S3SubCommand.java      | 10 +++
 pom.xml                                            |  1 +
 6 files changed, 209 insertions(+)

diff --git a/command-line/pom.xml b/command-line/pom.xml
new file mode 100644
index 0000000..f26e1cf
--- /dev/null
+++ b/command-line/pom.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>airavata-mft</artifactId>
+        <groupId>org.apache.airavata</groupId>
+        <version>0.01-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>mft-command-line</artifactId>
+
+    <properties>
+        <maven.compiler.source>11</maven.compiler.source>
+        <maven.compiler.target>11</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>mft-api-client</artifactId>
+            <version>0.01-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>info.picocli</groupId>
+            <artifactId>picocli</artifactId>
+            <version>4.6.3</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>3.1.1</version>
+
+                <configuration>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
+                    <archive>
+                        <manifest>
+                            <!--mainClass>MinIoS3SimpleExample</mainClass-->
+                            <!--mainClass>MinIOMultipartUpload</mainClass-->
+                            <!--mainClass>MinIOMultipartAdvanced</mainClass-->
+                            
<!--mainClass>S3DownloadMultipartExample</mainClass-->
+                            
<mainClass>org.apache.airavata.mft.command.line.MainRunner</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git 
a/command-line/src/main/java/org/apache/airavata/mft/command/line/MainRunner.java
 
b/command-line/src/main/java/org/apache/airavata/mft/command/line/MainRunner.java
new file mode 100644
index 0000000..8855dc2
--- /dev/null
+++ 
b/command-line/src/main/java/org/apache/airavata/mft/command/line/MainRunner.java
@@ -0,0 +1,17 @@
+package org.apache.airavata.mft.command.line;
+
+import org.apache.airavata.mft.command.line.sub.s3.S3SubCommand;
+import picocli.CommandLine;
+import picocli.CommandLine.Command;
+
+@Command(name = "checksum", mixinStandardHelpOptions = true, version = 
"checksum 4.0",
+        description = "Prints the checksum (SHA-256 by default) of a file to 
STDOUT.",
+        subcommands = {S3SubCommand.class})
+class MainRunner {
+
+    public static void main(String... args) {
+        int exitCode = new CommandLine(new MainRunner())
+                .execute(args);
+        System.exit(exitCode);
+    }
+}
diff --git 
a/command-line/src/main/java/org/apache/airavata/mft/command/line/sub/s3/S3ResourceSubCommand.java
 
b/command-line/src/main/java/org/apache/airavata/mft/command/line/sub/s3/S3ResourceSubCommand.java
new file mode 100644
index 0000000..eb2d7b6
--- /dev/null
+++ 
b/command-line/src/main/java/org/apache/airavata/mft/command/line/sub/s3/S3ResourceSubCommand.java
@@ -0,0 +1,65 @@
+package org.apache.airavata.mft.command.line.sub.s3;
+
+import org.apache.airavata.mft.api.client.MFTApiClient;
+import org.apache.airavata.mft.common.AuthToken;
+import org.apache.airavata.mft.credential.stubs.s3.S3Secret;
+import org.apache.airavata.mft.credential.stubs.s3.S3SecretCreateRequest;
+import org.apache.airavata.mft.resource.service.s3.S3StorageServiceGrpc;
+import org.apache.airavata.mft.resource.stubs.s3.storage.S3Storage;
+import 
org.apache.airavata.mft.resource.stubs.s3.storage.S3StorageCreateRequest;
+import picocli.CommandLine;
+
[email protected](name = "remote")
+public class S3ResourceSubCommand {
+
+    @CommandLine.Command(name = "add")
+    void addS3Resource() {
+
+        AuthToken authToken = AuthToken.newBuilder().build();
+
+        String remoteName = System.console().readLine("Remote Name: ");
+        String bucket = System.console().readLine("Bucket: ");
+        String region = System.console().readLine("Region: ");
+        String endpoint = System.console().readLine("S3 Endpoint: ");
+        String useTLS = System.console().readLine("Use TLS [Y/n]: ");
+
+        String accessKey = System.console().readLine("Access Key: ");
+        String accessSecret = System.console().readLine("Access Secret: ");
+        System.out.println("Adding S3 Secret");
+        MFTApiClient mftApiClient = 
MFTApiClient.MFTApiClientBuilder.newBuilder().build();
+
+        S3Secret s3Secret = mftApiClient.getSecretServiceClient().s3()
+                .createS3Secret(S3SecretCreateRequest.newBuilder()
+                        .setAccessKey(accessKey)
+                        .setSecretKey(accessSecret)
+                        .setAuthzToken(authToken).build());
+
+        System.out.println("Adding S3 Storage");
+        S3StorageServiceGrpc.S3StorageServiceBlockingStub s3StorageClient = 
mftApiClient.getStorageServiceClient().s3();
+
+        S3Storage s3Storage = 
s3StorageClient.createS3Storage(S3StorageCreateRequest.newBuilder()
+                .setStorageId(remoteName)
+                .setEndpoint(endpoint)
+                .setBucketName(bucket)
+                .setUseTLS("Y".equals(useTLS))
+                .setRegion(region).build());
+
+        System.out.println("Successfully created the remote " + remoteName);
+
+    }
+
+    @CommandLine.Command(name = "delete")
+    void deleteS3Resource(@CommandLine.Parameters(index = "0") String 
resourceId) {
+        System.out.println("Deleting S3 Resource " + resourceId);
+    }
+
+    @CommandLine.Command(name = "list")
+    void listS3Resource() {
+        System.out.println("Listing S3 Resource");
+    }
+
+    @CommandLine.Command(name = "get")
+    void getS3Resource(@CommandLine.Parameters(index = "0") String resourceId) 
{
+        System.out.println("Getting S3 Resource " + resourceId);
+    }
+}
diff --git 
a/command-line/src/main/java/org/apache/airavata/mft/command/line/sub/s3/S3SecretSubCommand.java
 
b/command-line/src/main/java/org/apache/airavata/mft/command/line/sub/s3/S3SecretSubCommand.java
new file mode 100644
index 0000000..57add4f
--- /dev/null
+++ 
b/command-line/src/main/java/org/apache/airavata/mft/command/line/sub/s3/S3SecretSubCommand.java
@@ -0,0 +1,27 @@
+package org.apache.airavata.mft.command.line.sub.s3;
+
+import picocli.CommandLine;
+
[email protected](name = "secret")
+public class S3SecretSubCommand {
+    @CommandLine.Command(name = "add")
+    void addS3Secret() {
+        System.out.println("Adding S3 Secret");
+    }
+
+    @CommandLine.Command(name = "delete")
+    void deleteS3Secret(@CommandLine.Parameters(index = "0") String secretId) {
+        System.out.println("Deleting S3 Secret " + secretId);
+    }
+
+    @CommandLine.Command(name = "list")
+    void listS3Secret() {
+        System.out.println("Listing S3 Resource");
+    }
+
+    @CommandLine.Command(name = "get")
+    void getS3Secret(@CommandLine.Parameters(index = "0") String secretId) {
+        System.out.println("Getting S3 Secret " + secretId);
+    }
+}
+
diff --git 
a/command-line/src/main/java/org/apache/airavata/mft/command/line/sub/s3/S3SubCommand.java
 
b/command-line/src/main/java/org/apache/airavata/mft/command/line/sub/s3/S3SubCommand.java
new file mode 100644
index 0000000..abb0976
--- /dev/null
+++ 
b/command-line/src/main/java/org/apache/airavata/mft/command/line/sub/s3/S3SubCommand.java
@@ -0,0 +1,10 @@
+package org.apache.airavata.mft.command.line.sub.s3;
+
+import picocli.CommandLine;
+
[email protected](name = "s3", description = "Manage S3 resources and 
credentials",
+        subcommands = {S3ResourceSubCommand.class, S3SecretSubCommand.class})
+public class S3SubCommand {
+
+
+}
diff --git a/pom.xml b/pom.xml
index a2c70df..cb33e96 100755
--- a/pom.xml
+++ b/pom.xml
@@ -49,6 +49,7 @@
         <module>agent</module>
         <module>controller</module>
         <module>examples</module>
+        <module>command-line</module>
     </modules>
 
     <url>http://airavata.apache.org/</url>

Reply via email to