lib/twilio-ruby/rest/microvisor/v1/device/device_secret.rb in twilio-ruby-5.77.0 vs lib/twilio-ruby/rest/microvisor/v1/device/device_secret.rb in twilio-ruby-6.0.0.pre.rc.1

- old
+ new

@@ -1,335 +1,368 @@ ## -# This code was generated by -# \ / _ _ _| _ _ -# | (_)\/(_)(_|\/| |(/_ v1.0.0 -# / / +# This code was generated by +# ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ +# | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ +# | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ # -# frozen_string_literal: true +# Twilio - Microvisor +# This is the public Twilio REST API. +# +# NOTE: This class is auto generated by OpenAPI Generator. +# https://openapi-generator.tech +# Do not edit the class manually. +# + module Twilio - module REST - class Microvisor < Domain - class V1 < Version - class DeviceContext < InstanceContext - ## - # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. - class DeviceSecretList < ListResource - ## - # Initialize the DeviceSecretList - # @param [Version] version Version that contains the resource - # @param [String] device_sid A 34-character string that uniquely identifies the - # parent Device. - # @return [DeviceSecretList] DeviceSecretList - def initialize(version, device_sid: nil) - super(version) + module REST + class Microvisor < MicrovisorBase + class V1 < Version + class DeviceContext < InstanceContext - # Path Solution - @solution = {device_sid: device_sid} - @uri = "/Devices/#{@solution[:device_sid]}/Secrets" - end + class DeviceSecretList < ListResource + ## + # Initialize the DeviceSecretList + # @param [Version] version Version that contains the resource + # @return [DeviceSecretList] DeviceSecretList + def initialize(version, device_sid: nil) + super(version) + # Path Solution + @solution = { device_sid: device_sid } + @uri = "/Devices/#{@solution[:device_sid]}/Secrets" + + end + ## + # Create the DeviceSecretInstance + # @param [String] key The secret key; up to 100 characters. + # @param [String] value The secret value; up to 4096 characters. + # @return [DeviceSecretInstance] Created DeviceSecretInstance + def create( + key: nil, + value: nil + ) - ## - # Lists DeviceSecretInstance 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 - def list(limit: nil, page_size: nil) - self.stream(limit: limit, page_size: page_size).entries - end + data = Twilio::Values.of({ + 'Key' => key, + 'Value' => value, + }) - ## - # Streams DeviceSecretInstance 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 - def stream(limit: nil, page_size: nil) - limits = @version.read_limits(limit, page_size) + payload = @version.create('POST', @uri, data: data) + DeviceSecretInstance.new( + @version, + payload, + device_sid: @solution[:device_sid], + ) + end - page = self.page(page_size: limits[:page_size], ) + + ## + # Lists DeviceSecretInstance 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 + def list(limit: nil, page_size: nil) + self.stream( + limit: limit, + page_size: page_size + ).entries + end - @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) - end + ## + # Streams Instance 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 + def stream(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) - ## - # When passed a block, yields DeviceSecretInstance records from the API. - # This operation lazily loads records as efficiently as possible until the limit - # is reached. - def each - limits = @version.read_limits + page = self.page( + page_size: limits[:page_size], ) - page = self.page(page_size: limits[:page_size], ) + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end - @version.stream(page, - limit: limits[:limit], - page_limit: limits[:page_limit]).each {|x| yield x} - end + ## + # When passed a block, yields DeviceSecretInstance records from the API. + # This operation lazily loads records as efficiently as possible until the limit + # is reached. + def each + limits = @version.read_limits - ## - # Retrieve a single page of DeviceSecretInstance 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 DeviceSecretInstance - def page(page_token: :unset, page_number: :unset, page_size: :unset) - params = Twilio::Values.of({ - 'PageToken' => page_token, - 'Page' => page_number, - 'PageSize' => page_size, - }) + page = self.page(page_size: limits[:page_size], ) - response = @version.page('GET', @uri, params: params) + @version.stream(page, + limit: limits[:limit], + page_limit: limits[:page_limit]).each {|x| yield x} + end - DeviceSecretPage.new(@version, response, @solution) - end + ## + # Retrieve a single page of DeviceSecretInstance 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 DeviceSecretInstance + def page(page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) - ## - # Retrieve a single page of DeviceSecretInstance records from the API. - # Request is executed immediately. - # @param [String] target_url API-generated URL for the requested results page - # @return [Page] Page of DeviceSecretInstance - def get_page(target_url) - response = @version.domain.request( - 'GET', - target_url - ) - DeviceSecretPage.new(@version, response, @solution) - end + response = @version.page('GET', @uri, params: params) - ## - # Create the DeviceSecretInstance - # @param [String] key The secret key; up to 100 characters. - # @param [String] value The secret value; up to 4096 characters. - # @return [DeviceSecretInstance] Created DeviceSecretInstance - def create(key: nil, value: nil) - data = Twilio::Values.of({'Key' => key, 'Value' => value, }) + DeviceSecretPage.new(@version, response, @solution) + end - payload = @version.create('POST', @uri, data: data) + ## + # Retrieve a single page of DeviceSecretInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of DeviceSecretInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + DeviceSecretPage.new(@version, response, @solution) + end + - DeviceSecretInstance.new(@version, payload, device_sid: @solution[:device_sid], ) - end - ## - # Provide a user friendly representation - def to_s - '#<Twilio.Microvisor.V1.DeviceSecretList>' - end - end + # Provide a user friendly representation + def to_s + '#<Twilio.Microvisor.V1.DeviceSecretList>' + end + end - ## - # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. - class DeviceSecretPage < Page - ## - # Initialize the DeviceSecretPage - # @param [Version] version Version that contains the resource - # @param [Response] response Response from the API - # @param [Hash] solution Path solution for the resource - # @return [DeviceSecretPage] DeviceSecretPage - def initialize(version, response, solution) - super(version, response) - # Path Solution - @solution = solution - end + ## + #PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. + class DeviceSecretContext < InstanceContext + ## + # Initialize the DeviceSecretContext + # @param [Version] version Version that contains the resource + # @param [String] device_sid A 34-character string that uniquely identifies the Device. + # @param [String] key The secret key; up to 100 characters. + # @return [DeviceSecretContext] DeviceSecretContext + def initialize(version, device_sid, key) + super(version) - ## - # Build an instance of DeviceSecretInstance - # @param [Hash] payload Payload response from the API - # @return [DeviceSecretInstance] DeviceSecretInstance - def get_instance(payload) - DeviceSecretInstance.new(@version, payload, device_sid: @solution[:device_sid], ) - end + # Path Solution + @solution = { device_sid: device_sid, key: key, } + @uri = "/Devices/#{@solution[:device_sid]}/Secrets/#{@solution[:key]}" - ## - # Provide a user friendly representation - def to_s - '<Twilio.Microvisor.V1.DeviceSecretPage>' - end - end + + end + ## + # Delete the DeviceSecretInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete - ## - # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. - class DeviceSecretContext < InstanceContext - ## - # Initialize the DeviceSecretContext - # @param [Version] version Version that contains the resource - # @param [String] device_sid A 34-character string that uniquely identifies the - # Device. - # @param [String] key The secret key; up to 100 characters. - # @return [DeviceSecretContext] DeviceSecretContext - def initialize(version, device_sid, key) - super(version) + @version.delete('DELETE', @uri) + end - # Path Solution - @solution = {device_sid: device_sid, key: key, } - @uri = "/Devices/#{@solution[:device_sid]}/Secrets/#{@solution[:key]}" - end + ## + # Fetch the DeviceSecretInstance + # @return [DeviceSecretInstance] Fetched DeviceSecretInstance + def fetch - ## - # Fetch the DeviceSecretInstance - # @return [DeviceSecretInstance] Fetched DeviceSecretInstance - def fetch - payload = @version.fetch('GET', @uri) + payload = @version.fetch('GET', @uri) + DeviceSecretInstance.new( + @version, + payload, + device_sid: @solution[:device_sid], + key: @solution[:key], + ) + end - DeviceSecretInstance.new( - @version, - payload, - device_sid: @solution[:device_sid], - key: @solution[:key], - ) - end + ## + # Update the DeviceSecretInstance + # @param [String] value The secret value; up to 4096 characters. + # @return [DeviceSecretInstance] Updated DeviceSecretInstance + def update( + value: nil + ) - ## - # Update the DeviceSecretInstance - # @param [String] value The secret value; up to 4096 characters. - # @return [DeviceSecretInstance] Updated DeviceSecretInstance - def update(value: nil) - data = Twilio::Values.of({'Value' => value, }) + data = Twilio::Values.of({ + 'Value' => value, + }) - payload = @version.update('POST', @uri, data: data) + payload = @version.update('POST', @uri, data: data) + DeviceSecretInstance.new( + @version, + payload, + device_sid: @solution[:device_sid], + key: @solution[:key], + ) + end - DeviceSecretInstance.new( - @version, - payload, - device_sid: @solution[:device_sid], - key: @solution[:key], - ) - end - ## - # Delete the DeviceSecretInstance - # @return [Boolean] true if delete succeeds, false otherwise - def delete - @version.delete('DELETE', @uri) - end + ## + # Provide a user friendly representation + def to_s + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#<Twilio.Microvisor.V1.DeviceSecretContext #{context}>" + end - ## - # Provide a user friendly representation - def to_s - context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') - "#<Twilio.Microvisor.V1.DeviceSecretContext #{context}>" - end + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#<Twilio.Microvisor.V1.DeviceSecretContext #{context}>" + end + end - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') - "#<Twilio.Microvisor.V1.DeviceSecretContext #{context}>" - end - end + class DeviceSecretPage < Page + ## + # Initialize the DeviceSecretPage + # @param [Version] version Version that contains the resource + # @param [Response] response Response from the API + # @param [Hash] solution Path solution for the resource + # @return [DeviceSecretPage] DeviceSecretPage + def initialize(version, response, solution) + super(version, response) - ## - # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. - class DeviceSecretInstance < InstanceResource - ## - # Initialize the DeviceSecretInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] device_sid A 34-character string that uniquely identifies the - # parent Device. - # @param [String] key The secret key; up to 100 characters. - # @return [DeviceSecretInstance] DeviceSecretInstance - def initialize(version, payload, device_sid: nil, key: nil) - super(version) + # Path Solution + @solution = solution + end - # Marshaled Properties - @properties = { - 'device_sid' => payload['device_sid'], - 'key' => payload['key'], - 'date_rotated' => Twilio.deserialize_iso8601_datetime(payload['date_rotated']), - 'url' => payload['url'], - } + ## + # Build an instance of DeviceSecretInstance + # @param [Hash] payload Payload response from the API + # @return [DeviceSecretInstance] DeviceSecretInstance + def get_instance(payload) + DeviceSecretInstance.new(@version, payload, device_sid: @solution[:device_sid]) + end - # Context - @instance_context = nil - @params = {'device_sid' => device_sid, 'key' => key || @properties['key'], } - end + ## + # Provide a user friendly representation + def to_s + '<Twilio.Microvisor.V1.DeviceSecretPage>' + end + end + class DeviceSecretInstance < InstanceResource + ## + # Initialize the DeviceSecretInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this DeviceSecret + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [DeviceSecretInstance] DeviceSecretInstance + def initialize(version, payload , device_sid: nil, key: nil) + super(version) + + # Marshaled Properties + @properties = { + 'device_sid' => payload['device_sid'], + 'key' => payload['key'], + 'date_rotated' => Twilio.deserialize_iso8601_datetime(payload['date_rotated']), + 'url' => payload['url'], + } - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [DeviceSecretContext] DeviceSecretContext for this DeviceSecretInstance - def context - unless @instance_context - @instance_context = DeviceSecretContext.new(@version, @params['device_sid'], @params['key'], ) - end - @instance_context - end + # Context + @instance_context = nil + @params = { 'device_sid' => device_sid || @properties['device_sid'] ,'key' => key || @properties['key'] , } + end - ## - # @return [String] A string that uniquely identifies the parent Device. - def device_sid - @properties['device_sid'] - end + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [DeviceSecretContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = DeviceSecretContext.new(@version , @params['device_sid'], @params['key']) + end + @instance_context + end + + ## + # @return [String] A 34-character string that uniquely identifies the parent Device. + def device_sid + @properties['device_sid'] + end + + ## + # @return [String] The secret key; up to 100 characters. + def key + @properties['key'] + end + + ## + # @return [Time] + def date_rotated + @properties['date_rotated'] + end + + ## + # @return [String] The absolute URL of the Secret. + def url + @properties['url'] + end + + ## + # Delete the DeviceSecretInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete - ## - # @return [String] The secret key. - def key - @properties['key'] - end + context.delete + end - ## - # @return [Time] The date_rotated - def date_rotated - @properties['date_rotated'] - end + ## + # Fetch the DeviceSecretInstance + # @return [DeviceSecretInstance] Fetched DeviceSecretInstance + def fetch - ## - # @return [String] The absolute URL of the Secret. - def url - @properties['url'] - end + context.fetch + end - ## - # Fetch the DeviceSecretInstance - # @return [DeviceSecretInstance] Fetched DeviceSecretInstance - def fetch - context.fetch - end + ## + # Update the DeviceSecretInstance + # @param [String] value The secret value; up to 4096 characters. + # @return [DeviceSecretInstance] Updated DeviceSecretInstance + def update( + value: nil + ) - ## - # Update the DeviceSecretInstance - # @param [String] value The secret value; up to 4096 characters. - # @return [DeviceSecretInstance] Updated DeviceSecretInstance - def update(value: nil) - context.update(value: value, ) - end + context.update( + value: value, + ) + end - ## - # Delete the DeviceSecretInstance - # @return [Boolean] true if delete succeeds, false otherwise - def delete - context.delete - end + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "<Twilio.Microvisor.V1.DeviceSecretInstance #{values}>" + end - ## - # Provide a user friendly representation - def to_s - values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "<Twilio.Microvisor.V1.DeviceSecretInstance #{values}>" - end + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "<Twilio.Microvisor.V1.DeviceSecretInstance #{values}>" + end + end - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") - "<Twilio.Microvisor.V1.DeviceSecretInstance #{values}>" + end end - end end - end end - end -end \ No newline at end of file +end + +