Class: NgrokAPI::Services::SSHHostCertificatesClient

Inherits:
Object
  • Object
show all
Defined in:
lib/ngrokapi/services/ssh_host_certificates_client.rb

Overview

SSH Host Certificates along with the corresponding private key allows an SSH server to assert its authenticity to connecting SSH clients who trust the SSH Certificate Authority that was used to sign the certificate.

ngrok.com/docs/api#api-ssh-host-certificates

Constant Summary collapse

PATH =

The API path for the requests

'/ssh_host_certificates'
LIST_PROPERTY =

The List Property from the resulting API for list calls

'ssh_host_certificates'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ SSHHostCertificatesClient

Returns a new instance of SSHHostCertificatesClient.



21
22
23
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 21

def initialize(client:)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



19
20
21
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 19

def client
  @client
end

Instance Method Details

#create(ssh_certificate_authority_id:, public_key:, principals: [], valid_after: "", valid_until: "", description: "", metadata: "") ⇒ NgrokAPI::Models::SSHHostCertificate

Create a new SSH Host Certificate

ngrok.com/docs/api#api-ssh-host-certificates-create

Parameters:

  • ssh_certificate_authority_id (string)

    the ssh certificate authority that is used to sign this ssh host certificate

  • public_key (string)

    a public key in OpenSSH Authorized Keys format that this certificate signs

  • principals (List<string>) (defaults to: [])

    the list of principals included in the ssh host certificate. This is the list of hostnames and/or IP addresses that are authorized to serve SSH traffic with this certificate. Dangerously, if no principals are specified, this certificate is considered valid for all hosts.

  • valid_after (datetime (RFC3339 string)) (defaults to: "")

    The time when the host certificate becomes valid, in RFC 3339 format. Defaults to the current time if unspecified.

  • valid_until (datetime (RFC3339 string)) (defaults to: "")

    The time when this host certificate becomes invalid, in RFC 3339 format. If unspecified, a default value of one year in the future will be used. The OpenSSH certificates RFC calls this valid_before.

  • description (string) (defaults to: "")

    human-readable description of this SSH Host Certificate. optional, max 255 bytes.

  • metadata (string) (defaults to: "")

    arbitrary user-defined machine-readable data of this SSH Host Certificate. optional, max 4096 bytes.

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 38

def create(ssh_certificate_authority_id:, public_key:, principals: [], valid_after: "", valid_until: "", description: "", metadata: "")
  path = '/ssh_host_certificates'
  replacements = {
  }
  data = {}
  data[:ssh_certificate_authority_id] = ssh_certificate_authority_id if ssh_certificate_authority_id
  data[:public_key] = public_key if public_key
  data[:principals] = principals if principals
  data[:valid_after] = valid_after if valid_after
  data[:valid_until] = valid_until if valid_until
  data[:description] = description if description
  data[:metadata] =  if 
  result = @client.post(path % replacements, data: data)
  NgrokAPI::Models::SSHHostCertificate.new(client: self, attrs: result)
end

#create!(ssh_certificate_authority_id:, public_key:, principals: [], valid_after: "", valid_until: "", description: "", metadata: "") ⇒ NgrokAPI::Models::SSHHostCertificate

Create a new SSH Host Certificate Throws an exception if API error.

ngrok.com/docs/api#api-ssh-host-certificates-create

Parameters:

  • ssh_certificate_authority_id (string)

    the ssh certificate authority that is used to sign this ssh host certificate

  • public_key (string)

    a public key in OpenSSH Authorized Keys format that this certificate signs

  • principals (List<string>) (defaults to: [])

    the list of principals included in the ssh host certificate. This is the list of hostnames and/or IP addresses that are authorized to serve SSH traffic with this certificate. Dangerously, if no principals are specified, this certificate is considered valid for all hosts.

  • valid_after (datetime (RFC3339 string)) (defaults to: "")

    The time when the host certificate becomes valid, in RFC 3339 format. Defaults to the current time if unspecified.

  • valid_until (datetime (RFC3339 string)) (defaults to: "")

    The time when this host certificate becomes invalid, in RFC 3339 format. If unspecified, a default value of one year in the future will be used. The OpenSSH certificates RFC calls this valid_before.

  • description (string) (defaults to: "")

    human-readable description of this SSH Host Certificate. optional, max 255 bytes.

  • metadata (string) (defaults to: "")

    arbitrary user-defined machine-readable data of this SSH Host Certificate. optional, max 4096 bytes.

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 68

def create!(ssh_certificate_authority_id:, public_key:, principals: [], valid_after: "", valid_until: "", description: "", metadata: "")
  path = '/ssh_host_certificates'
  replacements = {
  }
  data = {}
  data[:ssh_certificate_authority_id] = ssh_certificate_authority_id if ssh_certificate_authority_id
  data[:public_key] = public_key if public_key
  data[:principals] = principals if principals
  data[:valid_after] = valid_after if valid_after
  data[:valid_until] = valid_until if valid_until
  data[:description] = description if description
  data[:metadata] =  if 
  result = @client.post(path % replacements, data: data, danger: true)
  NgrokAPI::Models::SSHHostCertificate.new(client: self, attrs: result)
end

#delete(id: "") ⇒ NgrokAPI::Models::Empty

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



91
92
93
94
95
96
97
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 91

def delete(id: "")
  path = '/ssh_host_certificates/%{id}'
  replacements = {
    id: id,
  }
  @client.delete(path % replacements)
end

#delete!(id: "") ⇒ NgrokAPI::Models::Empty

Delete an SSH Host Certificate Throws an exception if API error.

ngrok.com/docs/api#api-ssh-host-certificates-delete

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



107
108
109
110
111
112
113
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 107

def delete!(id: "")
  path = '/ssh_host_certificates/%{id}'
  replacements = {
    id: id,
  }
  @client.delete(path % replacements, danger: true)
end

#get(id: "") ⇒ NgrokAPI::Models::SSHHostCertificate

Get detailed information about an SSH Host Certficate

ngrok.com/docs/api#api-ssh-host-certificates-get

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:



122
123
124
125
126
127
128
129
130
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 122

def get(id: "")
  path = '/ssh_host_certificates/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  result = @client.get(path % replacements, data: data)
  NgrokAPI::Models::SSHHostCertificate.new(client: self, attrs: result)
end

#get!(id: "") ⇒ NgrokAPI::Models::SSHHostCertificate

Get detailed information about an SSH Host Certficate Throws an exception if API error.

ngrok.com/docs/api#api-ssh-host-certificates-get

Parameters:

  • id (string) (defaults to: "")

    a resource identifier

Returns:



140
141
142
143
144
145
146
147
148
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 140

def get!(id: "")
  path = '/ssh_host_certificates/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  result = @client.get(path % replacements, data: data, danger: true)
  NgrokAPI::Models::SSHHostCertificate.new(client: self, attrs: result)
end

#list(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable

List all SSH Host Certificates issued on this account

ngrok.com/docs/api#api-ssh-host-certificates-list

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 159

def list(before_id: nil, limit: nil, url: nil)
  result = @client.list(
    before_id: before_id,
    limit: limit,
    url: url,
    path: PATH
  )

  NgrokAPI::Models::Listable.new(
    client: self,
    attrs: result,
    list_property: LIST_PROPERTY,
    klass: NgrokAPI::Models::SSHHostCertificate
  )
end

#list!(before_id: nil, limit: nil, url: nil) ⇒ NgrokAPI::Models::Listable

List all SSH Host Certificates issued on this account Throws an exception if API error.

ngrok.com/docs/api#api-ssh-host-certificates-list

Parameters:

  • before_id (string) (defaults to: nil)
  • limit (string) (defaults to: nil)
  • url (string) (defaults to: nil)

    optional and mutually exclusive from before_id and limit

Returns:



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 185

def list!(before_id: nil, limit: nil, url: nil)
  result = @client.list(
    before_id: before_id,
    limit: limit,
    danger: true,
    url: url,
    path: PATH
  )

  NgrokAPI::Models::Listable.new(
    client: self,
    attrs: result,
    list_property: LIST_PROPERTY,
    klass: NgrokAPI::Models::SSHHostCertificate,
    danger: true
  )
end

#update(id: "", description: nil, metadata: nil) ⇒ NgrokAPI::Models::SSHHostCertificate

Parameters:

  • id (string) (defaults to: "")
  • description (string) (defaults to: nil)

    human-readable description of this SSH Host Certificate. optional, max 255 bytes.

  • metadata (string) (defaults to: nil)

    arbitrary user-defined machine-readable data of this SSH Host Certificate. optional, max 4096 bytes.

Returns:



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 212

def update(id: "", description: nil, metadata: nil)
  path = '/ssh_host_certificates/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  data[:description] = description if description
  data[:metadata] =  if 
  result = @client.patch(path % replacements, data: data)
  NgrokAPI::Models::SSHHostCertificate.new(client: self, attrs: result)
end

#update!(id: "", description: nil, metadata: nil) ⇒ NgrokAPI::Models::SSHHostCertificate

Update an SSH Host Certificate Throws an exception if API error.

ngrok.com/docs/api#api-ssh-host-certificates-update

Parameters:

  • id (string) (defaults to: "")
  • description (string) (defaults to: nil)

    human-readable description of this SSH Host Certificate. optional, max 255 bytes.

  • metadata (string) (defaults to: nil)

    arbitrary user-defined machine-readable data of this SSH Host Certificate. optional, max 4096 bytes.

Returns:



234
235
236
237
238
239
240
241
242
243
244
# File 'lib/ngrokapi/services/ssh_host_certificates_client.rb', line 234

def update!(id: "", description: nil, metadata: nil)
  path = '/ssh_host_certificates/%{id}'
  replacements = {
    id: id,
  }
  data = {}
  data[:description] = description if description
  data[:metadata] =  if 
  result = @client.patch(path % replacements, data: data, danger: true)
  NgrokAPI::Models::SSHHostCertificate.new(client: self, attrs: result)
end