parameters: (serviceName,
            version,
            http=None,
            discoveryServiceUrl=DISCOVERY_URI,
            developerKey=None,
            model=None,
            requestBuilder=HttpRequest)
return_statement: return build_from_document(content, discoveryServiceUrl, http=http,
        developerKey=developerKey, model=model, requestBuilder=requestBuilder)
docstring: Construct a Resource for interacting with an API.
  
    Construct a Resource object for interacting with an API. The serviceName and
    version are the names from the Discovery service.
  
    Args:
      serviceName: string, name of the service.
      version: string, the version of the service.
      http: httplib2.Http, An instance of httplib2.Http or something that acts
        like it that HTTP requests will be made through.
      discoveryServiceUrl: string, a URI Template that points to the location of
        the discovery service. It should have two parameters {api} and
        {apiVersion} that when filled in produce an absolute URI to the discovery
        document for that service.
      developerKey: string, key obtained from
        https://code.google.com/apis/console.
      model: apiclient.Model, converts to and from the wire format.
      requestBuilder: apiclient.http.HttpRequest, encapsulator for an HTTP
        request.
  
    Returns:
      A Resource object with methods for interacting with the service.
docstring_summary: Construct a Resource for interacting with an API.
docstring_tokens: Construct a Resource for interacting with an API .
function: def build(serviceName,
            version,
            http=None,
            discoveryServiceUrl=DISCOVERY_URI,
            developerKey=None,
            model=None,
            requestBuilder=HttpRequest):
    """Construct a Resource for interacting with an API.
  
    Construct a Resource object for interacting with an API. The serviceName and
    version are the names from the Discovery service.
  
    Args:
      serviceName: string, name of the service.
      version: string, the version of the service.
      http: httplib2.Http, An instance of httplib2.Http or something that acts
        like it that HTTP requests will be made through.
      discoveryServiceUrl: string, a URI Template that points to the location of
        the discovery service. It should have two parameters {api} and
        {apiVersion} that when filled in produce an absolute URI to the discovery
        document for that service.
      developerKey: string, key obtained from
        https://code.google.com/apis/console.
      model: apiclient.Model, converts to and from the wire format.
      requestBuilder: apiclient.http.HttpRequest, encapsulator for an HTTP
        request.
  
    Returns:
      A Resource object with methods for interacting with the service.
    """
    params = {
        'api': serviceName,
        'apiVersion': version
        }
  
    if http is None:
      http = httplib2.Http()
  
    requested_url = uritemplate.expand(discoveryServiceUrl, params)
  
    # REMOTE_ADDR is defined by the CGI spec [RFC3875] as the environment
    # variable that contains the network address of the client sending the
    # request. If it exists then add that to the request for the discovery
    # document to avoid exceeding the quota on discovery requests.
    if 'REMOTE_ADDR' in os.environ:
      requested_url = _add_query_parameter(requested_url, 'userIp',
                                           os.environ['REMOTE_ADDR'])
    logger.info('URL being requested: %s' % requested_url)
  
    resp, content = http.request(requested_url)
  
    if resp.status == 404:
      raise UnknownApiNameOrVersion("name: %s  version: %s" % (serviceName,
                                                              version))
    if resp.status >= 400:
      raise HttpError(resp, content, requested_url)
  
    try:
      service = simplejson.loads(content)
    except ValueError, e:
      logger.error('Failed to parse as JSON: ' + content)
      raise InvalidJsonError()
  
    return build_from_document(content, discoveryServiceUrl, http=http,
        developerKey=developerKey, model=model, requestBuilder=requestBuilder)
function_tokens: def build ( serviceName , version , http = None , discoveryServiceUrl = DISCOVERY_URI , developerKey = None , model = None , requestBuilder = HttpRequest ) : params = { 'api' : serviceName , 'apiVersion' : version } if http is None : http = httplib2 . Http ( ) requested_url = uritemplate . expand ( discoveryServiceUrl , params ) # REMOTE_ADDR is defined by the CGI spec [RFC3875] as the environment # variable that contains the network address of the client sending the # request. If it exists then add that to the request for the discovery # document to avoid exceeding the quota on discovery requests. if 'REMOTE_ADDR' in os . environ : requested_url = _add_query_parameter ( requested_url , 'userIp' , os . environ [ 'REMOTE_ADDR' ] ) logger . info ( 'URL being requested: %s' % requested_url ) resp , content = http . request ( requested_url ) if resp . status == 404 : raise UnknownApiNameOrVersion ( "name: %s  version: %s" % ( serviceName , version ) ) if resp . status >= 400 : raise HttpError ( resp , content , requested_url ) try : service = simplejson . loads ( content ) except ValueError , e : logger . error ( 'Failed to parse as JSON: ' + content ) raise InvalidJsonError ( ) return build_from_document ( content , discoveryServiceUrl , http = http , developerKey = developerKey , model = model , requestBuilder = requestBuilder )