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.
21 model "ealt/cmd/model"
28 func BuilderRequest(valueArgs []string, command string) error {
33 case "NewAppCreateCommand":
35 //ealtedge/mepm/app_pkgm/v1/app_packages/
36 //read the file from the system.
37 URIString = common.AppmUriCreate
38 var packageName string
40 body = jsonEmptyBodyFormat()
41 packageName = strings.TrimSpace(valueArgs[0])
42 HttpMultiPartPostRequestBuilder(URIString, body, 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 HttpDeleteRequestBuilder(URIString, body)
52 case "NewApplcmCreateCommand":
53 //appLCM application Creation URI
54 //ealtedge/mepm/app_lcm/v1/app_instances
57 URIString = common.ApplcmUriCreate
58 //Assigning the AppLcm Create Command Line Flags to the Json Paylod.
59 payload := model.CreateApplicationReq{AppDID: strings.TrimSpace(valueArgs[0]),
60 AppInstancename: strings.TrimSpace(valueArgs[1]),
61 AppInstanceDescriptor: strings.TrimSpace(valueArgs[2])}
62 body, err := json.Marshal(payload)
67 HttpPostRequestBuilder(URIString, body)
69 case "NewApplcmDeleteCommand":
70 //appLCM Delete Application URI
71 ///ealtedge/mepm/app_lcm/v1/app_instances/{appInstanceId}
73 URIString = common.ApplcmUri + strings.TrimSpace(valueArgs[0])
75 //Empty body for Delete Command.
76 body = jsonEmptyBodyFormat()
77 HttpDeleteRequestBuilder(URIString, body)
79 case "NewApplcmStartCommand":
80 //applcm application instantiate uri
81 //ealtedge/mepm/app_lcm/v1/app_instances/{appInstanceId}/instantiate
84 URIString = common.ApplcmUri + strings.TrimSpace(valueArgs[0]) + common.InstantiateUri
86 selectedMECHostInfo := model.SelectedMECHostInfo{HostName: strings.TrimSpace(valueArgs[1]),
87 HostId: strings.TrimSpace(valueArgs[2])}
89 payload := model.InstantiateApplicationReq{SelectedMECHostInfo: selectedMECHostInfo}
90 body, err := json.Marshal(payload)
94 HttpPostRequestBuilder(URIString, body)
96 case "NewApplcmTerminateCommand":
97 //applcm application terminate uri
98 //ealtedge/mepm/app_lcm/v1/app_instances/{appInstanceId}/terminate
100 URIString = common.ApplcmUri + strings.TrimSpace(valueArgs[0]) + common.TerminateUri
101 body = jsonEmptyBodyFormat()
102 HttpPostRequestBuilder(URIString, body)
107 func jsonEmptyBodyFormat() []byte {
109 jsonstr = []byte(`{"":""}`)