PrimaryIPsClient
- class PrimaryIPsClient(client: Client)[source]
- actions: ResourceActionsClient
Primary IPs scoped actions client
- Type:
- assign(primary_ip: PrimaryIP | BoundPrimaryIP, assignee_id: int, assignee_type: str = 'server') BoundAction[source]
Assigns a Primary IP to a assignee_id.
- Parameters:
primary_ip –
BoundPrimaryIPorPrimaryIPassignee_id – int Assignee the Primary IP shall be assigned to
assignee_type – str Assignee the Primary IP shall be assigned to
- Returns:
- change_dns_ptr(primary_ip: PrimaryIP | BoundPrimaryIP, ip: str, dns_ptr: str) BoundAction[source]
Changes the dns ptr that will appear when getting the dns ptr belonging to this Primary IP.
- Parameters:
primary_ip –
BoundPrimaryIPorPrimaryIPip – str The IP address for which to set the reverse DNS entry
dns_ptr – str Hostname to set as a reverse DNS PTR entry, will reset to original default value if None
- Returns:
- change_protection(primary_ip: PrimaryIP | BoundPrimaryIP, delete: bool | None = None) BoundAction[source]
Changes the protection configuration of the Primary IP.
- Parameters:
primary_ip –
BoundPrimaryIPorPrimaryIPdelete – boolean If true, prevents the Primary IP from being deleted
- Returns:
- create(type: str, name: str, datacenter: Datacenter | BoundDatacenter | None = None, location: Location | BoundLocation | None = None, assignee_type: str | None = None, assignee_id: int | None = None, auto_delete: bool | None = False, labels: dict[str, str] | None = None) CreatePrimaryIPResponse[source]
Creates a new Primary IP assigned to a server.
- Parameters:
type – str Primary IP type Choices: ipv4, ipv6
name – str
datacenter – Datacenter (optional)
location – Location (optional)
assignee_type – str (optional)
assignee_id – int (optional)
auto_delete – bool (optional)
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
- Returns:
CreatePrimaryIPResponse
- delete(primary_ip: PrimaryIP | BoundPrimaryIP) bool[source]
Deletes a Primary IP. If it is currently assigned to an assignee it will automatically get unassigned.
- Parameters:
primary_ip –
BoundPrimaryIPorPrimaryIP- Returns:
boolean
- get_actions(primary_ip: PrimaryIP | BoundPrimaryIP, status: list[Literal['running', 'success', 'error']] | None = None, sort: list[Literal['id', 'id:asc', 'id:desc', 'command', 'command:asc', 'command:desc', 'status', 'status:asc', 'status:desc', 'started', 'started:asc', 'started:desc', 'finished', 'finished:asc', 'finished:desc']] | None = None) list[BoundAction][source]
Returns all Actions for a Primary IP.
- Parameters:
primary_ip – Primary IP to get the Actions for.
status – Filter the Actions by status.
sort – Sort Actions by field and direction.
- get_actions_list(primary_ip: PrimaryIP | BoundPrimaryIP, status: list[Literal['running', 'success', 'error']] | None = None, sort: list[Literal['id', 'id:asc', 'id:desc', 'command', 'command:asc', 'command:desc', 'status', 'status:asc', 'status:desc', 'started', 'started:asc', 'started:desc', 'finished', 'finished:asc', 'finished:desc']] | None = None, page: int | None = None, per_page: int | None = None) ActionsPageResult[source]
Returns a paginated list of Actions for a Primary IP.
- Parameters:
primary_ip – Primary IP to get the Actions for.
status – Filter the Actions by status.
sort – Sort Actions by field and direction.
page – Page number to get.
per_page – Maximum number of Actions returned per page.
- get_all(label_selector: str | None = None, name: str | None = None) list[BoundPrimaryIP][source]
Get all primary ips from this account
- Parameters:
label_selector – str (optional) Can be used to filter Primary IPs by labels. The response will only contain Primary IPs matching the label selector.able values.
name – str (optional) Can be used to filter networks by their name.
- Returns:
List[
BoundPrimaryIP]
- get_by_id(id: int) BoundPrimaryIP[source]
Returns a specific Primary IP object.
- Parameters:
id – int
- Returns:
- get_by_name(name: str) BoundPrimaryIP | None[source]
Get Primary IP by name
- Parameters:
name – str Used to get Primary IP by name.
- Returns:
- get_list(label_selector: str | None = None, page: int | None = None, per_page: int | None = None, name: str | None = None, ip: str | None = None) PrimaryIPsPageResult[source]
Get a list of primary ips from this account
- Parameters:
label_selector – str (optional) Can be used to filter Primary IPs by labels. The response will only contain Primary IPs matching the label selectorable values.
page – int (optional) Specifies the page to fetch
per_page – int (optional) Specifies how many results are returned by page
name – str (optional) Can be used to filter networks by their name.
ip – str (optional) Can be used to filter resources by their ip. The response will only contain the resources matching the specified ip.
- Returns:
(List[
BoundPrimaryIP],Meta)
- unassign(primary_ip: PrimaryIP | BoundPrimaryIP) BoundAction[source]
Unassigns a Primary IP, resulting in it being unreachable. You may assign it to a server again at a later time.
- Parameters:
primary_ip –
BoundPrimaryIPorPrimaryIP- Returns:
- update(primary_ip: PrimaryIP | BoundPrimaryIP, auto_delete: bool | None = None, labels: dict[str, str] | None = None, name: str | None = None) BoundPrimaryIP[source]
Updates the name, auto_delete or labels of a Primary IP.
- Parameters:
primary_ip –
BoundPrimaryIPorPrimaryIPauto_delete – bool (optional) Delete this Primary IP when the resource it is assigned to is deleted
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
name – str (optional) New name to set
- Returns:
- class BoundPrimaryIP(client: PrimaryIPsClient, data: dict[str, Any], complete: bool = True)[source]
- assign(assignee_id: int, assignee_type: str) BoundAction[source]
Assigns a Primary IP to a assignee.
- Parameters:
assignee_id – int` Id of an assignee the Primary IP shall be assigned to
assignee_type – string` Assignee type (e.g server) the Primary IP shall be assigned to
- Returns:
- change_dns_ptr(ip: str, dns_ptr: str) BoundAction[source]
Changes the hostname that will appear when getting the hostname belonging to this Primary IP.
- Parameters:
ip – str The IP address for which to set the reverse DNS entry
dns_ptr – str Hostname to set as a reverse DNS PTR entry, will reset to original default value if None
- Returns:
- change_protection(delete: bool | None = None) BoundAction[source]
Changes the protection configuration of the Primary IP.
- Parameters:
delete – boolean If true, prevents the Primary IP from being deleted
- Returns:
- delete() bool[source]
Deletes a Primary IP. If it is currently assigned to a server it will automatically get unassigned.
- Returns:
boolean
- get_actions(status: list[Literal['running', 'success', 'error']] | None = None, sort: list[Literal['id', 'id:asc', 'id:desc', 'command', 'command:asc', 'command:desc', 'status', 'status:asc', 'status:desc', 'started', 'started:asc', 'started:desc', 'finished', 'finished:asc', 'finished:desc']] | None = None) list[BoundAction][source]
Returns all Actions for a Primary IP.
- Parameters:
status – Filter the Actions by status.
sort – Sort Actions by field and direction.
- get_actions_list(status: list[Literal['running', 'success', 'error']] | None = None, sort: list[Literal['id', 'id:asc', 'id:desc', 'command', 'command:asc', 'command:desc', 'status', 'status:asc', 'status:desc', 'started', 'started:asc', 'started:desc', 'finished', 'finished:asc', 'finished:desc']] | None = None, page: int | None = None, per_page: int | None = None) ActionsPageResult[source]
Returns a paginated list of Actions for a Primary IP.
- Parameters:
status – Filter the Actions by status.
sort – Sort Actions by field and direction.
page – Page number to get.
per_page – Maximum number of Actions returned per page.
- unassign() BoundAction[source]
Unassigns a Primary IP, resulting in it being unreachable. You may assign it to a server again at a later time.
- Returns:
- update(auto_delete: bool | None = None, labels: dict[str, str] | None = None, name: str | None = None) BoundPrimaryIP[source]
Updates the description or labels of a Primary IP.
- Parameters:
auto_delete – bool (optional) Auto delete IP when assignee gets deleted
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
name – str (optional) New Name to set
- Returns:
- class PrimaryIP(id: int | None = None, type: str | None = None, ip: str | None = None, dns_ptr: list[DNSPtr] | None = None, datacenter: BoundDatacenter | None = None, location: BoundLocation | None = None, blocked: bool | None = None, protection: PrimaryIPProtection | None = None, labels: dict[str, str] | None = None, created: str | None = None, name: str | None = None, assignee_id: int | None = None, assignee_type: str | None = None, auto_delete: bool | None = None)[source]
Primary IP Domain
- Parameters:
id – int ID of the Primary IP
ip – str IP address of the Primary IP
type – str Type of Primary IP. Choices: ipv4, ipv6
dns_ptr – List[Dict] Array of reverse DNS entries
datacenter –
DatacenterDatacenter the Primary IP was created in.This property is deprecated and will be removed after 1 July 2026. Please use the
locationproperty instead.See https://docs.hetzner.cloud/changelog#2025-12-16-phasing-out-datacenters.
location –
LocationLocation the Primary IP was created in.blocked – boolean Whether the IP is blocked
protection – dict Protection configuration for the Primary IP
labels – dict User-defined labels (key-value pairs)
created – datetime Point in time when the Primary IP was created
name – str Name of the Primary IP
assignee_id – int Assignee ID the Primary IP is assigned to
assignee_type – str Assignee Type of entity the Primary IP is assigned to
auto_delete – bool Delete the Primary IP when the Assignee it is assigned to is deleted.