admin_org.go 537 B

123456789101112131415161718192021
  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) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error) {
  11. body, err := json.Marshal(&opt)
  12. if err != nil {
  13. return nil, err
  14. }
  15. org := new(Organization)
  16. return org, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/orgs", user),
  17. jsonHeader, bytes.NewReader(body), org)
  18. }