1 # Copyright 2010 Google Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 require 'addressable/uri'
17 require 'addressable/template'
19 require 'google/api_client/errors'
25 # Media upload elements for discovered methods
29 # Creates a description of a particular method.
31 # @param [Google::APIClient::API] api
32 # Base discovery document for the API
33 # @param [Addressable::URI] method_base
34 # The base URI for the service.
35 # @param [Hash] discovery_document
36 # The media upload section of the discovery document.
38 # @return [Google::APIClient::Method] The constructed method object.
39 def initialize(api, method_base, discovery_document)
41 @method_base = method_base
42 @discovery_document = discovery_document
46 # List of acceptable mime types
49 # List of acceptable mime types for uploaded content
51 @discovery_document['accept']
55 # Maximum size of an uplad
56 # TODO: Parse & convert to numeric value
60 @discovery_document['maxSize']
64 # Returns the URI template for the method. A parameter list can be
65 # used to expand this into a URI.
67 # @return [Addressable::Template] The URI template.
69 return @uri_template ||= Addressable::Template.new(
70 @api.method_base.join(Addressable::URI.parse(@discovery_document['protocols']['simple']['path']))