Class: Telnyx::Resources::WireguardPeers

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/wireguard_peers.rb

Overview

WireGuard Interface operations

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ WireguardPeers

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of WireguardPeers.

Parameters:



152
153
154
# File 'lib/telnyx/resources/wireguard_peers.rb', line 152

def initialize(client:)
  @client = client
end

Instance Method Details

#create(wireguard_interface_id:, request_options: {}) ⇒ Telnyx::Models::WireguardPeerCreateResponse

Create a new WireGuard Peer. Current limitation of 5 peers per interface can be created.

Parameters:

  • wireguard_interface_id (String)

    The id of the wireguard interface associated with the peer.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



19
20
21
22
23
24
25
26
27
28
# File 'lib/telnyx/resources/wireguard_peers.rb', line 19

def create(params)
  parsed, options = Telnyx::WireguardPeerCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "wireguard_peers",
    body: parsed,
    model: Telnyx::Models::WireguardPeerCreateResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ Telnyx::Models::WireguardPeerDeleteResponse

Delete the WireGuard peer.

Parameters:

  • id (String)

    Identifies the resource.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



119
120
121
122
123
124
125
126
# File 'lib/telnyx/resources/wireguard_peers.rb', line 119

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["wireguard_peers/%1$s", id],
    model: Telnyx::Models::WireguardPeerDeleteResponse,
    options: params[:request_options]
  )
end

#list(filter: nil, page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::WireguardPeerListResponse>

Some parameter documentations has been truncated, see Models::WireguardPeerListParams for more details.

List all WireGuard peers.

Parameters:

Returns:

See Also:



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/telnyx/resources/wireguard_peers.rb', line 95

def list(params = {})
  parsed, options = Telnyx::WireguardPeerListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "wireguard_peers",
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::Models::WireguardPeerListResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Telnyx::Models::WireguardPeerRetrieveResponse

Retrieve the WireGuard peer.

Parameters:

  • id (String)

    Identifies the resource.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



41
42
43
44
45
46
47
48
# File 'lib/telnyx/resources/wireguard_peers.rb', line 41

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["wireguard_peers/%1$s", id],
    model: Telnyx::Models::WireguardPeerRetrieveResponse,
    options: params[:request_options]
  )
end

#retrieve_config(id, request_options: {}) ⇒ String

Retrieve Wireguard config template for Peer

Parameters:

  • id (String)

    Identifies the resource.

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (String)

See Also:



139
140
141
142
143
144
145
146
147
# File 'lib/telnyx/resources/wireguard_peers.rb', line 139

def retrieve_config(id, params = {})
  @client.request(
    method: :get,
    path: ["wireguard_peers/%1$s/config", id],
    headers: {"accept" => "text/plain"},
    model: String,
    options: params[:request_options]
  )
end

#update(id, public_key: nil, request_options: {}) ⇒ Telnyx::Models::WireguardPeerUpdateResponse

Some parameter documentations has been truncated, see Models::WireguardPeerUpdateParams for more details.

Update the WireGuard peer.

Parameters:

  • id (String)

    Identifies the resource.

  • public_key (String)

    The WireGuard ‘PublicKey`.<br /><br />If you do not provide a Public Key, a new

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



66
67
68
69
70
71
72
73
74
75
# File 'lib/telnyx/resources/wireguard_peers.rb', line 66

def update(id, params = {})
  parsed, options = Telnyx::WireguardPeerUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["wireguard_peers/%1$s", id],
    body: parsed,
    model: Telnyx::Models::WireguardPeerUpdateResponse,
    options: options
  )
end