Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Different Kinds Of Request Action For Linkis DataSource Client #1434

Merged
merged 21 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
29e24f6
add datasource action interface
xiaojie19852006 Feb 11, 2022
6770d88
add the request for create datasource action
xiaojie19852006 Feb 11, 2022
e57b5d0
add the request for datasource test connect action
xiaojie19852006 Feb 11, 2022
d4bd501
add the request for delete datasource action
xiaojie19852006 Feb 11, 2022
1f36c80
add the request for expire datasource action
xiaojie19852006 Feb 11, 2022
0e995a8
add the request for get all datasource types action
xiaojie19852006 Feb 11, 2022
16f7548
add the request for get connect params by datasource id action
xiaojie19852006 Feb 11, 2022
e8c38dc
add the request for get connect params by datasource name action
xiaojie19852006 Feb 11, 2022
e035f70
add the request for get datasource versions action
xiaojie19852006 Feb 11, 2022
52baf54
add the request for get info by datasource id action
xiaojie19852006 Feb 11, 2022
52e6958
add the request for get keytype of datasource action
xiaojie19852006 Feb 11, 2022
462209e
add the request for get columns of metadata action
xiaojie19852006 Feb 11, 2022
ea2ad90
add the request for get databases of metadata action
xiaojie19852006 Feb 11, 2022
d881b86
add the request for get partitions of metadata action
xiaojie19852006 Feb 11, 2022
669c75d
add the request for get table props of metadata action
xiaojie19852006 Feb 11, 2022
cdb882d
add the request for get tables of metadata action
xiaojie19852006 Feb 11, 2022
e50af31
add the request for pushish datasource versons action
xiaojie19852006 Feb 11, 2022
a924b71
add the request for query datasouce action
xiaojie19852006 Feb 11, 2022
077448b
add the request for query datasouce env action
xiaojie19852006 Feb 11, 2022
da1987d
add the request for update datasource action
xiaojie19852006 Feb 11, 2022
67203a0
add the request for update datasource param action
xiaojie19852006 Feb 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.linkis.datasource.client.request


import org.apache.linkis.datasource.client.config.DatasourceClientConfig.DATA_SOURCE_SERVICE_MODULE
import org.apache.linkis.httpclient.dws.DWSHttpClient
import org.apache.linkis.httpclient.request.POSTAction

import java.util
import scala.collection.JavaConverters._

class CreateDataSourceAction extends POSTAction with DataSourceAction{
override def getRequestPayload: String = DWSHttpClient.jacksonJson.writeValueAsString(getRequestPayloads)

private var user: String = _

override def setUser(user: String): Unit = this.user = user

override def getUser: String = this.user

override def suffixURLs: Array[String] = Array(DATA_SOURCE_SERVICE_MODULE.getValue, "info", "json")
}
object CreateDataSourceAction {
def builder(): Builder = new Builder

class Builder private[CreateDataSourceAction]() {
private var user: String = _
private var payload: util.Map[String, Any] = new util.HashMap[String, Any]()

def setUser(user: String): Builder = {
this.user = user
this
}

def addRequestPayload(key: String, value: Any): Builder = {
if (value != null) this.payload.put(key, value)
this
}

def addRequestPayloads(map: util.Map[String, Any]): Builder = {
this.synchronized(this.payload = map)
this
}

def build(): CreateDataSourceAction = {
val action = new CreateDataSourceAction
action.setUser(user)
this.payload.asScala.foreach(k => {
action.addRequestPayload(k._1, k._2)
})
action
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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.linkis.datasource.client.request

import org.apache.linkis.httpclient.dws.request.DWSHttpAction

trait DataSourceAction extends DWSHttpAction with org.apache.linkis.httpclient.request.UserAction
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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.linkis.datasource.client.request

import org.apache.linkis.datasource.client.config.DatasourceClientConfig.DATA_SOURCE_SERVICE_MODULE
import org.apache.linkis.datasource.client.exception.DataSourceClientBuilderException
import org.apache.linkis.httpclient.dws.DWSHttpClient
import org.apache.linkis.httpclient.request.PutAction


class DataSourceTestConnectAction private() extends PutAction with DataSourceAction {
private var user: String = _

private var dataSourceId: String = _

private var version: String = _

override def setUser(user: String): Unit = this.user = user

override def getUser: String = this.user

override def suffixURLs: Array[String] = Array(DATA_SOURCE_SERVICE_MODULE.getValue, dataSourceId, version, "op", "connect")

override def getRequestPayload: String = DWSHttpClient.jacksonJson.writeValueAsString(getRequestPayloads)
}
object DataSourceTestConnectAction {
def builder(): Builder = new Builder

class Builder private[DataSourceTestConnectAction]() {
private var user: String = _
private var dataSourceId: String = _
private var version: String = _

def setUser(user: String): Builder = {
this.user = user
this
}

def setDataSourceId(dataSourceId: String): Builder = {
this.dataSourceId = dataSourceId
this
}

def setVersion(version: String): Builder = {
this.version = version
this
}

def build(): DataSourceTestConnectAction = {
if (dataSourceId == null) throw new DataSourceClientBuilderException("dataSourceId is needed!")
if(version == null) throw new DataSourceClientBuilderException("version is needed!")
if(user == null) throw new DataSourceClientBuilderException("user is needed!")

val action = new DataSourceTestConnectAction()
action.dataSourceId = dataSourceId
action.version = version
action.user = user

action
}
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.linkis.datasource.client.request

import org.apache.linkis.datasource.client.config.DatasourceClientConfig.DATA_SOURCE_SERVICE_MODULE
import org.apache.linkis.datasource.client.exception.DataSourceClientBuilderException
import org.apache.linkis.httpclient.request.DeleteAction


class DeleteDataSourceAction extends DeleteAction with DataSourceAction {
private var user: String = _

private var resourceId: String = _

override def setUser(user: String): Unit = this.user = user

override def getUser: String = this.user

override def suffixURLs: Array[String] = Array(DATA_SOURCE_SERVICE_MODULE.getValue, "info", resourceId)
}
object DeleteDataSourceAction{
def builder(): Builder = new Builder
class Builder private[DeleteDataSourceAction]() {
private var user: String = _
private var resourceId: String = _

def setUser(user: String): Builder = {
this.user = user
this
}

def setResourceId(resourceId: String): Builder = {
this.resourceId = resourceId
this
}

def builder(): DeleteDataSourceAction = {
if (user == null) throw new DataSourceClientBuilderException("user is needed!")
if(resourceId == null) throw new DataSourceClientBuilderException("resourceId is needed!")

val action = new DeleteDataSourceAction
action.user = user
action.resourceId = resourceId
action
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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.linkis.datasource.client.request


import org.apache.linkis.datasource.client.config.DatasourceClientConfig.DATA_SOURCE_SERVICE_MODULE
import org.apache.linkis.datasource.client.exception.DataSourceClientBuilderException
import org.apache.linkis.httpclient.request.PutAction

class ExpireDataSourceAction extends PutAction with DataSourceAction {
override def getRequestPayload: String = ""

private var user: String = _

private var dataSourceId: String = _

override def setUser(user: String): Unit = this.user = user

override def getUser: String = this.user

override def suffixURLs: Array[String] = Array(DATA_SOURCE_SERVICE_MODULE.getValue, "info", dataSourceId, "expire")
}
object ExpireDataSourceAction{
def builder(): Builder = new Builder
class Builder private[ExpireDataSourceAction]() {
private var user: String = _
private var dataSourceId: String = _

def setUser(user: String): Builder = {
this.user = user
this
}

def setDataSourceId(dataSourceId: String): Builder = {
this.dataSourceId = dataSourceId
this
}
def build(): ExpireDataSourceAction = {
if (dataSourceId == null) throw new DataSourceClientBuilderException("dataSourceId is needed!")
if(user == null) throw new DataSourceClientBuilderException("user is needed!")

val action = new ExpireDataSourceAction()
action.dataSourceId = dataSourceId
action.user = user
action
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.linkis.datasource.client.request


import org.apache.linkis.datasource.client.config.DatasourceClientConfig.DATA_SOURCE_SERVICE_MODULE
import org.apache.linkis.httpclient.request.GetAction

class GetAllDataSourceTypesAction extends GetAction with DataSourceAction {
override def suffixURLs: Array[String] = Array(DATA_SOURCE_SERVICE_MODULE.getValue, "type", "all")

private var user: String = _

override def setUser(user: String): Unit = this.user = user

override def getUser: String = this.user
}

object GetAllDataSourceTypesAction {
def builder(): Builder = new Builder

class Builder private[GetAllDataSourceTypesAction]() {
private var user: String = _

def setUser(user: String): Builder = {
this.user = user
this
}

def build(): GetAllDataSourceTypesAction = {
val action = new GetAllDataSourceTypesAction
action.setUser(user)

action
}
}
}