Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #330 from packethost/bgp-discover
Browse files Browse the repository at this point in the history
add support for BGP Discover
  • Loading branch information
cprivitere authored May 2, 2022
2 parents 4636b71 + 17a8c98 commit c1c08c7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions bgp_sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

var bgpSessionBasePath = "/bgp/sessions"
var bgpNeighborsBasePath = "/bgp/neighbors"
var bgpDiscoverBasePath = "/bgp/discover"

// BGPSessionService interface defines available BGP session methods
type BGPSessionService interface {
Expand Down
22 changes: 22 additions & 0 deletions projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type ProjectService interface {
Update(string, *ProjectUpdateRequest) (*Project, *Response, error)
Delete(string) (*Response, error)
ListBGPSessions(projectID string, listOpt *ListOptions) ([]BGPSession, *Response, error)
DiscoverBGPSessions(projectID string, getOpt *GetOptions) (*BGPDiscoverResponse, *Response, error)
ListEvents(string, *ListOptions) ([]Event, *Response, error)
ListSSHKeys(projectID string, searchOpt *SearchOptions) ([]SSHKey, *Response, error)
}
Expand All @@ -38,6 +39,11 @@ type Project struct {
BackendTransfer bool `json:"backend_transfer_enabled"`
}

// BGPDiscoverResponse struct is returned from the bgp/discover endpoint
type BGPDiscoverResponse struct {
UpdatedAt Timestamp `json:"updated_at"`
}

func (p Project) String() string {
return Stringify(p)
}
Expand Down Expand Up @@ -198,3 +204,19 @@ func (s *ProjectServiceOp) ListEvents(projectID string, listOpt *ListOptions) ([

return listEvents(s.client, apiPath, listOpt)
}

// Discover refreshes BGP session status
func (p *ProjectServiceOp) DiscoverBGPSessions(projectID string, opts *GetOptions) (*BGPDiscoverResponse, *Response, error) {
if validateErr := ValidateUUID(projectID); validateErr != nil {
return nil, nil, validateErr
}
endpointPath := path.Join(bgpDiscoverBasePath, projectID)
apiPathQuery := opts.WithQuery(endpointPath)
discovery := new(BGPDiscoverResponse)
response, err := p.client.DoRequest("POST", apiPathQuery, nil, discovery)
if err != nil {
return nil, response, err
}

return discovery, response, err
}

0 comments on commit c1c08c7

Please sign in to comment.