Documentation
¶
Overview ¶
Package client calls the Cloudflare v4 API for the account this connector syncs. It owns authentication, paging, rate-limit annotations, and mapping HTTP failures to gRPC codes; it returns one page per list call.
Endpoints used (all under https://api.cloudflare.com/client/v4, API docs at https://developers.cloudflare.com/api/):
GET /accounts/{account_id}/access/keys
GET /accounts/{account_id}/access/users
GET /accounts/{account_id}/access/groups
GET /accounts/{account_id}/access/groups/{group_id}
PUT /accounts/{account_id}/access/groups/{group_id}
GET /accounts/{account_id}/members
GET /accounts/{account_id}/members/{member_id}
PUT /accounts/{account_id}/members/{member_id}
GET /accounts/{account_id}/roles
GET /accounts/{account_id}/roles/{role_id}
GET /accounts/{account_id}/iam/permission_groups
Permission names below are the Cloudflare API token permission groups this connector declares for the resource type that makes the call.
Index ¶
- Variables
- type AccessGroup
- type AccessUser
- type AccountMember
- type AccountMemberUserDetails
- type AccountRole
- type AccountRolePermission
- type Client
- func (c *Client) AccountMember(ctx context.Context, memberID string) (AccountMember, annotations.Annotations, error)
- func (c *Client) AccountResourceGroup() ResourceGroup
- func (c *Client) GetAccessGroup(ctx context.Context, groupID string) (AccessGroup, annotations.Annotations, error)
- func (c *Client) ListAccessGroups(ctx context.Context, pageToken string) ([]*AccessGroup, string, annotations.Annotations, error)
- func (c *Client) ListAccessUsers(ctx context.Context, pageToken string) ([]*AccessUser, string, annotations.Annotations, error)
- func (c *Client) ListAccountMembers(ctx context.Context, pageToken string) ([]*AccountMember, string, annotations.Annotations, error)
- func (c *Client) ListAccountRoles(ctx context.Context, pageToken string) ([]*AccountRole, string, annotations.Annotations, error)
- func (c *Client) RolePermissionGroup(ctx context.Context, roleID string) (PermissionGroup, annotations.Annotations, error)
- func (c *Client) UpdateAccessGroupInclude(ctx context.Context, group *AccessGroup, include []interface{}) (annotations.Annotations, error)
- func (c *Client) UpdateAccountMember(ctx context.Context, memberID string, member AccountMember) (AccountMember, annotations.Annotations, error)
- func (c *Client) VerifyAccess(ctx context.Context) (annotations.Annotations, error)
- type Permission
- type PermissionGroup
- type Policy
- type ResourceGroup
- type Scope
- type ScopeObject
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AccessGroup ¶
type AccessGroup struct {
ID string `json:"id,omitempty"`
CreatedAt *time.Time `json:"created_at"`
Name string `json:"name"`
// Include is OR: the user must satisfy one of the rules.
Include []interface{} `json:"include"`
// Exclude is NOT: the user must not satisfy any of the rules.
Exclude []interface{} `json:"exclude"`
// Require is AND: the user must satisfy all of the rules.
Require []interface{} `json:"require"`
}
AccessGroup is a Zero Trust Access group. Its rule lists are kept as decoded JSON values so that rule types this connector does not model survive a read-modify-write unchanged.
type AccessUser ¶
type AccessUser struct {
ID string `json:"id"`
AccessSeat *bool `json:"access_seat"`
CreatedAt string `json:"created_at"`
Email string `json:"email"`
LastSuccessfulLogin string `json:"last_successful_login"`
Name string `json:"name"`
}
AccessUser is a Zero Trust Access user.
type AccountMember ¶
type AccountMember struct {
ID string `json:"id"`
Code string `json:"code"`
User AccountMemberUserDetails `json:"user"`
Status string `json:"status"`
Roles []AccountRole `json:"roles,omitempty"`
Policies []Policy `json:"policies,omitempty"`
}
AccountMember is a member of the account. A member's access is expressed either as legacy Roles or as Policies (Domain Scoped Roles), never both.
type AccountMemberUserDetails ¶
type AccountMemberUserDetails struct {
ID string `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
}
AccountMemberUserDetails is the user behind an account member.
type AccountRole ¶
type AccountRole struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Permissions map[string]AccountRolePermission `json:"permissions"`
}
AccountRole is a classic account role.
type AccountRolePermission ¶
AccountRolePermission is the read/edit pair a role grants on one area.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the Cloudflare API for a single account.
func New ¶
New returns a Client authenticated with an API token, or with an API key and email when no API token is set. Requests go through a uhttp client so they get Baton logging and gRPC-coded errors, and are throttled to 4 per second: Cloudflare allows 1200 requests per 5 minutes per user, and going over blocks every call from that user for the rest of the window, which outlasts the provisioning retries. baseURL overrides the Cloudflare API URL when non-empty.
func (*Client) AccountMember ¶
func (c *Client) AccountMember(ctx context.Context, memberID string) (AccountMember, annotations.Annotations, error)
AccountMember returns an account member, bypassing the HTTP cache because callers modify and write the member back. An empty member ID would address the member collection instead of a member, so it is rejected. GET /accounts/{account_id}/members/{member_id} Permission: Account Settings Read.
func (*Client) AccountResourceGroup ¶
func (c *Client) AccountResourceGroup() ResourceGroup
AccountResourceGroup returns a resource group covering every resource in the client's account.
func (*Client) GetAccessGroup ¶
func (c *Client) GetAccessGroup(ctx context.Context, groupID string) (AccessGroup, annotations.Annotations, error)
GetAccessGroup returns one Access group, bypassing the HTTP cache because Grant and Revoke modify and write the group back. GET /accounts/{account_id}/access/groups/{group_id} Permission: Access: Organizations, Identity Providers, and Groups Read. A missing group returns codes.NotFound.
func (*Client) ListAccessGroups ¶
func (c *Client) ListAccessGroups(ctx context.Context, pageToken string) ([]*AccessGroup, string, annotations.Annotations, error)
ListAccessGroups returns one page of Access groups and the token for the next page ("" after the last page). GET /accounts/{account_id}/access/groups Permission: Access: Organizations, Identity Providers, and Groups Read.
func (*Client) ListAccessUsers ¶
func (c *Client) ListAccessUsers(ctx context.Context, pageToken string) ([]*AccessUser, string, annotations.Annotations, error)
ListAccessUsers returns one page of Zero Trust Access users and the token for the next page ("" after the last page). GET /accounts/{account_id}/access/users Permission: Access: Users Read.
func (*Client) ListAccountMembers ¶
func (c *Client) ListAccountMembers(ctx context.Context, pageToken string) ([]*AccountMember, string, annotations.Annotations, error)
ListAccountMembers returns one page of account members and the token for the next page ("" after the last page). GET /accounts/{account_id}/members Permission: Account Settings Read.
func (*Client) ListAccountRoles ¶
func (c *Client) ListAccountRoles(ctx context.Context, pageToken string) ([]*AccountRole, string, annotations.Annotations, error)
ListAccountRoles returns one page of account roles and the token for the next page ("" after the last page). GET /accounts/{account_id}/roles Permission: Account Settings Read.
func (*Client) RolePermissionGroup ¶
func (c *Client) RolePermissionGroup(ctx context.Context, roleID string) (PermissionGroup, annotations.Annotations, error)
RolePermissionGroup finds the permission group that mirrors the given classic role. Accounts enrolled in Domain Scoped Roles represent grants via Policies (a permission group + resource group pair), not the legacy Roles list, and reject an update that sets Roles on a member that already has Policies. Permission groups share their name with the role they mirror, so the role's name is used to find the equivalent group. GET /accounts/{account_id}/roles/{role_id} GET /accounts/{account_id}/iam/permission_groups?name={role_name} Permission: Account Settings Read.
func (*Client) UpdateAccessGroupInclude ¶
func (c *Client) UpdateAccessGroupInclude(ctx context.Context, group *AccessGroup, include []interface{}) (annotations.Annotations, error)
UpdateAccessGroupInclude replaces a group's Include list, carrying the rest of the group over unchanged. The endpoint replaces the whole group, so sending only Include would write an empty name and clear both other rule lists. PUT /accounts/{account_id}/access/groups/{group_id} Permission: Access: Organizations, Identity Providers, and Groups Write. A missing group returns codes.NotFound.
func (*Client) UpdateAccountMember ¶
func (c *Client) UpdateAccountMember(ctx context.Context, memberID string, member AccountMember) (AccountMember, annotations.Annotations, error)
UpdateAccountMember replaces an account member's roles or policies. The member must carry exactly one of the two. PUT /accounts/{account_id}/members/{member_id} Permission: Account Settings Write.
func (*Client) VerifyAccess ¶
func (c *Client) VerifyAccess(ctx context.Context) (annotations.Annotations, error)
VerifyAccess checks the credentials and account ID by reading the account's Access key rotation settings. The settings themselves are not used. GET /accounts/{account_id}/access/keys Permission: Access: Organizations, Identity Providers, and Groups Read.
type Permission ¶
type Permission struct {
ID string `json:"id"`
Key string `json:"key"`
Attributes map[string]string `json:"attributes,omitempty"`
}
Permission is one permission inside a PermissionGroup.
type PermissionGroup ¶
type PermissionGroup struct {
ID string `json:"id"`
Name string `json:"name"`
Meta map[string]string `json:"meta"`
Permissions []Permission `json:"permissions"`
}
PermissionGroup is a named set of permissions used in a Policy.
type Policy ¶
type Policy struct {
ID string `json:"id"`
PermissionGroups []PermissionGroup `json:"permission_groups"`
ResourceGroups []ResourceGroup `json:"resource_groups"`
Access string `json:"access"`
}
Policy grants the permission groups it lists on the resource groups it lists.
type ResourceGroup ¶
type ResourceGroup struct {
ID string `json:"id"`
Name string `json:"name"`
Meta map[string]string `json:"meta"`
Scope Scope `json:"scope"`
}
ResourceGroup is the set of resources a Policy applies to.
type Scope ¶
type Scope struct {
Key string `json:"key"`
ScopeObjects []ScopeObject `json:"objects"`
}
Scope selects the resources of a ResourceGroup.
type ScopeObject ¶
type ScopeObject struct {
Key string `json:"key"`
}
ScopeObject is one resource selector inside a Scope.