forked from mystiq/dex
schema: disable user API
This commit is contained in:
parent
1563d78861
commit
b33cfbf556
4 changed files with 180 additions and 7 deletions
|
@ -4,7 +4,7 @@
|
|||
//
|
||||
// Usage example:
|
||||
//
|
||||
// import "github.com/coreos/dex/Godeps/_workspace/src/google.golang.org/api/adminschema/v1"
|
||||
// import "google.golang.org/api/adminschema/v1"
|
||||
// ...
|
||||
// adminschemaService, err := adminschema.New(oauthHttpClient)
|
||||
package adminschema
|
||||
|
|
|
@ -134,6 +134,15 @@ type UserCreateResponse struct {
|
|||
type UserCreateResponseUser struct {
|
||||
}
|
||||
|
||||
type UserDisableRequest struct {
|
||||
// Disable: If true, disable this user, if false, enable them
|
||||
Disable bool `json:"disable,omitempty"`
|
||||
}
|
||||
|
||||
type UserDisableResponse struct {
|
||||
Ok bool `json:"ok,omitempty"`
|
||||
}
|
||||
|
||||
type UserResponse struct {
|
||||
User *User `json:"user,omitempty"`
|
||||
}
|
||||
|
@ -355,6 +364,89 @@ func (c *UsersCreateCall) Do() (*UserCreateResponse, error) {
|
|||
|
||||
}
|
||||
|
||||
// method id "dex.User.Disable":
|
||||
|
||||
type UsersDisableCall struct {
|
||||
s *Service
|
||||
id string
|
||||
userdisablerequest *UserDisableRequest
|
||||
opt_ map[string]interface{}
|
||||
}
|
||||
|
||||
// Disable: Enable or disable a user.
|
||||
func (r *UsersService) Disable(id string, userdisablerequest *UserDisableRequest) *UsersDisableCall {
|
||||
c := &UsersDisableCall{s: r.s, opt_: make(map[string]interface{})}
|
||||
c.id = id
|
||||
c.userdisablerequest = userdisablerequest
|
||||
return c
|
||||
}
|
||||
|
||||
// Fields allows partial responses to be retrieved.
|
||||
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
|
||||
// for more information.
|
||||
func (c *UsersDisableCall) Fields(s ...googleapi.Field) *UsersDisableCall {
|
||||
c.opt_["fields"] = googleapi.CombineFields(s)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *UsersDisableCall) Do() (*UserDisableResponse, error) {
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.userdisablerequest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctype := "application/json"
|
||||
params := make(url.Values)
|
||||
params.Set("alt", "json")
|
||||
if v, ok := c.opt_["fields"]; ok {
|
||||
params.Set("fields", fmt.Sprintf("%v", v))
|
||||
}
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "users/{id}/disable")
|
||||
urls += "?" + params.Encode()
|
||||
req, _ := http.NewRequest("POST", urls, body)
|
||||
googleapi.Expand(req.URL, map[string]string{
|
||||
"id": c.id,
|
||||
})
|
||||
req.Header.Set("Content-Type", ctype)
|
||||
req.Header.Set("User-Agent", "google-api-go-client/0.5")
|
||||
res, err := c.s.client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer googleapi.CloseBody(res)
|
||||
if err := googleapi.CheckResponse(res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var ret *UserDisableResponse
|
||||
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
// {
|
||||
// "description": "Enable or disable a user.",
|
||||
// "httpMethod": "POST",
|
||||
// "id": "dex.User.Disable",
|
||||
// "parameterOrder": [
|
||||
// "id"
|
||||
// ],
|
||||
// "parameters": {
|
||||
// "id": {
|
||||
// "location": "path",
|
||||
// "required": true,
|
||||
// "type": "string"
|
||||
// }
|
||||
// },
|
||||
// "path": "users/{id}/disable",
|
||||
// "request": {
|
||||
// "$ref": "UserDisableRequest"
|
||||
// },
|
||||
// "response": {
|
||||
// "$ref": "UserDisableResponse"
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// method id "dex.User.Get":
|
||||
|
||||
type UsersGetCall struct {
|
||||
|
@ -363,7 +455,7 @@ type UsersGetCall struct {
|
|||
opt_ map[string]interface{}
|
||||
}
|
||||
|
||||
// Get: Get a single use object.
|
||||
// Get: Get a single User object by id.
|
||||
func (r *UsersService) Get(id string) *UsersGetCall {
|
||||
c := &UsersGetCall{s: r.s, opt_: make(map[string]interface{})}
|
||||
c.id = id
|
||||
|
@ -406,7 +498,7 @@ func (c *UsersGetCall) Do() (*UserResponse, error) {
|
|||
}
|
||||
return ret, nil
|
||||
// {
|
||||
// "description": "Get a single use object.",
|
||||
// "description": "Get a single User object by id.",
|
||||
// "httpMethod": "GET",
|
||||
// "id": "dex.User.Get",
|
||||
// "parameterOrder": [
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package workerschema
|
||||
|
||||
//
|
||||
// This file is automatically generated by schema/generator
|
||||
//
|
||||
|
@ -167,6 +166,25 @@ const DiscoveryJSON = `{
|
|||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"UserDisableRequest": {
|
||||
"id": "UserDisableRequest",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"disable": {
|
||||
"type": "boolean",
|
||||
"description": "If true, disable this user, if false, enable them"
|
||||
}
|
||||
}
|
||||
},
|
||||
"UserDisableResponse": {
|
||||
"id": "UserDisableResponse",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"resources": {
|
||||
|
@ -224,7 +242,7 @@ const DiscoveryJSON = `{
|
|||
},
|
||||
"Get": {
|
||||
"id": "dex.User.Get",
|
||||
"description": "Get a single use object.",
|
||||
"description": "Get a single User object by id.",
|
||||
"httpMethod": "GET",
|
||||
"path": "users/{id}",
|
||||
"parameters": {
|
||||
|
@ -252,9 +270,31 @@ const DiscoveryJSON = `{
|
|||
"response": {
|
||||
"$ref": "UserCreateResponse"
|
||||
}
|
||||
},
|
||||
"Disable": {
|
||||
"id": "dex.User.Disable",
|
||||
"description": "Enable or disable a user.",
|
||||
"httpMethod": "POST",
|
||||
"path": "users/{id}/disable",
|
||||
"parameters": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"location": "path"
|
||||
}
|
||||
},
|
||||
"parameterOrder": [
|
||||
"id"
|
||||
],
|
||||
"request": {
|
||||
"$ref": "UserDisableRequest"
|
||||
},
|
||||
"response": {
|
||||
"$ref": "UserDisableResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
`
|
|
@ -160,6 +160,25 @@
|
|||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"UserDisableRequest": {
|
||||
"id": "UserDisableRequest",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"disable": {
|
||||
"type": "boolean",
|
||||
"description": "If true, disable this user, if false, enable them. No error is signaled if the user state doesn't change."
|
||||
}
|
||||
}
|
||||
},
|
||||
"UserDisableResponse": {
|
||||
"id": "UserDisableResponse",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"resources": {
|
||||
|
@ -217,7 +236,7 @@
|
|||
},
|
||||
"Get": {
|
||||
"id": "dex.User.Get",
|
||||
"description": "Get a single use object.",
|
||||
"description": "Get a single User object by id.",
|
||||
"httpMethod": "GET",
|
||||
"path": "users/{id}",
|
||||
"parameters": {
|
||||
|
@ -245,6 +264,28 @@
|
|||
"response": {
|
||||
"$ref": "UserCreateResponse"
|
||||
}
|
||||
},
|
||||
"Disable": {
|
||||
"id": "dex.User.Disable",
|
||||
"description": "Enable or disable a user.",
|
||||
"httpMethod": "POST",
|
||||
"path": "users/{id}/disable",
|
||||
"parameters": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"location": "path"
|
||||
}
|
||||
},
|
||||
"parameterOrder": [
|
||||
"id"
|
||||
],
|
||||
"request": {
|
||||
"$ref": "UserDisableRequest"
|
||||
},
|
||||
"response": {
|
||||
"$ref": "UserDisableResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue