Class: NgrokAPI::Services::ApplicationSessionsClient

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

Overview

Constant Summary collapse

PATH =

The API path for the requests

'/app/sessions/%{id}'
LIST_PROPERTY =

The List Property from the resulting API for list calls

'application_sessions'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ApplicationSessionsClient

Returns a new instance of ApplicationSessionsClient.



17
18
19
# File 'lib/ngrokapi/services/application_sessions_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/application_sessions_client.rb', line 15

def client
  @client
end

Instance Method Details

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

Delete an application session by ID.

https://ngrok.com/docs/api#api-application-sessions-delete

Parameters:

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

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



63
64
65
66
67
68
69
# File 'lib/ngrokapi/services/application_sessions_client.rb', line 63

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

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

Delete an application session by ID. Throws an exception if API error.

https://ngrok.com/docs/api#api-application-sessions-delete

Parameters:

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

    a resource identifier

Returns:

  • (NgrokAPI::Models::Empty)

    result from the API request



79
80
81
82
83
84
85
# File 'lib/ngrokapi/services/application_sessions_client.rb', line 79

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

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

Parameters:

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

    a resource identifier

Returns:



28
29
30
31
32
33
34
35
36
# File 'lib/ngrokapi/services/application_sessions_client.rb', line 28

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

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

Get an application session by ID. Throws an exception if API error.

https://ngrok.com/docs/api#api-application-sessions-get

Parameters:

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

    a resource identifier

Returns:



46
47
48
49
50
51
52
53
54
# File 'lib/ngrokapi/services/application_sessions_client.rb', line 46

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

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

List all application sessions for this account.

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



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/ngrokapi/services/application_sessions_client.rb', line 96

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

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

List all application sessions for this account. Throws an exception if API error.

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



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/ngrokapi/services/application_sessions_client.rb', line 122

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