This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathoauth_client.go
101 lines (84 loc) · 3.15 KB
/
oauth_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// WARNING: This code is auto-generated from the Heroku Platform API JSON Schema
// by a Ruby script (gen/gen.rb). Changes should be made to the generation
// script rather than the generated files.
package heroku
import (
"time"
)
// OAuth clients are applications that Heroku users can authorize to automate,
// customize or extend their usage of the platform. For more information please
// refer to the Heroku OAuth documentation.
type OAuthClient struct {
// when OAuth client was created
CreatedAt time.Time `json:"created_at"`
// unique identifier of this OAuth client
Id string `json:"id"`
// whether the client is still operable given a delinquent account
IgnoresDelinquent *bool `json:"ignores_delinquent"`
// OAuth client name
Name string `json:"name"`
// endpoint for redirection after authorization with OAuth client
RedirectUri string `json:"redirect_uri"`
// secret used to obtain OAuth authorizations under this client
Secret string `json:"secret"`
// when OAuth client was updated
UpdatedAt time.Time `json:"updated_at"`
}
// Create a new OAuth client.
//
// name is the OAuth client name. redirectUri is the endpoint for redirection
// after authorization with OAuth client.
func (c *Client) OAuthClientCreate(name string, redirectUri string) (*OAuthClient, error) {
params := struct {
Name string `json:"name"`
RedirectUri string `json:"redirect_uri"`
}{
Name: name,
RedirectUri: redirectUri,
}
var oauthClientRes OAuthClient
return &oauthClientRes, c.Post(&oauthClientRes, "/oauth/clients", params)
}
// Delete OAuth client.
//
// oauthClientIdentity is the unique identifier of the OAuthClient.
func (c *Client) OAuthClientDelete(oauthClientIdentity string) error {
return c.Delete("/oauth/clients/" + oauthClientIdentity)
}
// Info for an OAuth client
//
// oauthClientIdentity is the unique identifier of the OAuthClient.
func (c *Client) OAuthClientInfo(oauthClientIdentity string) (*OAuthClient, error) {
var oauthClient OAuthClient
return &oauthClient, c.Get(&oauthClient, "/oauth/clients/"+oauthClientIdentity)
}
// List OAuth clients
//
// lr is an optional ListRange that sets the Range options for the paginated
// list of results.
func (c *Client) OAuthClientList(lr *ListRange) ([]OAuthClient, error) {
req, err := c.NewRequest("GET", "/oauth/clients", nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var oauthClientsRes []OAuthClient
return oauthClientsRes, c.DoReq(req, &oauthClientsRes)
}
// Update OAuth client
//
// oauthClientIdentity is the unique identifier of the OAuthClient. options is
// the struct of optional parameters for this action.
func (c *Client) OAuthClientUpdate(oauthClientIdentity string, options *OAuthClientUpdateOpts) (*OAuthClient, error) {
var oauthClientRes OAuthClient
return &oauthClientRes, c.Patch(&oauthClientRes, "/oauth/clients/"+oauthClientIdentity, options)
}
// OAuthClientUpdateOpts holds the optional parameters for OAuthClientUpdate
type OAuthClientUpdateOpts struct {
// OAuth client name
Name *string `json:"name,omitempty"`
// endpoint for redirection after authorization with OAuth client
RedirectUri *string `json:"redirect_uri,omitempty"`
}