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

Commit 78460e9

Browse files
committed
admin creare repo
1 parent ce7aab6 commit 78460e9

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

admin_orgs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type CreateOrgOption struct {
1919
Location string `json:"location"`
2020
}
2121

22-
func (c *Client) CreateOrg(user string, opt CreateOrgOption) (*Organization, error) {
22+
func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error) {
2323
body, err := json.Marshal(&opt)
2424
if err != nil {
2525
return nil, err

admin_repos.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
5+
package gogs
6+
7+
import (
8+
"bytes"
9+
"encoding/json"
10+
"fmt"
11+
"net/http"
12+
)
13+
14+
func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, error) {
15+
body, err := json.Marshal(&opt)
16+
if err != nil {
17+
return nil, err
18+
}
19+
repo := new(Repository)
20+
return repo, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/repos", user),
21+
http.Header{"content-type": []string{"application/json"}}, bytes.NewReader(body), repo)
22+
}

admin_users.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type CreateUserOption struct {
2020
SendNotify bool `json:"send_notify"`
2121
}
2222

23-
func (c *Client) CreateUser(opt CreateUserOption) (*User, error) {
23+
func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) {
2424
body, err := json.Marshal(&opt)
2525
if err != nil {
2626
return nil, err
@@ -44,7 +44,7 @@ type EditUserOption struct {
4444
AllowImportLocal *bool `json:"allow_import_local"`
4545
}
4646

47-
func (c *Client) EditUser(user string, opt EditUserOption) error {
47+
func (c *Client) AdminEditUser(user string, opt EditUserOption) error {
4848
body, err := json.Marshal(&opt)
4949
if err != nil {
5050
return err
@@ -54,12 +54,12 @@ func (c *Client) EditUser(user string, opt EditUserOption) error {
5454
return err
5555
}
5656

57-
func (c *Client) DeleteUser(user string) error {
57+
func (c *Client) AdminDeleteUser(user string) error {
5858
_, err := c.getResponse("DELETE", fmt.Sprintf("/admin/users/%s", user), nil, nil)
5959
return err
6060
}
6161

62-
func (c *Client) CreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) {
62+
func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) {
6363
body, err := json.Marshal(&opt)
6464
if err != nil {
6565
return nil, err

0 commit comments

Comments
 (0)