(ctx context.Context, codespaceName string, orgName string, userName string)
| 617 | } |
| 618 | |
| 619 | func (a *API) StopCodespace(ctx context.Context, codespaceName string, orgName string, userName string) error { |
| 620 | var stopURL *safeurl.MutableSafeURL |
| 621 | var spanName string |
| 622 | var err error |
| 623 | |
| 624 | if orgName != "" { |
| 625 | stopURL, err = safeurl.JoinPathWithHostPrefix(a.githubAPI, "orgs", orgName, "members", userName, "codespaces", codespaceName, "stop") |
| 626 | spanName = "/orgs/*/members/*/codespaces/*/stop" |
| 627 | } else { |
| 628 | stopURL, err = safeurl.JoinPathWithHostPrefix(a.githubAPI, "user", "codespaces", codespaceName, "stop") |
| 629 | spanName = "/user/codespaces/*/stop" |
| 630 | } |
| 631 | if err != nil { |
| 632 | return err |
| 633 | } |
| 634 | |
| 635 | req, err := http.NewRequest(http.MethodPost, stopURL.String(), nil) |
| 636 | if err != nil { |
| 637 | return fmt.Errorf("error creating request: %w", err) |
| 638 | } |
| 639 | |
| 640 | a.setHeaders(req) |
| 641 | resp, err := a.do(ctx, req, spanName) |
| 642 | if err != nil { |
| 643 | return fmt.Errorf("error making request: %w", err) |
| 644 | } |
| 645 | defer resp.Body.Close() |
| 646 | |
| 647 | if resp.StatusCode != http.StatusOK { |
| 648 | return api.HandleHTTPError(resp) |
| 649 | } |
| 650 | |
| 651 | return nil |
| 652 | } |
| 653 | |
| 654 | type Machine struct { |
| 655 | Name string `json:"name"` |
nothing calls this directly
no test coverage detected