Skip to content
This repository was archived by the owner on Jun 8, 2019. It is now read-only.

Commit 7e711e0

Browse files
ngourdontechknowlogick
authored andcommitted
add missing methods in the org API (#175)
1 parent 5619ee5 commit 7e711e0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

gitea/org.go

+17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2015 The Gogs Authors. All rights reserved.
2+
// Copyright 2019 The Gitea Authors. All rights reserved.
23
// Use of this source code is governed by a MIT-style
34
// license that can be found in the LICENSE file.
45

@@ -33,6 +34,16 @@ func (c *Client) GetOrg(orgname string) (*Organization, error) {
3334
return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org)
3435
}
3536

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+
3647
// EditOrg modify one organization via options
3748
func (c *Client) EditOrg(orgname string, opt structs.EditOrgOption) error {
3849
body, err := json.Marshal(&opt)
@@ -42,3 +53,9 @@ func (c *Client) EditOrg(orgname string, opt structs.EditOrgOption) error {
4253
_, err = c.getResponse("PATCH", fmt.Sprintf("/orgs/%s", orgname), jsonHeader, bytes.NewReader(body))
4354
return err
4455
}
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

Comments
 (0)