Sha256: 8a5c3443fe143ae466558af1f3152bf6e201e27f61df48a0994b64dbe4407375

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module NgrokAPI
  module Models
    class IPPolicy
      attr_reader :client,
        :result,
        :id,
        :uri,
        :created_at,
        :description,
        :metadata,
        :action

      def initialize(client:, result:)
        @client = client
        @result = result
        @id = @result['id']
        @uri = @result['uri']
        @created_at = @result['created_at']
        @description = @result['description']
        @metadata = @result['metadata']
        @action = @result['action']
      end

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

      def to_s
        @result.to_s
      end

      ##
      # 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
      def delete
        @client.delete(
          id: @id
        )
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ngrok-api-0.18.0 lib/ngrokapi/models/ip_policy.rb
ngrok-api-0.17.0 lib/ngrokapi/models/ip_policy.rb
ngrok-api-0.16.0 lib/ngrokapi/models/ip_policy.rb
ngrok-api-0.15.0 lib/ngrokapi/models/ip_policy.rb
ngrok-api-0.14.0 lib/ngrokapi/models/ip_policy.rb
ngrok-api-0.12.0 lib/ngrokapi/models/ip_policy.rb