MCPcopy Create free account
hub / github.com/cli/cli / GetSubscription

Method GetSubscription

pkg/cmd/event/client/client.go:126–149  ·  view source on GitHub ↗
(ctx context.Context, id string)

Source from the content-addressed store, hash-verified

124}
125
126func (c *eventClient) GetSubscription(ctx context.Context, id string) (*Subscription, error) {
127 if !SupportedHost(c.host) {
128 return nil, ErrUnsupportedHost
129 }
130
131 path, err := safeurl.JoinPath("event-subscriptions", id)
132 if err != nil {
133 return nil, err
134 }
135
136 var sub Subscription
137 if err := c.api.REST(c.host, http.MethodGet, path.String(), nil, &sub); err != nil {
138 if httpErr, ok := errors.AsType[api.HTTPError](err); ok {
139 switch {
140 case httpErr.StatusCode == http.StatusNotFound:
141 return nil, fmt.Errorf("%w: %w", ErrSubscriptionNotFound, err)
142 case httpErr.StatusCode == http.StatusForbidden:
143 return nil, forbiddenError(httpErr, err)
144 }
145 }
146 return nil, err
147 }
148 return &sub, nil
149}
150
151// maxPerPage is the largest page size the list endpoint accepts.
152const maxPerPage = 100

Callers

nothing calls this directly

Calls 6

JoinPathFunction · 0.92
SupportedHostFunction · 0.85
forbiddenErrorFunction · 0.85
RESTMethod · 0.65
StringMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected