Documentation
¶
Overview ¶
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Copyright (c) 2026 Contentways SPDX-License-Identifier: MIT
Index ¶
- Constants
- func DefaultBackoff(attempt int) time.Duration
- func IsNotFound(err error) bool
- func RecordToSchema(r Record) schema.Record
- func ZoneToSchema(z Zone) schema.Zone
- type APIError
- type Backoff
- type BulkRecordOperation
- type BulkRecordsResult
- type Client
- type Group
- type GroupClient
- func (g *GroupClient) AddMember(ctx context.Context, groupID, userID int) (*Response, error)
- func (g *GroupClient) AddZone(ctx context.Context, groupID, zoneID int) (*Response, error)
- func (g *GroupClient) All(ctx context.Context) ([]*Group, error)
- func (g *GroupClient) Create(ctx context.Context, opts GroupCreateOpts) (int, *Response, error)
- func (g *GroupClient) Delete(ctx context.Context, id int) (*Response, error)
- func (g *GroupClient) GetByID(ctx context.Context, id int) (*Group, *Response, error)
- func (g *GroupClient) GetByName(ctx context.Context, name string) (*Group, *Response, error)
- func (g *GroupClient) List(ctx context.Context, opts ListOpts) ([]*Group, *Response, error)
- func (g *GroupClient) Members(ctx context.Context, id int) ([]*GroupMember, *Response, error)
- func (g *GroupClient) RemoveMember(ctx context.Context, groupID, userID int) (*Response, error)
- func (g *GroupClient) RemoveZone(ctx context.Context, groupID, zoneID int) (*Response, error)
- func (g *GroupClient) Update(ctx context.Context, id int, opts GroupUpdateOpts) (*Group, *Response, error)
- func (g *GroupClient) Zones(ctx context.Context, id int) ([]*GroupZone, *Response, error)
- type GroupCreateOpts
- type GroupMember
- type GroupUpdateOpts
- type GroupZone
- type IGroupClient
- type IPermissionClient
- type IPermissionTemplateClient
- type IRRSetClient
- type IRecordClient
- type IUserClient
- type IZoneClient
- type IZoneTemplateClient
- type ListOpts
- type Option
- func WithAPIKey(key string) Option
- func WithAPIVersion(version string) Option
- func WithBaseURL(u string) Option
- func WithBasicAuth(username, password string) Option
- func WithDebugWriter(w io.Writer) Option
- func WithHTTPClient(hc *http.Client) Option
- func WithInsecure() Option
- func WithRetry(maxAttempts int) Option
- func WithRetryBackoff(fn Backoff) Option
- func WithTimeout(d time.Duration) Option
- type Pagination
- type Permission
- type PermissionClient
- type PermissionTemplate
- type PermissionTemplateClient
- func (c *PermissionTemplateClient) Create(ctx context.Context, opts PermissionTemplateOpts) (*PermissionTemplate, *Response, error)
- func (c *PermissionTemplateClient) Delete(ctx context.Context, id int) (*Response, error)
- func (c *PermissionTemplateClient) GetByID(ctx context.Context, id int) (*PermissionTemplate, *Response, error)
- func (c *PermissionTemplateClient) GetByName(ctx context.Context, name string) (*PermissionTemplate, *Response, error)
- func (c *PermissionTemplateClient) List(ctx context.Context) ([]*PermissionTemplate, *Response, error)
- func (c *PermissionTemplateClient) Update(ctx context.Context, id int, opts PermissionTemplateOpts) (*PermissionTemplate, *Response, error)
- type PermissionTemplateOpts
- type RRSet
- type RRSetClient
- func (r *RRSetClient) Delete(ctx context.Context, zoneID int, name, recordType string) (*Response, error)
- func (r *RRSetClient) Get(ctx context.Context, zoneID int, name, recordType string) (*RRSet, *Response, error)
- func (r *RRSetClient) List(ctx context.Context, zoneID int) ([]*RRSet, *Response, error)
- func (r *RRSetClient) Upsert(ctx context.Context, zoneID int, opts RRSetUpsertOpts) (*Response, error)
- type RRSetRecord
- type RRSetUpsertOpts
- type Record
- type RecordClient
- func (r *RecordClient) All(ctx context.Context, zoneID int) ([]*Record, error)
- func (r *RecordClient) Bulk(ctx context.Context, zoneID int, ops []BulkRecordOperation) (*BulkRecordsResult, *Response, error)
- func (r *RecordClient) Create(ctx context.Context, zoneID int, opts RecordCreateOpts) (int64, *Response, error)
- func (r *RecordClient) Delete(ctx context.Context, zoneID int, recordID int64) (*Response, error)
- func (r *RecordClient) GetByID(ctx context.Context, zoneID int, recordID int64) (*Record, *Response, error)
- func (r *RecordClient) List(ctx context.Context, zoneID int, opts RecordListOpts) ([]*Record, *Response, error)
- func (r *RecordClient) Update(ctx context.Context, zoneID int, recordID int64, opts RecordUpdateOpts) (*Record, *Response, error)
- type RecordCreateOpts
- type RecordListOpts
- type RecordUpdateOpts
- type Response
- type ResponseMeta
- type User
- type UserClient
- func (u *UserClient) All(ctx context.Context) ([]*User, error)
- func (u *UserClient) Create(ctx context.Context, opts UserCreateOpts) (int, *Response, error)
- func (u *UserClient) Delete(ctx context.Context, id int) (*Response, error)
- func (u *UserClient) GetByID(ctx context.Context, id int) (*User, *Response, error)
- func (u *UserClient) GetByName(ctx context.Context, username string) (*User, *Response, error)
- func (u *UserClient) List(ctx context.Context, opts ListOpts) ([]*User, *Response, error)
- func (u *UserClient) SetPermissionTemplate(ctx context.Context, id, permTemplID int) (*Response, error)
- func (u *UserClient) Update(ctx context.Context, id int, opts UserUpdateOpts) (*User, *Response, error)
- type UserCreateOpts
- type UserUpdateOpts
- type Zone
- type ZoneClient
- func (z *ZoneClient) AddOwner(ctx context.Context, zoneID, userID int) (*Response, error)
- func (z *ZoneClient) AddOwners(ctx context.Context, zoneID int, userIDs []int) (*Response, error)
- func (z *ZoneClient) All(ctx context.Context) ([]*Zone, error)
- func (z *ZoneClient) Create(ctx context.Context, opts ZoneCreateOpts) (int, *Response, error)
- func (z *ZoneClient) Delete(ctx context.Context, id int) (*Response, error)
- func (z *ZoneClient) GetByID(ctx context.Context, id int) (*Zone, *Response, error)
- func (z *ZoneClient) GetByName(ctx context.Context, name string) (*Zone, *Response, error)
- func (z *ZoneClient) List(ctx context.Context, opts ListOpts) ([]*Zone, *Response, error)
- func (z *ZoneClient) Owners(ctx context.Context, zoneID int) ([]*ZoneOwner, *Response, error)
- func (z *ZoneClient) RemoveOwner(ctx context.Context, zoneID, userID int) (*Response, error)
- func (z *ZoneClient) Update(ctx context.Context, id int, opts ZoneUpdateOpts) (*Zone, *Response, error)
- type ZoneCreateOpts
- type ZoneOwner
- type ZoneTemplate
- type ZoneTemplateClient
- func (c *ZoneTemplateClient) Create(ctx context.Context, opts ZoneTemplateCreateOpts) (*ZoneTemplate, *Response, error)
- func (c *ZoneTemplateClient) CreateRecord(ctx context.Context, templateID int, opts ZoneTemplateRecordOpts) (*ZoneTemplateRecord, *Response, error)
- func (c *ZoneTemplateClient) Delete(ctx context.Context, id int) (*Response, error)
- func (c *ZoneTemplateClient) DeleteRecord(ctx context.Context, templateID, recordID int) (*Response, error)
- func (c *ZoneTemplateClient) GetByID(ctx context.Context, id int) (*ZoneTemplate, *Response, error)
- func (c *ZoneTemplateClient) GetByName(ctx context.Context, name string) (*ZoneTemplate, *Response, error)
- func (c *ZoneTemplateClient) GetRecord(ctx context.Context, templateID, recordID int) (*ZoneTemplateRecord, *Response, error)
- func (c *ZoneTemplateClient) List(ctx context.Context) ([]*ZoneTemplate, *Response, error)
- func (c *ZoneTemplateClient) Records(ctx context.Context, templateID int) ([]*ZoneTemplateRecord, *Response, error)
- func (c *ZoneTemplateClient) Update(ctx context.Context, id int, opts ZoneTemplateUpdateOpts) (*ZoneTemplate, *Response, error)
- func (c *ZoneTemplateClient) UpdateRecord(ctx context.Context, templateID, recordID int, opts ZoneTemplateRecordOpts) (*ZoneTemplateRecord, *Response, error)
- type ZoneTemplateCreateOpts
- type ZoneTemplateRecord
- type ZoneTemplateRecordOpts
- type ZoneTemplateUpdateOpts
- type ZoneType
- type ZoneUpdateOpts
Constants ¶
const Version = "1.1.0"
Version is the current version of the poweradmin-go SDK.
Variables ¶
This section is empty.
Functions ¶
func DefaultBackoff ¶
DefaultBackoff is exponential with ±25% jitter, hard-capped at 10s. attempt 0 → ~100ms, 1 → ~200ms, 2 → ~400ms, 3 → ~800ms, ..., ≤ 10s.
func IsNotFound ¶
IsNotFound reports whether err is a 404 Not Found API error.
func RecordToSchema ¶
func ZoneToSchema ¶
Types ¶
type Backoff ¶
Backoff returns the delay before the next retry attempt. attempt is the zero-based index of the *next* attempt (0 = first retry).
type BulkRecordOperation ¶
type BulkRecordOperation struct {
Action string
RecordID int
Name string
Type string
Content string
TTL int
Priority int
Disabled bool
}
BulkRecordOperation represents a single operation in a bulk records request. Action is one of "create", "update", "delete". RecordID is required for update/delete; Name/Type/Content are required for create.
type BulkRecordsResult ¶
BulkRecordsResult is the outcome of a bulk records call. The API reports per-action counts rather than a single success/failure tally.
type Client ¶
type Client struct {
// Per-resource clients
Zone IZoneClient
ZoneTemplate IZoneTemplateClient
Record IRecordClient
RRSet IRRSetClient
User IUserClient
Group IGroupClient
Permission IPermissionClient
PermissionTemplate IPermissionTemplateClient
// contains filtered or unexported fields
}
Client is the Poweradmin API client. Create one via NewClient.
func NewClient ¶
NewClient creates a new Poweradmin API client. At minimum, WithBaseURL and either WithAPIKey or WithBasicAuth must be provided.
type Group ¶
type Group struct {
ID int
Name string
Description string
PermTemplID int
MemberCount int
ZoneCount int
CreatedAt string
}
Group represents a Poweradmin user group.
func GroupFromSchema ¶
type GroupClient ¶
type GroupClient struct {
// contains filtered or unexported fields
}
GroupClient provides access to the group-related Poweradmin API endpoints.
func (*GroupClient) All ¶
func (g *GroupClient) All(ctx context.Context) ([]*Group, error)
All returns all [Group]s across all pages.
func (*GroupClient) Create ¶
func (g *GroupClient) Create(ctx context.Context, opts GroupCreateOpts) (int, *Response, error)
Create creates a new Group and returns the new ID.
func (*GroupClient) GetByName ¶
GetByName returns a single Group by name. Paginates the list endpoint and matches client-side.
func (*GroupClient) Members ¶
func (g *GroupClient) Members(ctx context.Context, id int) ([]*GroupMember, *Response, error)
Members returns the [GroupMember]s of a group.
func (*GroupClient) RemoveMember ¶
RemoveMember removes a user from a group.
func (*GroupClient) RemoveZone ¶
RemoveZone disassociates a zone from a group.
type GroupCreateOpts ¶
GroupCreateOpts configures a group creation request.
type GroupMember ¶
GroupMember represents a member of a group.
func GroupMemberFromSchema ¶
func GroupMemberFromSchema(s schema.GroupMember) GroupMember
type GroupUpdateOpts ¶
GroupUpdateOpts configures a group update request. Description is a *string so an empty description can be sent explicitly.
type IGroupClient ¶
type IGroupClient interface {
// GetByName returns a single [Group] by name.
// Paginates the list endpoint and matches client-side.
GetByName(ctx context.Context, name string) (*Group, *Response, error)
// GetByID returns a single [Group] by ID.
GetByID(ctx context.Context, id int) (*Group, *Response, error)
// List returns one page of [Group]s.
List(ctx context.Context, opts ListOpts) ([]*Group, *Response, error)
// All returns all [Group]s across all pages.
All(ctx context.Context) ([]*Group, error)
// Create creates a new [Group] and returns the new ID.
Create(ctx context.Context, opts GroupCreateOpts) (int, *Response, error)
// Update updates an existing [Group] and returns the updated state.
Update(ctx context.Context, id int, opts GroupUpdateOpts) (*Group, *Response, error)
// Delete deletes the [Group] with the given ID.
Delete(ctx context.Context, id int) (*Response, error)
// Members returns the [GroupMember]s of a group.
Members(ctx context.Context, id int) ([]*GroupMember, *Response, error)
// AddMember adds a user to a group.
AddMember(ctx context.Context, groupID, userID int) (*Response, error)
// RemoveMember removes a user from a group.
RemoveMember(ctx context.Context, groupID, userID int) (*Response, error)
// Zones returns the zones associated with a group.
Zones(ctx context.Context, id int) ([]*GroupZone, *Response, error)
// AddZone associates a zone with a group.
AddZone(ctx context.Context, groupID, zoneID int) (*Response, error)
// RemoveZone disassociates a zone from a group.
RemoveZone(ctx context.Context, groupID, zoneID int) (*Response, error)
}
IGroupClient ...
type IPermissionClient ¶
type IPermissionClient interface {
// GetByID returns a single [Permission] by ID.
GetByID(ctx context.Context, id int) (*Permission, *Response, error)
// List returns one page of [Permission]s.
List(ctx context.Context, opts ListOpts) ([]*Permission, *Response, error)
// All returns all [Permission]s across all pages.
All(ctx context.Context) ([]*Permission, error)
}
IPermissionClient ...
type IPermissionTemplateClient ¶
type IPermissionTemplateClient interface {
// GetByName returns a single [PermissionTemplate] by name.
// Falls back to a list scan since there is no dedicated by-name endpoint.
// Note: list responses do not include the full permission list — call
// [PermissionTemplateClient.GetByID] on the result to get permissions.
GetByName(ctx context.Context, name string) (*PermissionTemplate, *Response, error)
// GetByID returns a single [PermissionTemplate] with its full permission list.
GetByID(ctx context.Context, id int) (*PermissionTemplate, *Response, error)
// List returns all [PermissionTemplate]s. The permission list is typically not
// populated in list responses — use [PermissionTemplateClient.GetByID] for that.
List(ctx context.Context) ([]*PermissionTemplate, *Response, error)
// Create creates a new [PermissionTemplate].
Create(ctx context.Context, opts PermissionTemplateOpts) (*PermissionTemplate, *Response, error)
// Update updates an existing [PermissionTemplate].
Update(ctx context.Context, id int, opts PermissionTemplateOpts) (*PermissionTemplate, *Response, error)
// Delete deletes a [PermissionTemplate].
Delete(ctx context.Context, id int) (*Response, error)
}
IPermissionTemplateClient ...
type IRRSetClient ¶
type IRRSetClient interface {
// Get returns a single [RRSet] identified by name and type within a zone.
Get(ctx context.Context, zoneID int, name, recordType string) (*RRSet, *Response, error)
// List returns all [RRSet]s in a zone.
List(ctx context.Context, zoneID int) ([]*RRSet, *Response, error)
// Upsert creates or replaces an [RRSet] via PUT. The API treats this as an
// idempotent create-or-update on (name, type) within the zone.
Upsert(ctx context.Context, zoneID int, opts RRSetUpsertOpts) (*Response, error)
// Delete deletes the [RRSet] identified by name and type within a zone.
Delete(ctx context.Context, zoneID int, name, recordType string) (*Response, error)
}
IRRSetClient ...
type IRecordClient ¶
type IRecordClient interface {
// GetByID returns a single [Record] by zone and record ID.
GetByID(ctx context.Context, zoneID int, recordID int64) (*Record, *Response, error)
// List returns one page of [Record]s for the given zone.
// Use [RecordListOpts] with Type set to filter by record type.
List(ctx context.Context, zoneID int, opts RecordListOpts) ([]*Record, *Response, error)
// All returns all [Record]s in a zone across all pages.
All(ctx context.Context, zoneID int) ([]*Record, error)
// Create creates a new [Record] in the given zone and returns the new ID.
Create(ctx context.Context, zoneID int, opts RecordCreateOpts) (int64, *Response, error)
// Update updates an existing [Record] and returns the updated state.
Update(ctx context.Context, zoneID int, recordID int64, opts RecordUpdateOpts) (*Record, *Response, error)
// Delete deletes the [Record] with the given ID.
Delete(ctx context.Context, zoneID int, recordID int64) (*Response, error)
// Bulk executes multiple record operations atomically against the given zone.
Bulk(ctx context.Context, zoneID int, ops []BulkRecordOperation) (*BulkRecordsResult, *Response, error)
}
IRecordClient ...
type IUserClient ¶
type IUserClient interface {
// GetByName returns a single [User] by username.
// Paginates the list endpoint server-side and matches client-side; the API
// has no dedicated username lookup.
GetByName(ctx context.Context, username string) (*User, *Response, error)
// GetByID returns a single [User] by ID.
GetByID(ctx context.Context, id int) (*User, *Response, error)
// List returns one page of [User]s.
List(ctx context.Context, opts ListOpts) ([]*User, *Response, error)
// All returns all [User]s across all pages.
All(ctx context.Context) ([]*User, error)
// Create creates a new [User] and returns the new ID.
Create(ctx context.Context, opts UserCreateOpts) (int, *Response, error)
// Update updates an existing [User] and returns the updated state.
Update(ctx context.Context, id int, opts UserUpdateOpts) (*User, *Response, error)
// Delete deletes the [User] with the given ID.
Delete(ctx context.Context, id int) (*Response, error)
// SetPermissionTemplate assigns a permission template to a user via PATCH.
// This is a partial update; other user fields are untouched.
SetPermissionTemplate(ctx context.Context, id, permTemplID int) (*Response, error)
}
IUserClient ...
type IZoneClient ¶
type IZoneClient interface {
// GetByID returns a single [Zone] by its numeric ID.
GetByID(ctx context.Context, id int) (*Zone, *Response, error)
// GetByName returns a single [Zone] by its DNS name.
// Performs a list + linear search across all pages — no dedicated API endpoint exists.
GetByName(ctx context.Context, name string) (*Zone, *Response, error)
// List returns one page of [Zone]s.
// Note: /v2/zones wraps the array under data.zones — unlike the other list
// endpoints in this API. The wrapper is unmarshalled here so callers see a
// plain slice.
List(ctx context.Context, opts ListOpts) ([]*Zone, *Response, error)
// All returns all [Zone]s across all pages.
All(ctx context.Context) ([]*Zone, error)
// Create creates a new [Zone] and returns the new ID.
// Call [ZoneClient.GetByID] to fetch the full object.
Create(ctx context.Context, opts ZoneCreateOpts) (int, *Response, error)
// Update updates an existing [Zone] and returns the updated state.
Update(ctx context.Context, id int, opts ZoneUpdateOpts) (*Zone, *Response, error)
// Delete deletes the [Zone] with the given ID.
Delete(ctx context.Context, id int) (*Response, error)
// Owners returns all owners of the zone.
Owners(ctx context.Context, zoneID int) ([]*ZoneOwner, *Response, error)
// AddOwner adds a single user as owner of the zone.
AddOwner(ctx context.Context, zoneID, userID int) (*Response, error)
// AddOwners adds multiple users as owners in a single request.
AddOwners(ctx context.Context, zoneID int, userIDs []int) (*Response, error)
// RemoveOwner removes a user from the zone's owners.
RemoveOwner(ctx context.Context, zoneID, userID int) (*Response, error)
}
IZoneClient ...
type IZoneTemplateClient ¶
type IZoneTemplateClient interface {
// GetByName returns a single [ZoneTemplate] by name.
// The template endpoint is not paginated, so this is a single-page scan.
GetByName(ctx context.Context, name string) (*ZoneTemplate, *Response, error)
// GetByID returns a single [ZoneTemplate].
GetByID(ctx context.Context, id int) (*ZoneTemplate, *Response, error)
// List returns all [ZoneTemplate]s.
List(ctx context.Context) ([]*ZoneTemplate, *Response, error)
// Create creates a new [ZoneTemplate].
Create(ctx context.Context, opts ZoneTemplateCreateOpts) (*ZoneTemplate, *Response, error)
// Update updates an existing [ZoneTemplate].
Update(ctx context.Context, id int, opts ZoneTemplateUpdateOpts) (*ZoneTemplate, *Response, error)
// Delete deletes a [ZoneTemplate].
Delete(ctx context.Context, id int) (*Response, error)
// Records returns all records belonging to the template.
Records(ctx context.Context, templateID int) ([]*ZoneTemplateRecord, *Response, error)
// GetRecord returns a single template record.
GetRecord(ctx context.Context, templateID, recordID int) (*ZoneTemplateRecord, *Response, error)
// CreateRecord adds a record to a template.
CreateRecord(ctx context.Context, templateID int, opts ZoneTemplateRecordOpts) (*ZoneTemplateRecord, *Response, error)
// UpdateRecord replaces a template record.
UpdateRecord(ctx context.Context, templateID, recordID int, opts ZoneTemplateRecordOpts) (*ZoneTemplateRecord, *Response, error)
// DeleteRecord removes a record from a template.
DeleteRecord(ctx context.Context, templateID, recordID int) (*Response, error)
}
IZoneTemplateClient ...
type ListOpts ¶
ListOpts controls pagination for List operations. A zero value requests the API's default page and size.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithAPIKey ¶
WithAPIKey configures Bearer token / X-API-Key authentication. This is the recommended authentication method.
func WithAPIVersion ¶
WithAPIVersion overrides the API version prefix (default: "v2").
func WithBaseURL ¶
WithBaseURL sets the base URL of the Poweradmin instance. Trailing slashes are stripped.
poweradmin.WithBaseURL("https://dns.example.com")
func WithBasicAuth ¶
WithBasicAuth configures HTTP basic authentication.
func WithDebugWriter ¶
WithDebugWriter enables HTTP request/response logging to w. One line is written per request with method, path, status code, and duration. Suitable destinations: os.Stderr, a *log.Logger via log.Writer(), or any io.Writer your application wires up (e.g. slog backed by a buffer).
func WithHTTPClient ¶
WithHTTPClient replaces the default http.Client. Use this to inject a custom transport, proxy, or test double.
func WithInsecure ¶
func WithInsecure() Option
WithInsecure disables TLS certificate verification. Do not use in production. Clones the existing transport if one is set so other settings are preserved.
func WithRetry ¶
WithRetry enables automatic retry on transient failures (network errors, HTTP 429, and 5xx). maxAttempts is the total number of attempts including the initial one — values < 2 disable retrying. Backoff defaults to DefaultBackoff; override via WithRetryBackoff.
func WithRetryBackoff ¶
WithRetryBackoff sets a custom backoff strategy. Only takes effect if WithRetry has also been called.
func WithTimeout ¶
WithTimeout sets the HTTP client timeout (default: 30s).
type Pagination ¶
Pagination is the domain-level representation of pagination metadata.
type Permission ¶
Permission represents a Poweradmin permission.
func PermissionFromSchema ¶
func PermissionFromSchema(s schema.Permission) Permission
type PermissionClient ¶
type PermissionClient struct {
// contains filtered or unexported fields
}
PermissionClient provides access to the permission-related Poweradmin API endpoints.
func (*PermissionClient) All ¶
func (p *PermissionClient) All(ctx context.Context) ([]*Permission, error)
All returns all [Permission]s across all pages.
func (*PermissionClient) GetByID ¶
func (p *PermissionClient) GetByID(ctx context.Context, id int) (*Permission, *Response, error)
GetByID returns a single Permission by ID.
func (*PermissionClient) List ¶
func (p *PermissionClient) List(ctx context.Context, opts ListOpts) ([]*Permission, *Response, error)
List returns one page of [Permission]s.
type PermissionTemplate ¶
type PermissionTemplate struct {
ID int
Name string
Descr string
TemplateType string // "user" or "group"
Permissions []Permission
}
PermissionTemplate represents a named bundle of permissions that can be assigned to a user or group.
type PermissionTemplateClient ¶
type PermissionTemplateClient struct {
// contains filtered or unexported fields
}
PermissionTemplateClient provides access to the permission-template endpoints.
func (*PermissionTemplateClient) Create ¶
func (c *PermissionTemplateClient) Create(ctx context.Context, opts PermissionTemplateOpts) (*PermissionTemplate, *Response, error)
Create creates a new PermissionTemplate.
func (*PermissionTemplateClient) Delete ¶
Delete deletes a PermissionTemplate.
func (*PermissionTemplateClient) GetByID ¶
func (c *PermissionTemplateClient) GetByID(ctx context.Context, id int) (*PermissionTemplate, *Response, error)
GetByID returns a single PermissionTemplate with its full permission list.
func (*PermissionTemplateClient) GetByName ¶
func (c *PermissionTemplateClient) GetByName(ctx context.Context, name string) (*PermissionTemplate, *Response, error)
GetByName returns a single PermissionTemplate by name. Falls back to a list scan since there is no dedicated by-name endpoint. Note: list responses do not include the full permission list — call PermissionTemplateClient.GetByID on the result to get permissions.
func (*PermissionTemplateClient) List ¶
func (c *PermissionTemplateClient) List(ctx context.Context) ([]*PermissionTemplate, *Response, error)
List returns all [PermissionTemplate]s. The permission list is typically not populated in list responses — use PermissionTemplateClient.GetByID for that.
func (*PermissionTemplateClient) Update ¶
func (c *PermissionTemplateClient) Update(ctx context.Context, id int, opts PermissionTemplateOpts) (*PermissionTemplate, *Response, error)
Update updates an existing PermissionTemplate.
type PermissionTemplateOpts ¶
type PermissionTemplateOpts struct {
Name string
Descr string
TemplateType string // "user" (default) or "group"
Permissions []int // permission IDs to assign
}
PermissionTemplateOpts configures a create or update request.
type RRSet ¶
type RRSet struct {
Name string
Type string
TTL int
Records []RRSetRecord
}
RRSet represents a DNS Resource Record Set. RRSets group all records that share the same name and type within a zone. The Poweradmin API identifies them by (name, type) — there is no numeric ID.
func RRSetFromSchema ¶
type RRSetClient ¶
type RRSetClient struct {
// contains filtered or unexported fields
}
RRSetClient provides access to the rrset-related Poweradmin API endpoints.
func (*RRSetClient) Delete ¶
func (r *RRSetClient) Delete(ctx context.Context, zoneID int, name, recordType string) (*Response, error)
Delete deletes the RRSet identified by name and type within a zone.
func (*RRSetClient) Get ¶
func (r *RRSetClient) Get(ctx context.Context, zoneID int, name, recordType string) (*RRSet, *Response, error)
Get returns a single RRSet identified by name and type within a zone.
func (*RRSetClient) Upsert ¶
func (r *RRSetClient) Upsert(ctx context.Context, zoneID int, opts RRSetUpsertOpts) (*Response, error)
Upsert creates or replaces an RRSet via PUT. The API treats this as an idempotent create-or-update on (name, type) within the zone.
type RRSetRecord ¶
RRSetRecord is one entry within an RRSet.
type RRSetUpsertOpts ¶
type RRSetUpsertOpts struct {
Name string
Type string
TTL int
Records []RRSetRecord
}
RRSetUpsertOpts configures a PUT request that creates or replaces an RRSet.
type Record ¶
type Record struct {
ID int64
ZoneID int64
Name string
Type string
Content string
TTL int
Priority int
Disabled bool
Auth bool // authoritative flag (managed by PowerDNS)
}
Record represents a DNS record in Poweradmin.
func RecordFromSchema ¶
type RecordClient ¶
type RecordClient struct {
// contains filtered or unexported fields
}
RecordClient provides access to the record-related Poweradmin API endpoints.
func (*RecordClient) Bulk ¶
func (r *RecordClient) Bulk(ctx context.Context, zoneID int, ops []BulkRecordOperation) (*BulkRecordsResult, *Response, error)
Bulk executes multiple record operations atomically against the given zone.
func (*RecordClient) Create ¶
func (r *RecordClient) Create(ctx context.Context, zoneID int, opts RecordCreateOpts) (int64, *Response, error)
Create creates a new Record in the given zone and returns the new ID.
func (*RecordClient) GetByID ¶
func (r *RecordClient) GetByID(ctx context.Context, zoneID int, recordID int64) (*Record, *Response, error)
GetByID returns a single Record by zone and record ID.
func (*RecordClient) List ¶
func (r *RecordClient) List(ctx context.Context, zoneID int, opts RecordListOpts) ([]*Record, *Response, error)
List returns one page of [Record]s for the given zone. Use RecordListOpts with Type set to filter by record type.
type RecordCreateOpts ¶
type RecordCreateOpts struct {
Name string
Type string
Content string
TTL int
Priority int
Disabled bool
CreatePTR bool
}
RecordCreateOpts configures a record creation request.
type RecordListOpts ¶
RecordListOpts adds a record-type filter on top of the standard pagination options.
type RecordUpdateOpts ¶
type RecordUpdateOpts struct {
Name string
Type string
Content string
TTL *int
Priority *int
Disabled *bool
}
RecordUpdateOpts configures a record update request. Pointer fields are only sent when non-nil.
type Response ¶
type Response struct {
*http.Response
Meta ResponseMeta
}
Response wraps http.Response with parsed metadata extracted from the Poweradmin API envelope (currently: pagination).
type ResponseMeta ¶
type ResponseMeta struct {
Pagination *Pagination
}
ResponseMeta holds parsed metadata that accompanied an API response.
type User ¶
type User struct {
ID int
Username string
Fullname string
Email string
Description string
Active bool
PermTempl int
UseLdap bool
IsAdmin bool
Permissions []string
ZoneCount int
CreatedAt string
UpdatedAt string
}
User represents a Poweradmin user.
func UserFromSchema ¶
type UserClient ¶
type UserClient struct {
// contains filtered or unexported fields
}
UserClient provides access to the user-related Poweradmin API endpoints.
func (*UserClient) All ¶
func (u *UserClient) All(ctx context.Context) ([]*User, error)
All returns all [User]s across all pages.
func (*UserClient) Create ¶
func (u *UserClient) Create(ctx context.Context, opts UserCreateOpts) (int, *Response, error)
Create creates a new User and returns the new ID.
func (*UserClient) GetByName ¶
GetByName returns a single User by username. Paginates the list endpoint server-side and matches client-side; the API has no dedicated username lookup.
func (*UserClient) SetPermissionTemplate ¶
func (u *UserClient) SetPermissionTemplate(ctx context.Context, id, permTemplID int) (*Response, error)
SetPermissionTemplate assigns a permission template to a user via PATCH. This is a partial update; other user fields are untouched.
type UserCreateOpts ¶
type UserCreateOpts struct {
Username string
Password string
Fullname string
Email string
Description string
Active bool
PermTempl int
UseLdap bool
}
UserCreateOpts configures a user creation request.
type UserUpdateOpts ¶
type UserUpdateOpts struct {
Username string
Password string
Fullname string
Email string
Description string
Active *bool
PermTempl int
UseLdap *bool
}
UserUpdateOpts configures a user update request.
type Zone ¶
type Zone struct {
ID int
Name string
Type ZoneType
Masters string
Account string
Description string
SOASerial int
DNSSECSigned bool
}
Zone represents a DNS zone in Poweradmin.
func ZoneFromSchema ¶
type ZoneClient ¶
type ZoneClient struct {
// contains filtered or unexported fields
}
ZoneClient provides access to the zone-related Poweradmin API endpoints.
func (*ZoneClient) All ¶
func (z *ZoneClient) All(ctx context.Context) ([]*Zone, error)
All returns all [Zone]s across all pages.
func (*ZoneClient) Create ¶
func (z *ZoneClient) Create(ctx context.Context, opts ZoneCreateOpts) (int, *Response, error)
Create creates a new Zone and returns the new ID. Call ZoneClient.GetByID to fetch the full object.
func (*ZoneClient) GetByName ¶
GetByName returns a single Zone by its DNS name. Performs a list + linear search across all pages — no dedicated API endpoint exists.
func (*ZoneClient) List ¶
List returns one page of [Zone]s. Note: /v2/zones wraps the array under data.zones — unlike the other list endpoints in this API. The wrapper is unmarshalled here so callers see a plain slice.
func (*ZoneClient) RemoveOwner ¶
RemoveOwner removes a user from the zone's owners.
type ZoneCreateOpts ¶
type ZoneCreateOpts struct {
Name string
Type ZoneType
Masters string
Account string
Description string
Template string
}
ZoneCreateOpts configures a zone creation request.
type ZoneTemplate ¶
type ZoneTemplate struct {
ID int
Name string
Description string
Owner int
IsGlobal bool
ZonesLinked int
}
ZoneTemplate represents a Poweradmin zone template.
type ZoneTemplateClient ¶
type ZoneTemplateClient struct {
// contains filtered or unexported fields
}
ZoneTemplateClient provides access to the zone-template endpoints.
func (*ZoneTemplateClient) Create ¶
func (c *ZoneTemplateClient) Create(ctx context.Context, opts ZoneTemplateCreateOpts) (*ZoneTemplate, *Response, error)
Create creates a new ZoneTemplate.
func (*ZoneTemplateClient) CreateRecord ¶
func (c *ZoneTemplateClient) CreateRecord(ctx context.Context, templateID int, opts ZoneTemplateRecordOpts) (*ZoneTemplateRecord, *Response, error)
CreateRecord adds a record to a template.
func (*ZoneTemplateClient) Delete ¶
Delete deletes a ZoneTemplate.
func (*ZoneTemplateClient) DeleteRecord ¶
func (c *ZoneTemplateClient) DeleteRecord(ctx context.Context, templateID, recordID int) (*Response, error)
DeleteRecord removes a record from a template.
func (*ZoneTemplateClient) GetByID ¶
func (c *ZoneTemplateClient) GetByID(ctx context.Context, id int) (*ZoneTemplate, *Response, error)
GetByID returns a single ZoneTemplate.
func (*ZoneTemplateClient) GetByName ¶
func (c *ZoneTemplateClient) GetByName(ctx context.Context, name string) (*ZoneTemplate, *Response, error)
GetByName returns a single ZoneTemplate by name. The template endpoint is not paginated, so this is a single-page scan.
func (*ZoneTemplateClient) GetRecord ¶
func (c *ZoneTemplateClient) GetRecord(ctx context.Context, templateID, recordID int) (*ZoneTemplateRecord, *Response, error)
GetRecord returns a single template record.
func (*ZoneTemplateClient) List ¶
func (c *ZoneTemplateClient) List(ctx context.Context) ([]*ZoneTemplate, *Response, error)
List returns all [ZoneTemplate]s.
func (*ZoneTemplateClient) Records ¶
func (c *ZoneTemplateClient) Records(ctx context.Context, templateID int) ([]*ZoneTemplateRecord, *Response, error)
Records returns all records belonging to the template.
func (*ZoneTemplateClient) Update ¶
func (c *ZoneTemplateClient) Update(ctx context.Context, id int, opts ZoneTemplateUpdateOpts) (*ZoneTemplate, *Response, error)
Update updates an existing ZoneTemplate.
func (*ZoneTemplateClient) UpdateRecord ¶
func (c *ZoneTemplateClient) UpdateRecord(ctx context.Context, templateID, recordID int, opts ZoneTemplateRecordOpts) (*ZoneTemplateRecord, *Response, error)
UpdateRecord replaces a template record.
type ZoneTemplateCreateOpts ¶
ZoneTemplateCreateOpts configures a template creation request.
type ZoneTemplateRecord ¶
type ZoneTemplateRecord struct {
ID int
Name string
Type string
Content string
TTL int
Priority int
}
ZoneTemplateRecord is a record entry within a ZoneTemplate. Placeholders like [ZONE], [NS1], [SERIAL] are expanded at zone creation time.
type ZoneTemplateRecordOpts ¶
ZoneTemplateRecordOpts configures a template-record create/update.
type ZoneTemplateUpdateOpts ¶
ZoneTemplateUpdateOpts configures a template update.
Source Files
¶
- client.go
- client_options.go
- error.go
- generate.go
- group.go
- list_opts.go
- permission.go
- permission_template.go
- record.go
- response.go
- retry.go
- rrset.go
- schema_conv.go
- user.go
- version.go
- zone.go
- zone_template.go
- zz_group_client_iface.go
- zz_permission_client_iface.go
- zz_permission_template_client_iface.go
- zz_record_client_iface.go
- zz_rrset_client_iface.go
- zz_user_client_iface.go
- zz_zone_client_iface.go
- zz_zone_template_client_iface.go