class Twilio::REST::Accounts::V1::CredentialList::PublicKeyList

Public Class Methods

new(version) click to toggle source

Initialize the PublicKeyList @param [Version] version Version that contains the resource @return [PublicKeyList] PublicKeyList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb
19 def initialize(version)
20   super(version)
21 
22   # Path Solution
23   @solution = {}
24   @uri = "/Credentials/PublicKeys"
25 end

Public Instance Methods

create(public_key: nil, friendly_name: :unset, account_sid: :unset) click to toggle source

Create the PublicKeyInstance @param [String] public_key A URL encoded representation of the public key. For

example, `-----BEGIN PUBLIC KEY-----MIIBIjANB.pa9xQIDAQAB-----END PUBLIC
KEY-----`

@param [String] friendly_name A descriptive string that you create to describe

the resource. It can be up to 64 characters long.

@param [String] account_sid The SID of the Subaccount that this Credential

should be associated with. Must be a valid Subaccount of the account issuing the
request

@return [PublicKeyInstance] Created PublicKeyInstance

    # File lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb
118 def create(public_key: nil, friendly_name: :unset, account_sid: :unset)
119   data = Twilio::Values.of({
120       'PublicKey' => public_key,
121       'FriendlyName' => friendly_name,
122       'AccountSid' => account_sid,
123   })
124 
125   payload = @version.create('POST', @uri, data: data)
126 
127   PublicKeyInstance.new(@version, payload, )
128 end
each() { |x| ... } click to toggle source

When passed a block, yields PublicKeyInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

   # File lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb
65 def each
66   limits = @version.read_limits
67 
68   page = self.page(page_size: limits[:page_size], )
69 
70   @version.stream(page,
71                   limit: limits[:limit],
72                   page_limit: limits[:page_limit]).each {|x| yield x}
73 end
get_page(target_url) click to toggle source

Retrieve a single page of PublicKeyInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of PublicKeyInstance

    # File lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb
 99 def get_page(target_url)
100   response = @version.domain.request(
101       'GET',
102       target_url
103   )
104   PublicKeyPage.new(@version, response, @solution)
105 end
list(limit: nil, page_size: nil) click to toggle source

Lists PublicKeyInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records.  If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Array] Array of up to limit results

   # File lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb
38 def list(limit: nil, page_size: nil)
39   self.stream(limit: limit, page_size: page_size).entries
40 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of PublicKeyInstance records from the API. Request is executed immediately. @param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of PublicKeyInstance

   # File lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb
82 def page(page_token: :unset, page_number: :unset, page_size: :unset)
83   params = Twilio::Values.of({
84       'PageToken' => page_token,
85       'Page' => page_number,
86       'PageSize' => page_size,
87   })
88 
89   response = @version.page('GET', @uri, params: params)
90 
91   PublicKeyPage.new(@version, response, @solution)
92 end
stream(limit: nil, page_size: nil) click to toggle source

Streams PublicKeyInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Enumerable] Enumerable that will yield up to limit results

   # File lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb
53 def stream(limit: nil, page_size: nil)
54   limits = @version.read_limits(limit, page_size)
55 
56   page = self.page(page_size: limits[:page_size], )
57 
58   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
59 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/accounts/v1/credential/public_key.rb
132 def to_s
133   '#<Twilio.Accounts.V1.PublicKeyList>'
134 end