admin_repo.go 539 B

12345678910111213141516171819202122
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package gogs
  5. import (
  6. "bytes"
  7. "encoding/json"
  8. "fmt"
  9. )
  10. func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, error) {
  11. body, err := json.Marshal(&opt)
  12. if err != nil {
  13. return nil, err
  14. }
  15. repo := new(Repository)
  16. return repo, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/repos", user),
  17. jsonHeader, bytes.NewReader(body), repo)
  18. }