-
Notifications
You must be signed in to change notification settings - Fork 29
/
fvRsConsIf_service.go
48 lines (39 loc) · 2.38 KB
/
fvRsConsIf_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package client
import (
"fmt"
"github.com/ciscoecosystem/aci-go-client/models"
)
func (sm *ServiceManager) CreateContractInterfaceRelationship(tnVzCPIfName string, application_epg string, application_profile string, tenant string, fvRsConsIfAttr models.ContractInterfaceRelationshipAttributes) (*models.ContractInterfaceRelationship, error) {
rn := fmt.Sprintf(models.RnfvRsConsIf, tnVzCPIfName)
parentDn := fmt.Sprintf(models.ParentDnfvRsConsIf, tenant, application_profile, application_epg)
fvRsConsIf := models.NewContractInterfaceRelationship(rn, parentDn, fvRsConsIfAttr)
err := sm.Save(fvRsConsIf)
return fvRsConsIf, err
}
func (sm *ServiceManager) ReadContractInterfaceRelationship(tnVzCPIfName string, application_epg string, application_profile string, tenant string) (*models.ContractInterfaceRelationship, error) {
dn := fmt.Sprintf(models.DnfvRsConsIf, tenant, application_profile, application_epg, tnVzCPIfName)
cont, err := sm.Get(dn)
if err != nil {
return nil, err
}
fvRsConsIf := models.ContractInterfaceRelationshipFromContainer(cont)
return fvRsConsIf, nil
}
func (sm *ServiceManager) DeleteContractInterfaceRelationship(tnVzCPIfName string, application_epg string, application_profile string, tenant string) error {
dn := fmt.Sprintf(models.DnfvRsConsIf, tenant, application_profile, application_epg, tnVzCPIfName)
return sm.DeleteByDn(dn, models.FvrsconsifClassName)
}
func (sm *ServiceManager) UpdateContractInterfaceRelationship(tnVzCPIfName string, application_epg string, application_profile string, tenant string, fvRsConsIfAttr models.ContractInterfaceRelationshipAttributes) (*models.ContractInterfaceRelationship, error) {
rn := fmt.Sprintf(models.RnfvRsConsIf, tnVzCPIfName)
parentDn := fmt.Sprintf(models.ParentDnfvRsConsIf, tenant, application_profile, application_epg)
fvRsConsIf := models.NewContractInterfaceRelationship(rn, parentDn, fvRsConsIfAttr)
fvRsConsIf.Status = "modified"
err := sm.Save(fvRsConsIf)
return fvRsConsIf, err
}
func (sm *ServiceManager) ListContractInterfaceRelationship(application_epg string, application_profile string, tenant string) ([]*models.ContractInterfaceRelationship, error) {
dnUrl := fmt.Sprintf("%s/uni/tn-%s/ap-%s/epg-%s/fvRsConsIf.json", models.BaseurlStr, tenant, application_profile, application_epg)
cont, err := sm.GetViaURL(dnUrl)
list := models.ContractInterfaceRelationshipListFromContainer(cont)
return list, err
}