Skip to content

Commit

Permalink
[minor_change] Added PostObjectConfig function to the client.go file …
Browse files Browse the repository at this point in the history
…and added DeviceLIfName to the vns_abs_func_conn.go model
  • Loading branch information
sajagana authored and lhercot committed Aug 29, 2023
1 parent ee338a0 commit 636e269
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
32 changes: 32 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto/tls"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -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)
}
29 changes: 11 additions & 18 deletions models/vns_abs_func_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand All @@ -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"),
},
}
}
Expand Down

0 comments on commit 636e269

Please sign in to comment.