From 78460e9b869bfc42ff3ba62c52343433da629c93 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 17 Dec 2015 22:51:53 -0500 Subject: [PATCH] admin creare repo --- admin_orgs.go | 2 +- admin_repos.go | 22 ++++++++++++++++++++++ admin_users.go | 8 ++++---- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 admin_repos.go diff --git a/admin_orgs.go b/admin_orgs.go index 9774152..ee29464 100644 --- a/admin_orgs.go +++ b/admin_orgs.go @@ -19,7 +19,7 @@ type CreateOrgOption struct { Location string `json:"location"` } -func (c *Client) CreateOrg(user string, opt CreateOrgOption) (*Organization, error) { +func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err diff --git a/admin_repos.go b/admin_repos.go new file mode 100644 index 0000000..8a213cb --- /dev/null +++ b/admin_repos.go @@ -0,0 +1,22 @@ +// Copyright 2015 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package gogs + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" +) + +func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, error) { + body, err := json.Marshal(&opt) + if err != nil { + return nil, err + } + repo := new(Repository) + return repo, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/repos", user), + http.Header{"content-type": []string{"application/json"}}, bytes.NewReader(body), repo) +} diff --git a/admin_users.go b/admin_users.go index 0ececaf..f8e26d9 100644 --- a/admin_users.go +++ b/admin_users.go @@ -20,7 +20,7 @@ type CreateUserOption struct { SendNotify bool `json:"send_notify"` } -func (c *Client) CreateUser(opt CreateUserOption) (*User, error) { +func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err @@ -44,7 +44,7 @@ type EditUserOption struct { AllowImportLocal *bool `json:"allow_import_local"` } -func (c *Client) EditUser(user string, opt EditUserOption) error { +func (c *Client) AdminEditUser(user string, opt EditUserOption) error { body, err := json.Marshal(&opt) if err != nil { return err @@ -54,12 +54,12 @@ func (c *Client) EditUser(user string, opt EditUserOption) error { return err } -func (c *Client) DeleteUser(user string) error { +func (c *Client) AdminDeleteUser(user string) error { _, err := c.getResponse("DELETE", fmt.Sprintf("/admin/users/%s", user), nil, nil) return err } -func (c *Client) CreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) { +func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) { body, err := json.Marshal(&opt) if err != nil { return nil, err