(ctx context.Context, codespaceName string, orgName string, userName string)
| 567 | } |
| 568 | |
| 569 | func (a *API) StopCodespace(ctx context.Context, codespaceName string, orgName string, userName string) error { |
| 570 | var stopURL string |
| 571 | var spanName string |
| 572 | |
| 573 | if orgName != "" { |
| 574 | stopURL = fmt.Sprintf("%s/orgs/%s/members/%s/codespaces/%s/stop", a.githubAPI, orgName, userName, codespaceName) |
| 575 | spanName = "/orgs/*/members/*/codespaces/*/stop" |
| 576 | } else { |
| 577 | stopURL = fmt.Sprintf("%s/user/codespaces/%s/stop", a.githubAPI, codespaceName) |
| 578 | spanName = "/user/codespaces/*/stop" |
| 579 | } |
| 580 | |
| 581 | req, err := http.NewRequest(http.MethodPost, stopURL, nil) |
| 582 | if err != nil { |
| 583 | return fmt.Errorf("error creating request: %w", err) |
| 584 | } |
| 585 | |
| 586 | a.setHeaders(req) |
| 587 | resp, err := a.do(ctx, req, spanName) |
| 588 | if err != nil { |
| 589 | return fmt.Errorf("error making request: %w", err) |
| 590 | } |
| 591 | defer resp.Body.Close() |
| 592 | |
| 593 | if resp.StatusCode != http.StatusOK { |
| 594 | return api.HandleHTTPError(resp) |
| 595 | } |
| 596 | |
| 597 | return nil |
| 598 | } |
| 599 | |
| 600 | type Machine struct { |
| 601 | Name string `json:"name"` |
nothing calls this directly
no test coverage detected