|
@@ -18,6 +18,7 @@ const servicePrefix = "/osm/api/v1"
|
|
|
var prefix string
|
|
|
var namespace string
|
|
|
var name string
|
|
|
+var baseUrl string
|
|
|
var httpClient *http_client.Client
|
|
|
|
|
|
type (
|
|
@@ -62,10 +63,11 @@ func Destroy() {
|
|
|
httpClient = nil
|
|
|
}
|
|
|
|
|
|
-func Init(configPrefix, configNamespace, configName, baseUrl string) error {
|
|
|
+func Init(configPrefix, configNamespace, configName, configBaseUrl string) error {
|
|
|
prefix = configPrefix
|
|
|
namespace = configNamespace
|
|
|
name = configName
|
|
|
+ baseUrl = configBaseUrl + servicePrefix
|
|
|
|
|
|
if httpClient == nil {
|
|
|
httpClient = http_client.New()
|
|
@@ -88,7 +90,7 @@ func getUrl(objName string) (string, error) {
|
|
|
}
|
|
|
|
|
|
getResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).
|
|
|
- Get(servicePrefix+"/operation/url/get",
|
|
|
+ Get(baseUrl+"/operation/url/get",
|
|
|
http_client.WithRequestQueryParams(map[string]string{
|
|
|
"namespace": namespace,
|
|
|
"name": name,
|
|
@@ -147,7 +149,7 @@ func zoomUrl(objName, process string) (string, error) {
|
|
|
}
|
|
|
|
|
|
postResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).
|
|
|
- Post(servicePrefix+"/operation/obj/zoomUrl", ZoomUrlJsonBody{
|
|
|
+ Post(baseUrl+"/operation/obj/zoomUrl", ZoomUrlJsonBody{
|
|
|
ConfigKey: ConfigKey{
|
|
|
Namespace: namespace,
|
|
|
Name: name,
|
|
@@ -194,7 +196,7 @@ func exist(objName string) (bool, error) {
|
|
|
if strutils.IsStringEmpty(objName) {
|
|
|
return false, nil
|
|
|
}
|
|
|
- getResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).Get(servicePrefix+"/operation/obj/check", http_client.WithRequestQueryParams(map[string]string{
|
|
|
+ getResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).Get(baseUrl+"/operation/obj/check", http_client.WithRequestQueryParams(map[string]string{
|
|
|
"namespace": namespace,
|
|
|
"name": name,
|
|
|
"objName": objName}))
|
|
@@ -231,7 +233,7 @@ func deleteMulti(objNames ...string) error {
|
|
|
if len(objNames) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
- postResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).Post(servicePrefix+"/operation/obj/deleteMulti", DeleteMultiObjJsonBody{
|
|
|
+ postResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).Post(baseUrl+"/operation/obj/deleteMulti", DeleteMultiObjJsonBody{
|
|
|
ConfigKey: ConfigKey{
|
|
|
Namespace: namespace,
|
|
|
Name: name,
|
|
@@ -269,7 +271,7 @@ func listDir(dirPath string) ([]string, error) {
|
|
|
return nil, nil
|
|
|
}
|
|
|
|
|
|
- getResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).Get(servicePrefix+"/operation/objPath/list", http_client.WithRequestQueryParams(map[string]string{
|
|
|
+ getResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).Get(baseUrl+"/operation/objPath/list", http_client.WithRequestQueryParams(map[string]string{
|
|
|
"namespace": namespace,
|
|
|
"name": name,
|
|
|
"dirPath": dirPath,
|
|
@@ -311,7 +313,7 @@ func lsDetails(dirPath string) ([]ObjectInfo, error) {
|
|
|
}
|
|
|
|
|
|
getResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).
|
|
|
- Get(servicePrefix+"/operation/objPath/listDetail", http_client.WithRequestQueryParams(map[string]string{
|
|
|
+ Get(baseUrl+"/operation/objPath/listDetail", http_client.WithRequestQueryParams(map[string]string{
|
|
|
"namespace": namespace,
|
|
|
"name": name,
|
|
|
"dirPath": dirPath,
|
|
@@ -358,7 +360,7 @@ func move(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
return nil
|
|
|
}
|
|
|
putResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).
|
|
|
- Put(servicePrefix+"/operation/obj/move", MoveJsonBody{
|
|
|
+ Put(baseUrl+"/operation/obj/move", MoveJsonBody{
|
|
|
ConfigKey: ConfigKey{
|
|
|
Namespace: namespace,
|
|
|
Name: name,
|
|
@@ -404,7 +406,7 @@ func copying(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
}
|
|
|
|
|
|
postResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).
|
|
|
- Post(servicePrefix+"/operation/obj/copy", CopyJsonBody{
|
|
|
+ Post(baseUrl+"/operation/obj/copy", CopyJsonBody{
|
|
|
ConfigKey: ConfigKey{
|
|
|
Namespace: namespace,
|
|
|
Name: name,
|
|
@@ -448,7 +450,7 @@ func copyPublic(srcObjName, dstObjName string, requireInfos []string) error {
|
|
|
}
|
|
|
|
|
|
postRequest := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration))
|
|
|
- postResponse, err := postRequest.Post(servicePrefix+"/operation/obj/copyPublic", CopyJsonBody{
|
|
|
+ postResponse, err := postRequest.Post(baseUrl+"/operation/obj/copyPublic", CopyJsonBody{
|
|
|
ConfigKey: ConfigKey{
|
|
|
Namespace: namespace,
|
|
|
Name: name,
|
|
@@ -489,8 +491,13 @@ func createImage(reader io.Reader, objName string) (string, error) {
|
|
|
}
|
|
|
|
|
|
postResponse, err := httpClient.NewRequest(http_client.WithNewRequestTimeout(timeoutDuration)).
|
|
|
- Post(servicePrefix+"/operation/obj/create/image", nil,
|
|
|
- http_client.WithRequestFileReader("file", objName, reader))
|
|
|
+ Post(baseUrl+"/operation/obj/create/image", nil,
|
|
|
+ http_client.WithRequestFileReader("file", objName, reader),
|
|
|
+ http_client.WithRequestFormData(map[string]string{
|
|
|
+ "namespace": namespace,
|
|
|
+ "name": name,
|
|
|
+ "objName": objName,
|
|
|
+ }))
|
|
|
if err != nil {
|
|
|
return "", err
|
|
|
}
|
|
@@ -550,7 +557,7 @@ func createImage(reader io.Reader, objName string) (string, error) {
|
|
|
// }
|
|
|
// buf := new(bytes.Buffer)
|
|
|
//
|
|
|
-// responseBytes, err := httpClient.GetWithoutHeaders(servicePrefix+"/operation/obj/getContent", map[string]string{
|
|
|
+// responseBytes, err := httpClient.GetWithoutHeaders(baseUrl+"/operation/obj/getContent", map[string]string{
|
|
|
// "namespace": namespace,
|
|
|
// "name": name,
|
|
|
// "objName": objName,
|