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

Method Create

pkg/cmd/issue/artifact/client/client.go:154–178  ·  view source on GitHub ↗
(repo ghrepo.Interface, issueNumber int, artifactType, name, body string)

Source from the content-addressed store, hash-verified

152}
153
154func (c *artifactClient) Create(repo ghrepo.Interface, issueNumber int, artifactType, name, body string) (*Artifact, error) {
155 u, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "issues", strconv.Itoa(issueNumber), "artifacts")
156 if err != nil {
157 return nil, err
158 }
159
160 payload, err := json.Marshal(struct {
161 Type string `json:"type"`
162 Name string `json:"name"`
163 Body string `json:"body"`
164 }{
165 Type: artifactType,
166 Name: name,
167 Body: body,
168 })
169 if err != nil {
170 return nil, err
171 }
172
173 var artifact Artifact
174 if err := c.apiClient.REST(repo.RepoHost(), "POST", u.String(), bytes.NewReader(payload), &artifact); err != nil {
175 return nil, err
176 }
177 return &artifact, nil
178}
179
180// Update sends only the fields it changes, since the API keeps any field a
181// request leaves out.

Callers

nothing calls this directly

Calls 6

JoinPathFunction · 0.92
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected