diff --git a/bgp_sessions.go b/bgp_sessions.go index 2b3ce72..b468f7c 100644 --- a/bgp_sessions.go +++ b/bgp_sessions.go @@ -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 { diff --git a/projects.go b/projects.go index f20478e..720c3b2 100644 --- a/projects.go +++ b/projects.go @@ -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) } @@ -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) } @@ -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 +}