From 636e26938638bcb02a10d72c4283299b66032246 Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Wed, 23 Aug 2023 14:53:55 +0530 Subject: [PATCH] [minor_change] Added PostObjectConfig function to the client.go file and added DeviceLIfName to the vns_abs_func_conn.go model --- client/client.go | 32 ++++++++++++++++++++++++++++++++ models/vns_abs_func_conn.go | 29 +++++++++++------------------ 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/client/client.go b/client/client.go index e59eb563..24138c7b 100644 --- a/client/client.go +++ b/client/client.go @@ -4,6 +4,7 @@ import ( "bytes" "crypto/tls" "encoding/base64" + "encoding/json" "errors" "fmt" "io/ioutil" @@ -742,3 +743,34 @@ func (c *Client) checkHtmlResp(body string) error { log.Printf("[DEBUG] HTML Error Parsing Result: %s", errStr) return fmt.Errorf(errStr) } + +// PostObjectConfig is a function that posts an object configuration to the ACI controller. +// +// It takes the following parameters: +// - objectDn: a string representing the object DN. +// - objectMap: a map[string]interface{} representing the object map. +// +// It returns an error if there is any issue during the post operation. +func (client *Client) PostObjectConfig(objectDn string, objectMap map[string]interface{}) error { + objectMapByteStr, err := json.Marshal(objectMap) + if err != nil { + return err + } + + objectContainer, err := container.ParseJSON(objectMapByteStr) + if err != nil { + return err + } + + httpRequestPayload, err := client.MakeRestRequest("POST", fmt.Sprintf("%s/%s.json", client.MOURL, objectDn), objectContainer, true) + if err != nil { + return err + } + + respCont, _, err := client.Do(httpRequestPayload) + if err != nil { + return err + } + + return CheckForErrors(respCont, "POST", false) +} diff --git a/models/vns_abs_func_conn.go b/models/vns_abs_func_conn.go index b1a58226..ab1c1557 100644 --- a/models/vns_abs_func_conn.go +++ b/models/vns_abs_func_conn.go @@ -15,13 +15,11 @@ type FunctionConnector struct { } type FunctionConnectorAttributes struct { - Name string `json:",omitempty"` - - Annotation string `json:",omitempty"` - - AttNotify string `json:",omitempty"` - - NameAlias string `json:",omitempty"` + Name string `json:",omitempty"` + Annotation string `json:",omitempty"` + AttNotify string `json:",omitempty"` + NameAlias string `json:",omitempty"` + DeviceLIfName string `json:",omitempty"` } func NewFunctionConnector(vnsAbsFuncConnRn, parentDn, description string, vnsAbsFuncConnattr FunctionConnectorAttributes) *FunctionConnector { @@ -46,12 +44,10 @@ func (vnsAbsFuncConn *FunctionConnector) ToMap() (map[string]string, error) { } A(vnsAbsFuncConnMap, "name", vnsAbsFuncConn.Name) - A(vnsAbsFuncConnMap, "annotation", vnsAbsFuncConn.Annotation) - A(vnsAbsFuncConnMap, "attNotify", vnsAbsFuncConn.AttNotify) - A(vnsAbsFuncConnMap, "nameAlias", vnsAbsFuncConn.NameAlias) + A(vnsAbsFuncConnMap, "deviceLIfName", vnsAbsFuncConn.DeviceLIfName) return vnsAbsFuncConnMap, err } @@ -69,14 +65,11 @@ func FunctionConnectorFromContainerList(cont *container.Container, index int) *F }, FunctionConnectorAttributes{ - - Name: G(FunctionConnectorCont, "name"), - - Annotation: G(FunctionConnectorCont, "annotation"), - - AttNotify: G(FunctionConnectorCont, "attNotify"), - - NameAlias: G(FunctionConnectorCont, "nameAlias"), + Name: G(FunctionConnectorCont, "name"), + Annotation: G(FunctionConnectorCont, "annotation"), + AttNotify: G(FunctionConnectorCont, "attNotify"), + NameAlias: G(FunctionConnectorCont, "nameAlias"), + DeviceLIfName: G(FunctionConnectorCont, "deviceLIfName"), }, } }