Skip to content

Commit 6e20b50

Browse files
shashvat-kediajonasfranz
authored andcommitted
Delete organization endpoint added (#5601)
* Delete organization endpoint added * Parameters added in comment * Typo fix * Newline character removed
1 parent 21357a4 commit 6e20b50

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

routers/api/v1/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ func RegisterRoutes(m *macaron.Macaron) {
622622
m.Group("/orgs/:orgname", func() {
623623
m.Get("/repos", user.ListOrgRepos)
624624
m.Combo("").Get(org.Get).
625-
Patch(reqToken(), reqOrgOwnership(), bind(api.EditOrgOption{}), org.Edit)
625+
Patch(reqToken(), reqOrgOwnership(), bind(api.EditOrgOption{}), org.Edit).
626+
Delete(reqToken(), reqOrgOwnership(), org.Delete)
626627
m.Group("/members", func() {
627628
m.Get("", org.ListMembers)
628629
m.Combo("/:username").Get(org.IsMember).

routers/api/v1/org/org.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,26 @@ func Edit(ctx *context.APIContext, form api.EditOrgOption) {
166166

167167
ctx.JSON(200, convert.ToOrganization(org))
168168
}
169+
170+
//Delete an organization
171+
func Delete(ctx *context.APIContext) {
172+
// swagger:operation DELETE /orgs/{org} organization orgDelete
173+
// ---
174+
// summary: Delete an organization
175+
// produces:
176+
// - application/json
177+
// parameters:
178+
// - name: org
179+
// in: path
180+
// description: organization that is to be deleted
181+
// type: string
182+
// required: true
183+
// responses:
184+
// "204":
185+
// "$ref": "#/responses/empty"
186+
if err := models.DeleteOrganization(ctx.Org.Organization); err != nil {
187+
ctx.Error(500, "DeleteOrganization", err)
188+
return
189+
}
190+
ctx.Status(204)
191+
}

templates/swagger/v1_json.tmpl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,30 @@
467467
}
468468
}
469469
},
470+
"delete": {
471+
"produces": [
472+
"application/json"
473+
],
474+
"tags": [
475+
"organization"
476+
],
477+
"summary": "Delete an organization",
478+
"operationId": "orgDelete",
479+
"parameters": [
480+
{
481+
"type": "string",
482+
"description": "organization that is to be deleted",
483+
"name": "org",
484+
"in": "path",
485+
"required": true
486+
}
487+
],
488+
"responses": {
489+
"204": {
490+
"$ref": "#/responses/empty"
491+
}
492+
}
493+
},
470494
"patch": {
471495
"consumes": [
472496
"application/json"

0 commit comments

Comments
 (0)