Sha256: 82ff1fb1dd37276cadfea50b3f8e0cfcbda8e9b957582324bcedfe3601ba06df

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

# Code generated for API Clients. DO NOT EDIT.

require 'uri'

module NgrokAPI
  module Models
    class IPPolicyRule
      attr_reader :client,
        :attrs,
        :id,
        :uri,
        :created_at,
        :description,
        :metadata,
        :cidr,
        :ip_policy,
        :action

      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']
        @cidr = @attrs['cidr']
        @ip_policy = @attrs['ip_policy']
        @action = @attrs['action']
      end

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

      def to_s
        @attrs.to_s
      end

      def to_h
        @attrs.to_h
      end

      ##
      # Delete an IP policy rule.
      #
      # https://ngrok.com/docs/api#api-ip-policy-rules-delete
      def delete
        @client.delete(
          id: @id
        )
      end

      ##
      # Update attributes of an IP policy rule by ID
      #
      # https://ngrok.com/docs/api#api-ip-policy-rules-update
      def update(
        description: nil,
        metadata: nil,
        cidr: nil
      )
        @description = description if description
        @metadata = metadata if metadata
        @cidr = cidr if cidr
        @client.update(
          id: @id,
          description: description,
          metadata: metadata,
          cidr: cidr
        )
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ngrok-api-0.24.0 lib/ngrokapi/models/ip_policy_rule.rb
ngrok-api-0.23.0 lib/ngrokapi/models/ip_policy_rule.rb
ngrok-api-0.22.0 lib/ngrokapi/models/ip_policy_rule.rb
ngrok-api-0.21.0 lib/ngrokapi/models/ip_policy_rule.rb