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

Method GetSubscription

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

Source from the content-addressed store, hash-verified

113}
114
115func (c *eventClient) GetSubscription(ctx context.Context, id string) (*Subscription, error) {
116 if !SupportedHost(c.host) {
117 return nil, ErrUnsupportedHost
118 }
119
120 path, err := safeurl.JoinPath("event-subscriptions", id)
121 if err != nil {
122 return nil, err
123 }
124
125 var sub Subscription
126 if err := c.api.REST(c.host, http.MethodGet, path.String(), nil, &sub); err != nil {
127 if httpErr, ok := errors.AsType[api.HTTPError](err); ok {
128 switch {
129 case httpErr.StatusCode == http.StatusNotFound:
130 return nil, fmt.Errorf("%w: %w", ErrSubscriptionNotFound, err)
131 case httpErr.StatusCode == http.StatusForbidden:
132 return nil, forbiddenError(httpErr, err)
133 }
134 }
135 return nil, err
136 }
137 return &sub, nil
138}
139
140// maxPerPage is the largest page size the list endpoint accepts.
141const 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