code: def fetch_service_config(service_name=None, service_version=None):
      
      if not service_name:
          service_name = _get_env_var_or_raise(_SERVICE_NAME_ENV_KEY)
      if not service_version:
          service_version = _get_service_version(_SERVICE_VERSION_ENV_KEY,
                                                 service_name)
  
      _logger.debug(u'Contacting Service Management API for service %s version %s',
                    service_name, service_version)
      response = _make_service_config_request(service_name, service_version)
      _logger.debug(u'obtained service json from the management api:\n%s', response.data)
      service = encoding.JsonToMessage(messages.Service, response.data)
      _validate_service_config(service, service_name, service_version)
      return service
docs: Fetches the service config from Google Service Management API.
  
      Args:
        service_name: the service name. When this argument is unspecified, this
          method uses the value of the "SERVICE_NAME" environment variable as the
          service name, and raises ValueError if the environment variable is unset.
        service_version: the service version. When this argument is unspecified,
          this method uses the value of the "SERVICE_VERSION" environment variable
          as the service version, and raises ValueError if the environment variable
          is unset.
  
      Returns: the fetched service config JSON object.
  
      Raises:
        ValueError: when the service name/version is neither provided as an
          argument or set as an environment variable; or when the fetched service
          config fails validation.
        Exception: when the Google Service Management API returns non-200 response.