1package rabbithole 2 3import ( 4 "encoding/json" 5 "net/http" 6) 7 8// Federation definition: additional arguments 9// added to the entities (queues, exchanges or both) 10// that match a policy. 11type FederationDefinition struct { 12 Uri string `json:"uri"` 13 Expires int `json:"expires"` 14 MessageTTL int32 `json:"message-ttl"` 15 MaxHops int `json:"max-hops"` 16 PrefetchCount int `json:"prefetch-count"` 17 ReconnectDelay int `json:"reconnect-delay"` 18 AckMode string `json:"ack-mode,omitempty"` 19 TrustUserId bool `json:"trust-user-id"` 20 Exchange string `json:"exchange"` 21 Queue string `json:"queue"` 22} 23 24// Represents a configured Federation upstream. 25type FederationUpstream struct { 26 Definition FederationDefinition `json:"value"` 27} 28 29// 30// PUT /api/parameters/federation-upstream/{vhost}/{upstream} 31// 32 33// Updates a federation upstream 34func (c *Client) PutFederationUpstream(vhost string, upstreamName string, fDef FederationDefinition) (res *http.Response, err error) { 35 fedUp := FederationUpstream{ 36 Definition: fDef, 37 } 38 body, err := json.Marshal(fedUp) 39 if err != nil { 40 return nil, err 41 } 42 43 req, err := newRequestWithBody(c, "PUT", "parameters/federation-upstream/"+PathEscape(vhost)+"/"+PathEscape(upstreamName), body) 44 if err != nil { 45 return nil, err 46 } 47 48 res, err = executeRequest(c, req) 49 if err != nil { 50 return nil, err 51 } 52 53 return res, nil 54} 55 56// 57// DELETE /api/parameters/federation-upstream/{vhost}/{name} 58// 59 60// Deletes a federation upstream. 61func (c *Client) DeleteFederationUpstream(vhost, upstreamName string) (res *http.Response, err error) { 62 req, err := newRequestWithBody(c, "DELETE", "parameters/federation-upstream/"+PathEscape(vhost)+"/"+PathEscape(upstreamName), nil) 63 if err != nil { 64 return nil, err 65 } 66 67 res, err = executeRequest(c, req) 68 if err != nil { 69 return nil, err 70 } 71 72 return res, nil 73} 74