Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get transport Zone API #36

Merged
merged 2 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pkg/client/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,33 @@ func (r *RouterAPIService) DeleteRouterBgpNeighbor(

return resp, err
}

func (r *RouterAPIService) GetTransportZones(
ctx context.Context,
serviceID int,
transportName string,
) (models.NetworkScope, error) {
resp := models.TransportZonesResp{}
routerAPI := &api{
compatibleVersion: routerCompatibleVersion,
method: "GET",
path: fmt.Sprintf("%s/%s/%d/%s",
consts.NetworksPath, consts.ServerPath, serviceID, consts.NetworkScopePath),
client: r.Client,
jsonParser: func(body []byte) error {
return json.Unmarshal(body, &resp)
},
}

if err := routerAPI.do(ctx, nil, nil); err != nil {
return models.NetworkScope{}, err
}

for _, t := range resp.NetworkScopes {
if t.Name == transportName {
return t, nil
}
}

return models.NetworkScope{}, nil
}
1 change: 1 addition & 0 deletions pkg/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
NetworkRouterPath = "routers"
NetworkRouterTypePath = "network-router-types"
NetworkServicePath = "services"
NetworkScopePath = "scopes"
ServerPath = "servers"
VirtualImagePath = "virtual-images"
FolderPath = "folders"
Expand Down
31 changes: 31 additions & 0 deletions pkg/models/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,34 @@ type NetworkRouterBgpNeighborBody struct {
DateCreated string `json:"dateCreated"`
LastUpdated string `json:"lastUpdated"`
}

type TransportZonesResp struct {
NetworkScopes []NetworkScope `json:"networkScopes"`
Meta Meta `json:"meta"`
}

type NetworkScope struct {
ID int `json:"id"`
InternalID string `json:"internalId"`
Visibility string `json:"visibility"`
DateCreated string `json:"dateCreated"`
ProviderID string `json:"providerId"`
tshihad marked this conversation as resolved.
Show resolved Hide resolved
LastUpdated string `json:"lastUpdated"`
Active bool `json:"active"`
StreamType string `json:"streamType"`
DisplayName string `json:"displayName"`
StatusMessage string `json:"statusMessage,omitempty"`
Name string `json:"name"`
Status string `json:"status"`
Enabled bool `json:"enabled"`
ExternalID string `json:"externalId"`
Config NetworkScopeConfig `json:"config"`
Owner IDModel `json:"owner"`
NetworkServer IDModel `json:"networkServer"`
Zone IDModel `json:"zone"`
}

type NetworkScopeConfig struct {
NvdsName string `json:"nvdsName"`
HostMembershipCriteria string `json:"hostMembershipCriteria"`
}