More documentation cleanup

This commit is contained in:
Steven Bazyl 2012-09-28 16:11:17 -07:00
parent 4d3c1801b7
commit 4d441b0437
5 changed files with 77 additions and 9 deletions

View File

@ -24,9 +24,13 @@ module Google
# #
# @api private # @api private
class BatchedCallResponse class BatchedCallResponse
# @return [String] UUID of the call
attr_reader :call_id attr_reader :call_id
# @return [Integer] HTTP status code
attr_accessor :status attr_accessor :status
# @return [Hash] HTTP response headers
attr_accessor :headers attr_accessor :headers
# @return [String] HTTP response body
attr_accessor :body attr_accessor :body
## ##
@ -64,7 +68,9 @@ module Google
class BatchRequest < Request class BatchRequest < Request
BATCH_BOUNDARY = "-----------RubyApiBatchRequest".freeze BATCH_BOUNDARY = "-----------RubyApiBatchRequest".freeze
attr_reader :calls, :callbacks # @api private
# @return [Array<(String,Google::APIClient::Request,Proc)] List of API calls in the batch
attr_reader :calls
## ##
# Creates a new batch request. # Creates a new batch request.

View File

@ -36,6 +36,7 @@ module Google
# Resumable uploader. # Resumable uploader.
# #
class ResumableUpload < Request class ResumableUpload < Request
# @return [Fixnum] Max bytes to send in a single request
attr_accessor :chunk_size attr_accessor :chunk_size
## ##
@ -162,6 +163,10 @@ module Google
return Google::APIClient::Result.new(self, response) return Google::APIClient::Result.new(self, response)
end end
##
# Hashified verison of the API request
#
# @return [Hash]
def to_hash def to_hash
super.merge(:offset => @offset) super.merge(:offset => @offset)
end end

View File

@ -28,8 +28,20 @@ module Google
class Request class Request
MULTIPART_BOUNDARY = "-----------RubyApiMultipartPost".freeze MULTIPART_BOUNDARY = "-----------RubyApiMultipartPost".freeze
attr_reader :parameters, :headers, :api_method # @return [Hash] Request parameters
attr_accessor :connection, :media, :authorization, :authenticated, :body attr_reader :parameters
# @return [Hash] Additional HTTP headers
attr_reader :headers
# @return [Google::APIClient::Method] API method to invoke
attr_reader :api_method
# @return [Google::APIClient::UploadIO] File to upload
attr_accessor :media
# @return [#generated_authenticated_request] User credentials
attr_accessor :authorization
# @return [TrueClass,FalseClass] True if request should include credentials
attr_accessor :authenticated
# @return [#read, #to_str] Request body
attr_accessor :body
## ##
# Build a request # Build a request
@ -85,10 +97,14 @@ module Google
end end
end end
# @!attribute [r] upload_type
# @return [String] protocol used for upload
def upload_type def upload_type
return self.parameters['uploadType'] || self.parameters['upload_type'] return self.parameters['uploadType'] || self.parameters['upload_type']
end end
# @!attribute http_method
# @return [Symbol] HTTP method if invoking a URI
def http_method def http_method
return @http_method ||= self.api_method.http_method.to_s.downcase.to_sym return @http_method ||= self.api_method.http_method.to_s.downcase.to_sym
end end
@ -113,6 +129,8 @@ module Google
end end
end end
# @!attribute uri
# @return [Addressable::URI] URI to send request
def uri def uri
return @uri ||= self.api_method.generate_uri(self.parameters) return @uri ||= self.api_method.generate_uri(self.parameters)
end end
@ -122,6 +140,7 @@ module Google
@parameters.update(@uri.query_values) unless @uri.query_values.nil? @parameters.update(@uri.query_values) unless @uri.query_values.nil?
end end
# Transmits the request with the given connection # Transmits the request with the given connection
# #
# @api private # @api private
@ -314,6 +333,11 @@ module Google
end end
##
# Subclass of Request for backwards compatibility with pre-0.5.0 versions of the library
#
# @deprecated
# use {Google::APIClient::Request} instead
class Reference < Request class Reference < Request
end end
end end

View File

@ -33,8 +33,13 @@ module Google
@media_upload = reference if reference.kind_of?(ResumableUpload) @media_upload = reference if reference.kind_of?(ResumableUpload)
end end
# @return [Google::APIClient::Request] Original request object
attr_reader :request attr_reader :request
# @return [Faraday::Response] HTTP response
attr_reader :response attr_reader :response
# @!attribute [r] reference
# @return [Google::APIClient::Request] Original request object
# @deprecated See {#request}
alias_method :reference, :request # For compatibility with pre-beta clients alias_method :reference, :request # For compatibility with pre-beta clients
# @!attribute [r] status # @!attribute [r] status
@ -45,6 +50,8 @@ module Google
# @return [String] HTTP response body # @return [String] HTTP response body
def_delegators :@response, :status, :headers, :body def_delegators :@response, :status, :headers, :body
# @!attribute [r] resumable_upload
# @return [Google::APIClient::ResumableUpload] For resuming media uploads
def resumable_upload def resumable_upload
@media_upload ||= ( @media_upload ||= (
options = self.reference.to_hash.merge( options = self.reference.to_hash.merge(
@ -57,7 +64,7 @@ module Google
## ##
# Get the content type of the response # Get the content type of the response
# # @!attribute [r] media_type
# @return [String] # @return [String]
# Value of content-type header # Value of content-type header
def media_type def media_type
@ -70,6 +77,7 @@ module Google
## ##
# Check if request failed # Check if request failed
# #
# @!attribute [r] error?
# @return [TrueClass, FalseClass] # @return [TrueClass, FalseClass]
# true if result of operation is an error # true if result of operation is an error
def error? def error?
@ -79,6 +87,7 @@ module Google
## ##
# Check if request was successful # Check if request was successful
# #
# @!attribute [r] success?
# @return [TrueClass, FalseClass] # @return [TrueClass, FalseClass]
# true if result of operation was successful # true if result of operation was successful
def success? def success?
@ -88,6 +97,7 @@ module Google
## ##
# Extracts error messages from the response body # Extracts error messages from the response body
# #
# @!attribute [r] error_message
# @return [String] # @return [String]
# error message, if available # error message, if available
def error_message def error_message
@ -107,6 +117,7 @@ module Google
## ##
# Check for parsable data in response # Check for parsable data in response
# #
# @!attribute [r] data?
# @return [TrueClass, FalseClass] # @return [TrueClass, FalseClass]
# true if body can be parsed # true if body can be parsed
def data? def data?
@ -116,6 +127,7 @@ module Google
## ##
# Return parsed version of the response body. # Return parsed version of the response body.
# #
# @!attribute [r] data
# @return [Object, Hash, String] # @return [Object, Hash, String]
# Object if body parsable from API schema, Hash if JSON, raw body if unable to parse # Object if body parsable from API schema, Hash if JSON, raw body if unable to parse
def data def data
@ -147,6 +159,7 @@ module Google
## ##
# Get the token used for requesting the next page of data # Get the token used for requesting the next page of data
# #
# @!attribute [r] next_page_token
# @return [String] # @return [String]
# next page token # next page token
def next_page_token def next_page_token
@ -179,6 +192,7 @@ module Google
## ##
# Get the token used for requesting the previous page of data # Get the token used for requesting the previous page of data
# #
# @!attribute [r] prev_page_token
# @return [String] # @return [String]
# previous page token # previous page token
def prev_page_token def prev_page_token
@ -208,10 +222,22 @@ module Google
) )
end end
##
# Pagination scheme used by this request/response
#
# @!attribute [r] pagination_type
# @return [Symbol]
# currently always :token
def pagination_type def pagination_type
return :token return :token
end end
##
# Name of the field that contains the pagination token
#
# @!attribute [r] page_token_param
# @return [String]
# currently always 'pageToken'
def page_token_param def page_token_param
return "pageToken" return "pageToken"
end end

View File

@ -65,8 +65,15 @@ module Google
# client.authorization = service_account.authorize # client.authorization = service_account.authorize
# client.execute(...) # client.execute(...)
class JWTAsserter class JWTAsserter
attr_accessor :issuer, :expiry, :skew # @return [String] ID/email of the issuing party
attr_accessor :issuer
# @return [Fixnum] How long, in seconds, the assertion is valid for
attr_accessor :expiry
# @return [Fixnum] Seconds to expand the issued at/expiry window to account for clock skew
attr_accessor :skew
# @return [String] Scopes to authorize
attr_reader :scope attr_reader :scope
# @return [OpenSSL::PKey] key for signing assertions
attr_writer :key attr_writer :key
## ##
@ -74,7 +81,7 @@ module Google
# #
# @param [String] issuer # @param [String] issuer
# Name/ID of the client issuing the assertion # Name/ID of the client issuing the assertion
# @param [String or Array] scope # @param [String, Array] scope
# Scopes to authorize. May be a space delimited string or array of strings # Scopes to authorize. May be a space delimited string or array of strings
# @param [OpenSSL::PKey] key # @param [OpenSSL::PKey] key
# RSA private key for signing assertions # RSA private key for signing assertions