Class: NgrokAPI::Services::TlsCertificatesClient

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

Overview

A client for interacting with the tls_certificates API

ngrok.com/docs/api#api-tls-certificates

Constant Summary collapse

LIST_PROPERTY =

The List Property from the resulting API for list calls

'tls_certificates'
PATH =

The API path for tls certificates

'/tls_certificates'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ TlsCertificatesClient

Returns a new instance of TlsCertificatesClient.



17
18
19
# File 'lib/ngrokapi/services/tls_certificates_client.rb', line 17

def initialize(client:)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



15
16
17
# File 'lib/ngrokapi/services/tls_certificates_client.rb', line 15

def client
  @client
end

Instance Method Details

#create(certificate_pem: '', description: '', metadata: '', private_key_pem: '') ⇒ NgrokAPI::Models::TlsCertificate

Upload a new TLS certificate.

ngrok.com/docs/api#api-tls-certificates-create

Parameters:

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

    human-readable description of this TLS certificate. optional, max 255 bytes.

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

    arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes.

  • certificate_pem (string) (defaults to: '')

    chain of PEM-encoded certificates, leaf first. See `Certificate Bundles` <(defaults to: '') —

    
    
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 33
    
    def create(
      certificate_pem: '',
      description: '',
      metadata: '',
      private_key_pem: ''
    )
      data = {
        certificate_pem: certificate_pem,
        description: description,
        metadata: ,
        private_key_pem: private_key_pem,
      }
      result = @client.post(PATH, data: data)
      NgrokAPI::Models::TlsCertificate.new(client: self, result: result)
    end

    #delete(id: nil) ⇒ nil

    Delete a TLS certificate by ID.

    ngrok.com/docs/api#api-tls-certificates-delete

    Parameters:

    • id (string) (defaults to: nil)

      a resource identifier

    Returns:

    • (nil)

      result from delete request

    
    
    57
    58
    59
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 57
    
    def delete(id: nil)
      @client.delete("#{PATH}/#{id}")
    end

    #delete!(id: nil) ⇒ nil

    Delete a TLS certificate by ID. Throw an exception if 404.

    ngrok.com/docs/api#api-tls-certificates-delete

    Parameters:

    • id (string) (defaults to: nil)

      a resource identifier

    Returns:

    • (nil)

      result from delete request

    
    
    68
    69
    70
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 68
    
    def delete!(id: nil)
      @client.delete("#{PATH}/#{id}", danger: true)
    end

    #get(id: nil) ⇒ NgrokAPI::Models::TlsCertificate

    Get detailed information about a TLS certificate by ID.

    ngrok.com/docs/api#api-tls-certificates-get

    Parameters:

    • id (string) (defaults to: nil)

      a resource identifier

    Returns:

    
    
    79
    80
    81
    82
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 79
    
    def get(id: nil)
      result = @client.get("#{PATH}/#{id}")
      NgrokAPI::Models::TlsCertificate.new(client: self, result: result)
    end

    #get!(id: nil) ⇒ NgrokAPI::Models::TlsCertificate

    Get detailed information about a TLS certificate by ID. Throw an exception if 404.

    ngrok.com/docs/api#api-tls-certificates-get

    Parameters:

    • id (string) (defaults to: nil)

      a resource identifier

    Returns:

    
    
    91
    92
    93
    94
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 91
    
    def get!(id: nil)
      result = @client.get("#{PATH}/#{id}", danger: true)
      NgrokAPI::Models::TlsCertificate.new(client: self, result: result)
    end

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

    List all TLS certificates on this account.

    ngrok.com/docs/api#api-tls-certificates-list

    Parameters:

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

      optional and mutually exclusive from before_id and limit

    Returns:

    
    
    105
    106
    107
    108
    109
    110
    111
    112
    113
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 105
    
    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,
        result: result,
        list_property: LIST_PROPERTY,
        klass: NgrokAPI::Models::TlsCertificate
      )
    end

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

    Update attributes of a TLS Certificate by ID.

    ngrok.com/docs/api#api-tls-certificates-update

    Parameters:

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

      human-readable description of this TLS certificate. optional, max 255 bytes.

    • metadata (string) (defaults to: nil)

      arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes.

    Returns:

    
    
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 126
    
    def update(
      id: nil,
      description: nil,
      metadata: nil
    )
      data = {}
      data[:description] = description if description
      data[:metadata] =  if 
      result = @client.patch("#{PATH}/#{id}", data: data)
      NgrokAPI::Models::TlsCertificate.new(client: self, result: result)
    end

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

    Update attributes of a TLS Certificate by ID. Throw an exception if 404.

    ngrok.com/docs/api#api-tls-certificates-update

    Parameters:

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

      human-readable description of this TLS certificate. optional, max 255 bytes.

    • metadata (string) (defaults to: nil)

      arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes.

    Returns:

    
    
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 147
    
    def update!(
      id: nil,
      description: nil,
      metadata: nil
    )
      data = {}
      data[:description] = description if description
      data[:metadata] =  if 
      result = @client.patch("#{PATH}/#{id}", danger: true, data: data)
      NgrokAPI::Models::TlsCertificate.new(client: self, result: result)
    end