This is an automated email from the ASF dual-hosted git repository. smarru pushed a commit to branch metadata-service in repository https://gitbox.apache.org/repos/asf/airavata-data-lake.git
commit 5c072e3b648a1b56f7aa19910764f83df6ca3f14 Author: Dimuthu Wannipurage <dimuthu.upeks...@gmail.com> AuthorDate: Tue Jan 5 04:51:42 2021 -0500 Initial framework for orchestrator API --- data-orchestrator/data-orchestrator-api/pom.xml | 51 ++++++++++ .../datalake/orchestrator/api/Application.java | 7 ++ .../HookController.java} | 7 +- .../api/controller/TransferController.java | 48 +++++++++ .../api/controller/remote/SFTPController.java | 57 +++++++++++ .../orchestrator/api/model/TransferEntry.java | 75 ++++++++++++++ .../api/model/remote/SFTPCredential.java | 110 +++++++++++++++++++++ .../orchestrator/api/model/remote/SFTPRemote.java | 73 ++++++++++++++ data-orchestrator/pom.xml | 21 ++++ 9 files changed, 444 insertions(+), 5 deletions(-) diff --git a/data-orchestrator/data-orchestrator-api/pom.xml b/data-orchestrator/data-orchestrator-api/pom.xml index 720bd6c..c840c04 100644 --- a/data-orchestrator/data-orchestrator-api/pom.xml +++ b/data-orchestrator/data-orchestrator-api/pom.xml @@ -1,4 +1,25 @@ <?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"> @@ -11,5 +32,35 @@ <artifactId>data-orchestrator-api</artifactId> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <version>2.4.1</version> + </dependency> + + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + </exclusion> + </exclusions> + <version>2.4.1</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>2.4.1</version> + </plugin> + </plugins> + </build> </project> \ No newline at end of file diff --git a/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/Application.java b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/Application.java index dc91369..df78fc2 100644 --- a/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/Application.java +++ b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/Application.java @@ -19,8 +19,15 @@ */ package org.apache.airavata.datalake.orchestrator.api; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + /** * TODO: Spring Boot API */ +@SpringBootApplication public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } } diff --git a/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/Application.java b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/controller/HookController.java similarity index 87% copy from data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/Application.java copy to data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/controller/HookController.java index dc91369..c171681 100644 --- a/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/Application.java +++ b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/controller/HookController.java @@ -17,10 +17,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.airavata.datalake.orchestrator.api; +package org.apache.airavata.datalake.orchestrator.api.controller; -/** - * TODO: Spring Boot API - */ -public class Application { +public class HookController { } diff --git a/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/controller/TransferController.java b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/controller/TransferController.java new file mode 100644 index 0000000..5e5b04c --- /dev/null +++ b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/controller/TransferController.java @@ -0,0 +1,48 @@ +/* + * + * 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. + */ +package org.apache.airavata.datalake.orchestrator.api.controller; + +import org.apache.airavata.datalake.orchestrator.api.model.TransferEntry; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping(path = "/transfer") +public class TransferController { + + @PostMapping(path = "") + public String createTransfer(@RequestBody TransferEntry transferEntry) { + return "transfer-id"; + } + + @GetMapping(path = "/start/{transferId}") + public String startTransfer(@PathVariable(name = "transferId") String transferId) { + return "trackingId"; + } + + @GetMapping(path = "/track/{trackingId}") + public String trackTransfer(@PathVariable(name = "trackingId") String trackingId) { + return "RUNNING"; + } + + @GetMapping(path = "/cancel/{trackingId}") + public String cancelTransfer(@PathVariable(name = "trackingId") String trackingId) { + return "CANCELLED"; + } +} diff --git a/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/controller/remote/SFTPController.java b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/controller/remote/SFTPController.java new file mode 100644 index 0000000..5492889 --- /dev/null +++ b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/controller/remote/SFTPController.java @@ -0,0 +1,57 @@ +/* + * + * 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. + */ +package org.apache.airavata.datalake.orchestrator.api.controller.remote; + +import org.apache.airavata.datalake.orchestrator.api.model.remote.SFTPCredential; +import org.apache.airavata.datalake.orchestrator.api.model.remote.SFTPRemote; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping(path = "/remotes/sftp") +public class SFTPController { + + @GetMapping(value = "/{remoteId}", produces = "application/json") + public SFTPRemote fetchSFTPRemote(@PathVariable(name = "remoteId") String remoteId) { + return new SFTPRemote() + .setHost("localhost") + .setPort(22) + .setCredential( + new SFTPCredential() + .setAuthMethod(SFTPCredential.AuthMethod.SSH_KEY) + .setPrivateKey("") + .setPublicKey("")); + } + + @PostMapping(value = "") + public String createSFTPRemote(@RequestBody SFTPRemote sftpRemote) { + return "Remote id"; + } + + @PutMapping(value = "/{remoteId}") + public String updateSFTPRemote(@RequestBody SFTPRemote sftpRemote, + @PathVariable(name = "remoteId") String remoteId) { + return "Remote id"; + } + + @DeleteMapping(value = "/{remoteId}") + public String removeSFTPRemote(@PathVariable(name = "remoteId") String remoteId) { + return "Deleted"; + } +} diff --git a/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/model/TransferEntry.java b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/model/TransferEntry.java new file mode 100644 index 0000000..a597836 --- /dev/null +++ b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/model/TransferEntry.java @@ -0,0 +1,75 @@ +/* + * + * 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. + */ +package org.apache.airavata.datalake.orchestrator.api.model; + +public class TransferEntry { + + private String id; + private String sourceRemoteId; + private String sourcePath; + + private String destRemoteId; + private String destPath; + + public String getId() { + return id; + } + + public TransferEntry setId(String id) { + this.id = id; + return this; + } + + public String getSourceRemoteId() { + return sourceRemoteId; + } + + public TransferEntry setSourceRemoteId(String sourceRemoteId) { + this.sourceRemoteId = sourceRemoteId; + return this; + } + + public String getSourcePath() { + return sourcePath; + } + + public TransferEntry setSourcePath(String sourcePath) { + this.sourcePath = sourcePath; + return this; + } + + public String getDestRemoteId() { + return destRemoteId; + } + + public TransferEntry setDestRemoteId(String destRemoteId) { + this.destRemoteId = destRemoteId; + return this; + } + + public String getDestPath() { + return destPath; + } + + public TransferEntry setDestPath(String destPath) { + this.destPath = destPath; + return this; + } +} diff --git a/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/model/remote/SFTPCredential.java b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/model/remote/SFTPCredential.java new file mode 100644 index 0000000..ee9a91c --- /dev/null +++ b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/model/remote/SFTPCredential.java @@ -0,0 +1,110 @@ +/* + * + * 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. + */ +package org.apache.airavata.datalake.orchestrator.api.model.remote; + +public class SFTPCredential { + + public enum AuthMethod {SSH_KEY, PASSWORD} + private String id; + + private String userName; + + private String existingKeyId; + + private String publicKey; + private String privateKey; + private String passphrase; + + private String password; + + private AuthMethod authMethod; + + public String getId() { + return id; + } + + public SFTPCredential setId(String id) { + this.id = id; + return this; + } + + public String getUserName() { + return userName; + } + + public SFTPCredential setUserName(String userName) { + this.userName = userName; + return this; + } + + public String getExistingKeyId() { + return existingKeyId; + } + + public SFTPCredential setExistingKeyId(String existingKeyId) { + this.existingKeyId = existingKeyId; + return this; + } + + public String getPublicKey() { + return publicKey; + } + + public SFTPCredential setPublicKey(String publicKey) { + this.publicKey = publicKey; + return this; + } + + public String getPrivateKey() { + return privateKey; + } + + public SFTPCredential setPrivateKey(String privateKey) { + this.privateKey = privateKey; + return this; + } + + public String getPassphrase() { + return passphrase; + } + + public SFTPCredential setPassphrase(String passphrase) { + this.passphrase = passphrase; + return this; + } + + public String getPassword() { + return password; + } + + public SFTPCredential setPassword(String password) { + this.password = password; + return this; + } + + public AuthMethod getAuthMethod() { + return authMethod; + } + + public SFTPCredential setAuthMethod(AuthMethod authMethod) { + this.authMethod = authMethod; + return this; + } +} diff --git a/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/model/remote/SFTPRemote.java b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/model/remote/SFTPRemote.java new file mode 100644 index 0000000..68d6578 --- /dev/null +++ b/data-orchestrator/data-orchestrator-api/src/main/java/org/apache/airavata/datalake/orchestrator/api/model/remote/SFTPRemote.java @@ -0,0 +1,73 @@ +/* + * + * 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. + */ +package org.apache.airavata.datalake.orchestrator.api.model.remote; + +public class SFTPRemote { + private String id; + private String name; + private String host; + private Integer port; + private SFTPCredential credential; + + public String getId() { + return id; + } + + public SFTPRemote setId(String id) { + this.id = id; + return this; + } + + public String getName() { + return name; + } + + public SFTPRemote setName(String name) { + this.name = name; + return this; + } + + public String getHost() { + return host; + } + + public SFTPRemote setHost(String host) { + this.host = host; + return this; + } + + public Integer getPort() { + return port; + } + + public SFTPRemote setPort(Integer port) { + this.port = port; + return this; + } + + public SFTPCredential getCredential() { + return credential; + } + + public SFTPRemote setCredential(SFTPCredential credential) { + this.credential = credential; + return this; + } +} diff --git a/data-orchestrator/pom.xml b/data-orchestrator/pom.xml index d0ba9bf..2d3ee54 100644 --- a/data-orchestrator/pom.xml +++ b/data-orchestrator/pom.xml @@ -1,4 +1,25 @@ <?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">