Class: NgrokAPI::Services::SSHUserCertificatesClient

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

Overview

SSH User Certificates are presented by SSH clients when connecting to an SSH server to authenticate their connection. The SSH server must trust the SSH Certificate Authority used to sign the certificate.

https://ngrok.com/docs/api#api-ssh-user-certificates

Constant Summary collapse

PATH =

The API path for the requests

'/ssh_user_certificates'
LIST_PROPERTY =

The List Property from the resulting API for list calls

'ssh_user_certificates'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ SSHUserCertificatesClient

Returns a new instance of SSHUserCertificatesClient.



21
22
23
# File 'lib/ngrokapi/services/ssh_user_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_user_certificates_client.rb', line 19

def client
  @client
end

Instance Method Details

#create(ssh_certificate_authority_id:, public_key:, principals: [], critical_options: {}, extensions: {}, valid_after: "", valid_until: "", description: "", metadata: "") ⇒ NgrokAPI::Models::SSHUserCertificate

Parameters:

  • ssh_certificate_authority_id (string)

    the ssh certificate authority that is used to sign this ssh user 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 user certificate. This is the list of usernames that the certificate holder may sign in as on a machine authorizing the signing certificate authority. Dangerously, if no principals are specified, this certificate may be used to log in as any user.

  • critical_options (Map<string, string>) (defaults to: {})

    A map of critical options included in the certificate. Only two critical options are currently defined by OpenSSH: force-command and source-address. See the OpenSSH certificate protocol spec <https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.certkeys>_ for additional details.

  • extensions (Map<string, string>) (defaults to: {})

    A map of extensions included in the certificate. Extensions are additional metadata that can be interpreted by the SSH server for any purpose. These can be used to permit or deny the ability to open a terminal, do port forwarding, x11 forwarding, and more. If unspecified, the certificate will include limited permissions with the following extension map: {"permit-pty": "", "permit-user-rc": ""} OpenSSH understands a number of predefined extensions. See the OpenSSH certificate protocol spec <https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.certkeys>_ for additional details.

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

    The time when the user 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 24 hours will be used. The OpenSSH certificates RFC calls this valid_before.

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

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

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

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

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 40

def create(ssh_certificate_authority_id:, public_key:, principals: [], critical_options: {}, extensions: {}, valid_after: "", valid_until: "", description: "", metadata: "")
  path = '/ssh_user_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[:critical_options] = critical_options if critical_options
  data[:extensions] = extensions if extensions
  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::SSHUserCertificate.new(client: self, attrs: result)
end

#create!(ssh_certificate_authority_id:, public_key:, principals: [], critical_options: {}, extensions: {}, valid_after: "", valid_until: "", description: "", metadata: "") ⇒ NgrokAPI::Models::SSHUserCertificate

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

https://ngrok.com/docs/api#api-ssh-user-certificates-create

Parameters:

  • ssh_certificate_authority_id (string)

    the ssh certificate authority that is used to sign this ssh user 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 user certificate. This is the list of usernames that the certificate holder may sign in as on a machine authorizing the signing certificate authority. Dangerously, if no principals are specified, this certificate may be used to log in as any user.

  • critical_options (Map<string, string>) (defaults to: {})

    A map of critical options included in the certificate. Only two critical options are currently defined by OpenSSH: force-command and source-address. See the OpenSSH certificate protocol spec <https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.certkeys>_ for additional details.

  • extensions (Map<string, string>) (defaults to: {})

    A map of extensions included in the certificate. Extensions are additional metadata that can be interpreted by the SSH server for any purpose. These can be used to permit or deny the ability to open a terminal, do port forwarding, x11 forwarding, and more. If unspecified, the certificate will include limited permissions with the following extension map: {"permit-pty": "", "permit-user-rc": ""} OpenSSH understands a number of predefined extensions. See the OpenSSH certificate protocol spec <https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.certkeys>_ for additional details.

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

    The time when the user 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 24 hours will be used. The OpenSSH certificates RFC calls this valid_before.

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

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

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

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

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 74

def create!(ssh_certificate_authority_id:, public_key:, principals: [], critical_options: {}, extensions: {}, valid_after: "", valid_until: "", description: "", metadata: "")
  path = '/ssh_user_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[:critical_options] = critical_options if critical_options
  data[:extensions] = extensions if extensions
  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::SSHUserCertificate.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



99
100
101
102
103
104
105
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 99

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

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

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

https://ngrok.com/docs/api#api-ssh-user-certificates-delete

Parameters:

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

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



115
116
117
118
119
120
121
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 115

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

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

Get detailed information about an SSH User Certficate

https://ngrok.com/docs/api#api-ssh-user-certificates-get

Parameters:

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

    a resource identifier

Returns:



130
131
132
133
134
135
136
137
138
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 130

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

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

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

https://ngrok.com/docs/api#api-ssh-user-certificates-get

Parameters:

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

    a resource identifier

Returns:



148
149
150
151
152
153
154
155
156
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 148

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

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

List all SSH User Certificates issued on this account

https://ngrok.com/docs/api#api-ssh-user-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:



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 167

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::SSHUserCertificate
  )
end

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

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

https://ngrok.com/docs/api#api-ssh-user-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:



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 193

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::SSHUserCertificate,
    danger: true
  )
end

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

Parameters:

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

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

  • metadata (string) (defaults to: nil)

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

Returns:



220
221
222
223
224
225
226
227
228
229
230
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 220

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

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

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

https://ngrok.com/docs/api#api-ssh-user-certificates-update

Parameters:

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

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

  • metadata (string) (defaults to: nil)

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

Returns:



242
243
244
245
246
247
248
249
250
251
252
# File 'lib/ngrokapi/services/ssh_user_certificates_client.rb', line 242

def update!(id: "", description: nil, metadata: nil)
  path = '/ssh_user_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::SSHUserCertificate.new(client: self, attrs: result)
end