forked from cloudflare/cloudflare-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_user_tokens.go
38 lines (31 loc) · 1.26 KB
/
access_user_tokens.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
package cloudflare
import (
"context"
"fmt"
"net/http"
)
type AccessUserEmail struct {
Email string `json:"email"`
}
// RevokeAccessUserTokens revokes any outstanding tokens issued for a specific user
// Access User.
//
// API reference: https://api.cloudflare.com/#access-organizations-revoke-all-access-tokens-for-a-user
func (api *API) RevokeAccessUserTokens(ctx context.Context, accountID string, accessUserEmail AccessUserEmail) error {
return api.revokeUserTokens(ctx, accountID, accessUserEmail, AccountRouteRoot)
}
// RevokeZoneLevelAccessUserTokens revokes any outstanding tokens issued for a specific user
// Access User.
//
// API reference: https://api.cloudflare.com/#zone-level-access-organizations-revoke-all-access-tokens-for-a-user
func (api *API) RevokeZoneLevelAccessUserTokens(ctx context.Context, zoneID string, accessUserEmail AccessUserEmail) error {
return api.revokeUserTokens(ctx, zoneID, accessUserEmail, ZoneRouteRoot)
}
func (api *API) revokeUserTokens(ctx context.Context, id string, accessUserEmail AccessUserEmail, routeRoot RouteRoot) error {
uri := fmt.Sprintf("/%s/%s/access/organizations/revoke_user", routeRoot, id)
_, err := api.makeRequestContext(ctx, http.MethodPost, uri, accessUserEmail)
if err != nil {
return err
}
return nil
}