2 Copyright 2020 Huawei Technologies Co., Ltd.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
27 func BuilderRequest(valueArgs []string, command string) error {
32 case "NewAppCreateCommand":
34 //ealtedge/mepm/app_pkgm/v1/app_packages/
35 //read the file from the system.
36 URIString = common.AppmUri
37 var packageName string
39 body = jsonEmptyBodyFormat()
40 packageName = strings.TrimSpace(valueArgs[0])
41 HttpMultiPartPostRequestBuilder(URIString, body, packageName)
42 fmt.Println(packageName)
44 case "NewAppDeleteCommand":
45 //The Delete Application Package URI
46 //ealtedge/mepm/app_pkgm/v1/app_packages/{{ID}}
48 URIString = common.AppmUri + strings.TrimSpace(valueArgs[0])
49 body = jsonEmptyBodyFormat()
50 fmt.Println(URIString)
51 HttpDeleteRequestBuilder(URIString, body)
53 fmt.Println(URIString)
55 case "NewApplcmCreateCommand":
56 //appLCM application Creation URI
57 //ealtedge/mepm/app_lcm/v1/app_instances
60 URIString = common.ApplcmUri
61 body, err := json.Marshal(map[string]string{
62 "appDId": strings.TrimSpace(valueArgs[0]),
63 "appInstancename": strings.TrimSpace(valueArgs[1]),
64 "appInstanceDescriptor": strings.TrimSpace(valueArgs[2]),
70 fmt.Println(URIString)
71 HttpPostRequestBuilder(URIString, body)
73 case "NewApplcmDeleteCommand":
74 //appLCM Delete Application URI
75 ///ealtedge/mepm/app_lcm/v1/app_instances/{appInstanceId}
77 URIString = common.ApplcmUri + strings.TrimSpace(valueArgs[0])
78 body = jsonEmptyBodyFormat()
79 fmt.Println(URIString)
80 HttpDeleteRequestBuilder(URIString, body)
82 case "NewApplcmStartCommand":
83 //applcm application instantiate uri
84 //ealtedge/mepm/app_lcm/v1/app_instances/{appInstanceId}/instantiate
87 URIString = common.ApplcmUri + strings.TrimSpace(valueArgs[0]) + common.InstantiateUri
88 body = jsonEmptyBodyFormat()
89 fmt.Println(URIString)
90 HttpPostRequestBuilder(URIString, body)
92 case "NewApplcmTerminateCommand":
93 //applcm application terminate uri
94 //ealtedge/mepm/app_lcm/v1/app_instances/{appInstanceId}/terminate
96 URIString = common.ApplcmUri + strings.TrimSpace(valueArgs[0]) + common.TerminateUri
97 body = jsonEmptyBodyFormat()
98 fmt.Println(URIString)
99 HttpPostRequestBuilder(URIString, body)
106 func jsonEmptyBodyFormat() []byte {
108 jsonstr = []byte(`{"":""}`)