client

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Token string
	// contains filtered or unexported fields
}

Client represents a Linode API client with configuration and HTTP wrapper.

func New

func New(ctx context.Context, client *Client) (*Client, error)

New creates a new Client instance from an existing Client configuration. It initializes a new HTTP client with logging capabilities. Parameters:

  • ctx: Context for cancellation and timeouts
  • client: Existing Client configuration to copy

Returns:

  • *Client: New client instance
  • error: Any initialization error

func NewClient

func NewClient(ctx context.Context, apiUrl string, token string, httpClient ...*uhttp.BaseHttpClient) *Client

NewClient creates a new Client instance with direct configuration. Parameters:

  • ctx: Context for cancellation and timeouts
  • apiUrl: Custom API URL (optional)
  • token: API authentication token
  • httpClient: Optional existing HTTP client (variadic parameter)

Returns:

  • *Client: New client instance

func (*Client) GetUserGrants

func (c *Client) GetUserGrants(ctx context.Context, username string) (*GrantsResponse, error)

GetUserGrants retrieves the grants/permissions for a specific user. Parameters:

  • ctx: Context for cancellation and timeouts
  • username: Username to fetch grants for

Returns:

  • *GrantsResponse: User's grants information
  • error: Any API request error

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, token string) ([]User, string, annotations.Annotations, error)

GetUsers retrieves a paginated list of users from the Linode API. Parameters:

  • ctx: Context for cancellation and timeouts
  • pageToken: Optional pagination token

Returns:

  • []User: List of user objects
  • *PageToken: Token for next page (if available)
  • annotations.Annotations: API metadata/annotations
  • error: Any API request error

type GlobalGrants

type GlobalGrants struct {
	AddImages            bool    `json:"add_images"`
	AddLinodes           bool    `json:"add_linodes"`
	LongviewSubscription bool    `json:"longview_subscription"`
	AddLKEs              bool    `json:"add_lkes"`
	ChildAccountAccess   *string `json:"child_account_access"`
	AddDatabases         bool    `json:"add_databases"`
	AddDomains           bool    `json:"add_domains"`
	AddStackscripts      bool    `json:"add_stackscripts"`
	AddVPCs              bool    `json:"add_vpcs"`
	AddNodebalancers     bool    `json:"add_nodebalancers"`
	AddFirewalls         bool    `json:"add_firewalls"`
	AddVolumes           bool    `json:"add_volumes"`
	AddLongview          bool    `json:"add_longview"`
	AccountAccess        string  `json:"account_access"`
	CancelAccount        bool    `json:"cancel_account"`
}

type GrantsResponse

type GrantsResponse struct {
	Linode       []interface{} `json:"linode"`
	Nodebalancer []interface{} `json:"nodebalancer"`
	Domain       []interface{} `json:"domain"`
	Stackscript  []interface{} `json:"stackscript"`
	Longview     []interface{} `json:"longview"`
	Image        []interface{} `json:"image"`
	Volume       []interface{} `json:"volume"`
	Firewall     []interface{} `json:"firewall"`
	Database     []interface{} `json:"database"`
	VPC          []interface{} `json:"vpc"`
	LKECluster   []interface{} `json:"lkecluster"`
	Global       struct {
		AddImages            bool    `json:"add_images"`
		AddLinodes           bool    `json:"add_linodes"`
		LongviewSubscription bool    `json:"longview_subscription"`
		AddLKEs              bool    `json:"add_lkes"`
		ChildAccountAccess   *string `json:"child_account_access"`
		AddDatabases         bool    `json:"add_databases"`
		AddDomains           bool    `json:"add_domains"`
		AddStackscripts      bool    `json:"add_stackscripts"`
		AddVPCs              bool    `json:"add_vpcs"`
		AddNodebalancers     bool    `json:"add_nodebalancers"`
		AddFirewalls         bool    `json:"add_firewalls"`
		AddVolumes           bool    `json:"add_volumes"`
		AddLongview          bool    `json:"add_longview"`
		AccountAccess        string  `json:"account_access"`
		CancelAccount        bool    `json:"cancel_account"`
	} `json:"global"`
}

type User

type User struct {
	Username   string `json:"username"`
	Email      string `json:"email"`
	Restricted bool   `json:"restricted"`
}

type UserGrants

type UserGrants struct {
	Global GlobalGrants `json:"global"`
}

type UsersResponse

type UsersResponse struct {
	Data    []User `json:"data"`
	Page    int    `json:"page"`
	Pages   int    `json:"pages"`
	Results int    `json:"results"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL