Class: Twilio::REST::PreviewIam::Versionless::OrganizationContext::UserList
- Inherits:
-
ListResource
- Object
- ListResource
- Twilio::REST::PreviewIam::Versionless::OrganizationContext::UserList
- Defined in:
- lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb
Defined Under Namespace
Classes: ScimUser
Instance Method Summary collapse
-
#create(scim_user: nil) ⇒ UserInstance
Create the UserInstance.
-
#each ⇒ Object
When passed a block, yields UserInstance records from the API.
-
#get_page(target_url) ⇒ Page
Retrieve a single page of UserInstance records from the API.
-
#initialize(version, organization_sid: nil) ⇒ UserList
constructor
Initialize the UserList.
-
#list(filter: :unset, limit: nil, page_size: nil) ⇒ Array
Lists UserInstance records from the API as a list.
-
#page(filter: :unset, page_token: :unset, page_number: :unset, page_size: :unset) ⇒ Page
Retrieve a single page of UserInstance records from the API.
-
#stream(filter: :unset, limit: nil, page_size: nil) ⇒ Enumerable
Streams Instance records from the API as an Enumerable.
-
#to_s ⇒ Object
Provide a user friendly representation.
Constructor Details
#initialize(version, organization_sid: nil) ⇒ UserList
Initialize the UserList
87 88 89 90 91 92 93 |
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 87 def initialize(version, organization_sid: nil) super(version) # Path Solution @solution = { organization_sid: organization_sid } @uri = "/#{@solution[:organization_sid]}/scim/Users" end |
Instance Method Details
#create(scim_user: nil) ⇒ UserInstance
Create the UserInstance
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 98 def create(scim_user: nil ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) headers['Content-Type'] = 'application/scim+json' headers['Accept'] = 'application/scim+json' payload = @version.create('POST', @uri, headers: headers, data: scim_user.to_json) UserInstance.new( @version, payload, organization_sid: @solution[:organization_sid], ) end |
#each ⇒ Object
When passed a block, yields UserInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
162 163 164 165 166 167 168 169 170 |
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 162 def each limits = @version.read_limits page = self.page(page_size: limits[:page_size], ) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]).each {|x| yield x} end |
#get_page(target_url) ⇒ Page
Retrieve a single page of UserInstance records from the API. Request is executed immediately.
201 202 203 204 205 206 207 |
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 201 def get_page(target_url) response = @version.domain.request( 'GET', target_url ) UserPage.new(@version, response, @solution) end |
#list(filter: :unset, limit: nil, page_size: nil) ⇒ Array
Lists UserInstance records from the API as a list. Unlike stream(), this operation is eager and will load ‘limit` records into memory before returning.
128 129 130 131 132 133 134 |
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 128 def list(filter: :unset, limit: nil, page_size: nil) self.stream( filter: filter, limit: limit, page_size: page_size ).entries end |
#page(filter: :unset, page_token: :unset, page_number: :unset, page_size: :unset) ⇒ Page
Retrieve a single page of UserInstance records from the API. Request is executed immediately.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 180 def page(filter: :unset, page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ 'filter' => filter, 'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, }) headers = Twilio::Values.of({}) headers['Accept'] = 'application/scim+json' response = @version.page('GET', @uri, params: params, headers: headers) UserPage.new(@version, response, @solution) end |
#stream(filter: :unset, limit: nil, page_size: nil) ⇒ Enumerable
Streams Instance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached.
148 149 150 151 152 153 154 155 156 |
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 148 def stream(filter: :unset, limit: nil, page_size: nil) limits = @version.read_limits(limit, page_size) page = self.page( filter: filter, page_size: limits[:page_size], ) @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) end |
#to_s ⇒ Object
Provide a user friendly representation
212 213 214 |
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 212 def to_s '#<Twilio.PreviewIam.Versionless.UserList>' end |