workerschema: move Client.Revoke to RefreshClient

also, RevokeClient -> RevokeClient for consistency.
This commit is contained in:
Bobby Rullo 2016-04-26 12:05:41 -07:00
parent e1c070d84e
commit 2406c09598
5 changed files with 137 additions and 138 deletions

View file

@ -382,10 +382,9 @@ func TestCreateClient(t *testing.T) {
return u
}
addIDAndSecret := func(cliNum int, hostport string, cli adminschema.Client) *adminschema.Client {
cli.Id = fmt.Sprintf("client_%v.example.com", hostport)
cli.Secret = base64.URLEncoding.EncodeToString([]byte(
fmt.Sprintf("client_%d", cliNum)))
addIDAndSecret := func(cli adminschema.Client) *adminschema.Client {
cli.Id = "client_auth.example.com"
cli.Secret = base64.URLEncoding.EncodeToString([]byte("client_0"))
return &cli
}
@ -448,7 +447,7 @@ func TestCreateClient(t *testing.T) {
Client: &adminClientGood,
},
want: adminschema.ClientCreateResponse{
Client: addIDAndSecret(2, "auth", adminClientGood),
Client: addIDAndSecret(adminClientGood),
},
wantClient: clientGood,
},
@ -457,7 +456,7 @@ func TestCreateClient(t *testing.T) {
Client: &adminAdminClient,
},
want: adminschema.ClientCreateResponse{
Client: addIDAndSecret(2, "auth", adminAdminClient),
Client: addIDAndSecret(adminAdminClient),
},
wantClient: clientGoodAdmin,
},
@ -466,7 +465,7 @@ func TestCreateClient(t *testing.T) {
Client: &adminMultiRedirect,
},
want: adminschema.ClientCreateResponse{
Client: addIDAndSecret(2, "auth", adminMultiRedirect),
Client: addIDAndSecret(adminMultiRedirect),
},
wantClient: clientMultiRedirect,
},
@ -475,7 +474,7 @@ func TestCreateClient(t *testing.T) {
Client: &adminClientWithPeers,
},
want: adminschema.ClientCreateResponse{
Client: addIDAndSecret(2, "auth", adminClientWithPeers),
Client: addIDAndSecret(adminClientWithPeers),
},
wantClient: clientGood,
wantTrustedPeers: []string{"test_client_0"},

View file

@ -199,7 +199,7 @@ A client with associated public metadata.
> __Description__
> List all clients that hold refresh tokens for the authenticated user.
> List all clients that hold refresh tokens for the specified user.
> __Parameters__
@ -221,11 +221,11 @@ A client with associated public metadata.
> __Summary__
> Revoke Clients
> Revoke RefreshClient
> __Description__
> Revoke all refresh tokens issues to the client for the authenticated user.
> Revoke all refresh tokens issues to the client for the specified user.
> __Parameters__

View file

@ -334,82 +334,7 @@ func (c *ClientsListCall) Do() (*ClientPage, error) {
}
// method id "dex.Client.Revoke":
type ClientsRevokeCall struct {
s *Service
userid string
clientid string
opt_ map[string]interface{}
}
// Revoke: Revoke all refresh tokens issues to the client for the
// authenticated user.
func (r *ClientsService) Revoke(userid string, clientid string) *ClientsRevokeCall {
c := &ClientsRevokeCall{s: r.s, opt_: make(map[string]interface{})}
c.userid = userid
c.clientid = clientid
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 *ClientsRevokeCall) Fields(s ...googleapi.Field) *ClientsRevokeCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *ClientsRevokeCall) Do() error {
var body io.Reader = nil
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, "account/{userid}/refresh/{clientid}")
urls += "?" + params.Encode()
req, _ := http.NewRequest("DELETE", urls, body)
googleapi.Expand(req.URL, map[string]string{
"userid": c.userid,
"clientid": c.clientid,
})
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return err
}
return nil
// {
// "description": "Revoke all refresh tokens issues to the client for the authenticated user.",
// "httpMethod": "DELETE",
// "id": "dex.Client.Revoke",
// "parameterOrder": [
// "userid",
// "clientid"
// ],
// "parameters": {
// "clientid": {
// "location": "path",
// "required": true,
// "type": "string"
// },
// "userid": {
// "location": "path",
// "required": true,
// "type": "string"
// }
// },
// "path": "account/{userid}/refresh/{clientid}"
// }
}
// method id "dex.Client.List":
// method id "dex.RefreshClient.List":
type RefreshClientListCall struct {
s *Service
@ -417,7 +342,7 @@ type RefreshClientListCall struct {
opt_ map[string]interface{}
}
// List: List all clients that hold refresh tokens for the authenticated
// List: List all clients that hold refresh tokens for the specified
// user.
func (r *RefreshClientService) List(userid string) *RefreshClientListCall {
c := &RefreshClientListCall{s: r.s, opt_: make(map[string]interface{})}
@ -461,9 +386,9 @@ func (c *RefreshClientListCall) Do() (*RefreshClientList, error) {
}
return ret, nil
// {
// "description": "List all clients that hold refresh tokens for the authenticated user.",
// "description": "List all clients that hold refresh tokens for the specified user.",
// "httpMethod": "GET",
// "id": "dex.Client.List",
// "id": "dex.RefreshClient.List",
// "parameterOrder": [
// "userid"
// ],
@ -482,6 +407,81 @@ func (c *RefreshClientListCall) Do() (*RefreshClientList, error) {
}
// method id "dex.RefreshClient.Revoke":
type RefreshClientRevokeCall struct {
s *Service
userid string
clientid string
opt_ map[string]interface{}
}
// Revoke: Revoke all refresh tokens issues to the client for the
// specified user.
func (r *RefreshClientService) Revoke(userid string, clientid string) *RefreshClientRevokeCall {
c := &RefreshClientRevokeCall{s: r.s, opt_: make(map[string]interface{})}
c.userid = userid
c.clientid = clientid
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 *RefreshClientRevokeCall) Fields(s ...googleapi.Field) *RefreshClientRevokeCall {
c.opt_["fields"] = googleapi.CombineFields(s)
return c
}
func (c *RefreshClientRevokeCall) Do() error {
var body io.Reader = nil
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, "account/{userid}/refresh/{clientid}")
urls += "?" + params.Encode()
req, _ := http.NewRequest("DELETE", urls, body)
googleapi.Expand(req.URL, map[string]string{
"userid": c.userid,
"clientid": c.clientid,
})
req.Header.Set("User-Agent", "google-api-go-client/0.5")
res, err := c.s.client.Do(req)
if err != nil {
return err
}
defer googleapi.CloseBody(res)
if err := googleapi.CheckResponse(res); err != nil {
return err
}
return nil
// {
// "description": "Revoke all refresh tokens issues to the client for the specified user.",
// "httpMethod": "DELETE",
// "id": "dex.RefreshClient.Revoke",
// "parameterOrder": [
// "userid",
// "clientid"
// ],
// "parameters": {
// "clientid": {
// "location": "path",
// "required": true,
// "type": "string"
// },
// "userid": {
// "location": "path",
// "required": true,
// "type": "string"
// }
// },
// "path": "account/{userid}/refresh/{clientid}"
// }
}
// method id "dex.User.Create":
type UsersCreateCall struct {

View file

@ -272,28 +272,6 @@ const DiscoveryJSON = `{
"response": {
"$ref": "ClientWithSecret"
}
},
"Revoke": {
"id": "dex.Client.Revoke",
"description": "Revoke all refresh tokens issues to the client for the authenticated user.",
"httpMethod": "DELETE",
"path": "account/{userid}/refresh/{clientid}",
"parameterOrder": [
"userid",
"clientid"
],
"parameters": {
"clientid": {
"type": "string",
"required": true,
"location": "path"
},
"userid": {
"type": "string",
"required": true,
"location": "path"
}
}
}
}
},
@ -398,8 +376,8 @@ const DiscoveryJSON = `{
"RefreshClient": {
"methods": {
"List": {
"id": "dex.Client.List",
"description": "List all clients that hold refresh tokens for the authenticated user.",
"id": "dex.RefreshClient.List",
"description": "List all clients that hold refresh tokens for the specified user.",
"httpMethod": "GET",
"path": "account/{userid}/refresh",
"parameters": {
@ -415,6 +393,28 @@ const DiscoveryJSON = `{
"response": {
"$ref": "RefreshClientList"
}
},
"Revoke": {
"id": "dex.RefreshClient.Revoke",
"description": "Revoke all refresh tokens issues to the client for the specified user.",
"httpMethod": "DELETE",
"path": "account/{userid}/refresh/{clientid}",
"parameterOrder": [
"userid",
"clientid"
],
"parameters": {
"clientid": {
"type": "string",
"required": true,
"location": "path"
},
"userid": {
"type": "string",
"required": true,
"location": "path"
}
}
}
}
}

View file

@ -266,28 +266,6 @@
"response": {
"$ref": "ClientWithSecret"
}
},
"Revoke": {
"id": "dex.Client.Revoke",
"description": "Revoke all refresh tokens issues to the client for the authenticated user.",
"httpMethod": "DELETE",
"path": "account/{userid}/refresh/{clientid}",
"parameterOrder": [
"userid",
"clientid"
],
"parameters": {
"clientid": {
"type": "string",
"required": true,
"location": "path"
},
"userid": {
"type": "string",
"required": true,
"location": "path"
}
}
}
}
},
@ -392,8 +370,8 @@
"RefreshClient": {
"methods": {
"List": {
"id": "dex.Client.List",
"description": "List all clients that hold refresh tokens for the authenticated user.",
"id": "dex.RefreshClient.List",
"description": "List all clients that hold refresh tokens for the specified user.",
"httpMethod": "GET",
"path": "account/{userid}/refresh",
"parameters": {
@ -409,6 +387,28 @@
"response": {
"$ref": "RefreshClientList"
}
},
"Revoke": {
"id": "dex.RefreshClient.Revoke",
"description": "Revoke all refresh tokens issues to the client for the specified user.",
"httpMethod": "DELETE",
"path": "account/{userid}/refresh/{clientid}",
"parameterOrder": [
"userid",
"clientid"
],
"parameters": {
"clientid": {
"type": "string",
"required": true,
"location": "path"
},
"userid": {
"type": "string",
"required": true,
"location": "path"
}
}
}
}
}