1
1
// Copyright 2015 The Gogs Authors. All rights reserved.
2
+ // Copyright 2019 The Gitea Authors. All rights reserved.
2
3
// Use of this source code is governed by a MIT-style
3
4
// license that can be found in the LICENSE file.
4
5
@@ -33,6 +34,16 @@ func (c *Client) GetOrg(orgname string) (*Organization, error) {
33
34
return org , c .getParsedResponse ("GET" , fmt .Sprintf ("/orgs/%s" , orgname ), nil , nil , org )
34
35
}
35
36
37
+ // CreateOrg creates an organization
38
+ func (c * Client ) CreateOrg (opt structs.CreateOrgOption ) (* Organization , error ) {
39
+ body , err := json .Marshal (& opt )
40
+ if err != nil {
41
+ return nil , err
42
+ }
43
+ org := new (Organization )
44
+ return org , c .getParsedResponse ("POST" , "/orgs" , jsonHeader , bytes .NewReader (body ), org )
45
+ }
46
+
36
47
// EditOrg modify one organization via options
37
48
func (c * Client ) EditOrg (orgname string , opt structs.EditOrgOption ) error {
38
49
body , err := json .Marshal (& opt )
@@ -42,3 +53,9 @@ func (c *Client) EditOrg(orgname string, opt structs.EditOrgOption) error {
42
53
_ , err = c .getResponse ("PATCH" , fmt .Sprintf ("/orgs/%s" , orgname ), jsonHeader , bytes .NewReader (body ))
43
54
return err
44
55
}
56
+
57
+ // DeleteOrg deletes an organization
58
+ func (c * Client ) DeleteOrg (orgname string ) error {
59
+ _ , err := c .getResponse ("DELETE" , fmt .Sprintf ("/orgs/%s" , orgname ), nil , nil )
60
+ return err
61
+ }
0 commit comments