Class: Twilio::REST::Intelligence::V3::ConfigurationList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/intelligence/v3/configuration.rb

Defined Under Namespace

Classes: Action, Context, ContextKnowledge, ContextMemory, CreateConfigurationRequest, Operator, RuleCreationRequestPayload, RuleUpdateRequestPayload, Trigger, TriggerParameters, UpdateConfigurationRequest

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ ConfigurationList

Initialize the ConfigurationList

Parameters:

  • version (Version)

    Version that contains the resource



416
417
418
419
420
421
422
423
424
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 416

def initialize(version)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    # Path Solution
    @solution = {  }
    @uri = "/ControlPlane/Configurations"
    
end

Instance Method Details

#create(create_configuration_request: nil) ⇒ ConfigurationInstance

Create the ConfigurationInstance

Parameters:

Returns:



429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 429

def create(create_configuration_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.create('POST', @uri, headers: headers, data: create_configuration_request.to_json)
    ConfigurationInstance.new(
        @version,
        payload,
    )
end

#create_with_metadata(create_configuration_request: nil) ⇒ ConfigurationInstance

Create the ConfigurationInstanceMetadata

Parameters:

Returns:



449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 449

def (create_configuration_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('POST', @uri, headers: headers, data: create_configuration_request.to_json)
    configuration_instance = ConfigurationInstance.new(
        @version,
        response.body,
    )
    ConfigurationInstanceMetadata.new(
        @version,
        configuration_instance,
        response.headers,
        response.status_code
    )
end

#eachObject

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



546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 546

def each
    limits = @version.read_limits

    page = self.page(page_size: limits[:page_size], )

    return [].each if page.nil?

    result = @version.stream(page,
        limit: limits[:limit],
        page_limit: limits[:page_limit])
    return [].each if result.nil?
    result.each {|x| yield x}
end

#get_page(target_url) ⇒ Page

Retrieve a single page of ConfigurationInstance records from the API. Request is executed immediately.

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of ConfigurationInstance



585
586
587
588
589
590
591
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 585

def get_page(target_url)
    response = @version.domain.request(
        'GET',
        target_url
    )
ConfigurationPage.new(@version, response, @solution)
end

#list(page_token: :unset, limit: nil, page_size: nil) ⇒ Array

Lists ConfigurationInstance records from the API as a list. Unlike stream(), this operation is eager and will load ‘limit` records into memory before returning.

Parameters:

  • page_token (String) (defaults to: :unset)

    Token for pagination

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    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)

Returns:

  • (Array)

    Array of up to limit results



484
485
486
487
488
489
490
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 484

def list(page_token: :unset, limit: nil, page_size: nil)
    self.stream(
        page_token: page_token,
        limit: limit,
        page_size: page_size
    ).entries
end

#list_with_metadata(page_token: :unset, limit: nil, page_size: nil) ⇒ Array

Returns Array of up to limit results.

Parameters:

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    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)

Returns:

  • (Array)

    Array of up to limit results



528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 528

def (page_token: :unset, limit: nil, page_size: nil)
    limits = @version.read_limits(limit, page_size)
    params = Twilio::Values.of({
        'pageToken' => page_token,
        
        'PageSize' => limits[:page_size],
    });
    headers = Twilio::Values.of({})

    response = @version.page('GET', @uri, params: params, headers: headers)

    ConfigurationPageMetadata.new(@version, response, @solution, limits[:limit])
end

#page(page_token: :unset, page_size: :unset) ⇒ Page

Returns Page of ConfigurationInstance.

Returns:

  • (Page)

    Page of ConfigurationInstance



566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 566

def page(page_token: :unset, page_size: :unset)
    params = Twilio::Values.of({
        'pageToken' => page_token,
                                    'PageSize' => page_size,
    })
    headers = Twilio::Values.of({})
    
    

    response = @version.page('GET', @uri, params: params, headers: headers)

    ConfigurationPage.new(@version, response, @solution)
end

#stream(page_token: :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.

Parameters:

  • page_token (String) (defaults to: :unset)

    Token for pagination

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    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)

Returns:

  • (Enumerable)

    Enumerable that will yield up to limit results



504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 504

def stream(page_token: :unset, limit: nil, page_size: nil)
    limits = @version.read_limits(limit, page_size)

    page = self.page(
        page_token: page_token,
        page_size: limits[:page_size], )

    return [].each if page.nil?

    result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
    return [].each if result.nil?
    result
end

#to_sObject

Provide a user friendly representation



596
597
598
# File 'lib/twilio-ruby/rest/intelligence/v3/configuration.rb', line 596

def to_s
    '#<Twilio.Intelligence.V3.ConfigurationList>'
end