Class: NgrokAPI::Models::IPPolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/ngrokapi/models/ip_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: nil, attrs: {}) ⇒ IPPolicy

Returns a new instance of IPPolicy.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ngrokapi/models/ip_policy.rb', line 18

def initialize(client: nil, attrs: {})
  @client = client
  @attrs = attrs
  @id = @attrs['id']
  unless @attrs['uri'].nil?
    @uri = URI(@attrs['uri'])
  end
  @created_at = @attrs['created_at']
  @description = @attrs['description']
  @metadata = @attrs['metadata']
end

Instance Attribute Details

#attrsObject (readonly)

Returns the value of attribute attrs.



10
11
12
# File 'lib/ngrokapi/models/ip_policy.rb', line 10

def attrs
  @attrs
end

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/ngrokapi/models/ip_policy.rb', line 10

def client
  @client
end

#created_atObject (readonly)

Returns the value of attribute created_at.



10
11
12
# File 'lib/ngrokapi/models/ip_policy.rb', line 10

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



10
11
12
# File 'lib/ngrokapi/models/ip_policy.rb', line 10

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/ngrokapi/models/ip_policy.rb', line 10

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



10
11
12
# File 'lib/ngrokapi/models/ip_policy.rb', line 10

def 
  @metadata
end

#uriObject (readonly)

Returns the value of attribute uri.



10
11
12
# File 'lib/ngrokapi/models/ip_policy.rb', line 10

def uri
  @uri
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/ngrokapi/models/ip_policy.rb', line 30

def ==(other)
  @attrs == other.attrs
end

#deleteObject

Delete an IP policy. If the IP policy is referenced by another object for the purposes of traffic restriction it will be treated as if the IP policy remains but has zero rules.

https://ngrok.com/docs/api#api-ip-policies-delete



48
49
50
51
52
# File 'lib/ngrokapi/models/ip_policy.rb', line 48

def delete
  @client.delete(
    id: @id
  )
end

#to_hObject



38
39
40
# File 'lib/ngrokapi/models/ip_policy.rb', line 38

def to_h
  @attrs.to_h
end

#to_sObject



34
35
36
# File 'lib/ngrokapi/models/ip_policy.rb', line 34

def to_s
  @attrs.to_s
end

#update(description: nil, metadata: nil) ⇒ Object

Update attributes of an IP policy by ID

https://ngrok.com/docs/api#api-ip-policies-update



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ngrokapi/models/ip_policy.rb', line 58

def update(
  description: nil,
  metadata: nil
)
  @description = description if description
  @metadata =  if 
  @client.update(
    id: @id,
    description: description,
    metadata: 
  )
end