docs: def json_call(cls, method, url, **kwargs):
          """ Call a remote api using json format """
          # retrieve api key if needed
          empty_key = kwargs.pop('empty_key', False)
          send_key = kwargs.pop('send_key', True)
          return_header = kwargs.pop('return_header', False)
          try:
              apikey = cls.get('apirest.key')
              if not apikey and not empty_key:
                  cls.echo("No apikey found for REST API, please use "
                           "'gandi setup' command")
                  sys.exit(1)
              if send_key:
                  if 'headers' in kwargs:
                      kwargs['headers'].update({'X-Api-Key': apikey})
                  else:
                      kwargs['headers'] = {'X-Api-Key': apikey}
          except MissingConfiguration:
              if not empty_key:
                  return []
          # make the call
          cls.debug('calling url: %s %s' % (method, url))
          cls.debug('with params: %r' % kwargs)
          try:
              resp, resp_headers = JsonClient.request(method, url, **kwargs)
              cls.dump('responded: %r' % resp)
              if return_header:
                  return resp, resp_headers
              return resp
          except APICallFailed as err:
              cls.echo('An error occured during call: %s' % err.errors)
              sys.exit(1)