'Creates a new hidden service. Unlike
:func:`~stem.control.Controller.create_hidden_service` this style of
hidden service doesn\'t touch disk, carrying with it a lot of advantages.
This is the suggested method for making hidden services.
Our **ports** argument can be a single port...
create_ephemeral_hidden_service(80)
... list of ports the service is available on...
create_ephemeral_hidden_service([80, 443])
... or a mapping of hidden service ports to their targets...
create_ephemeral_hidden_service({80: 80, 443: \'173.194.33.133:443\'})
.. versionadded:: 1.4.0
:param int,list,dict ports: hidden service port(s) or mapping of hidden
service ports to their targets
:param str key_type: type of key being provided, generates a new key if
\'NEW\' (options are: **NEW** and **RSA1024**)
:param str key_content: key for the service to use or type of key to be
generated (options when **key_type** is **NEW** are **BEST** and
**RSA1024**)
:param bool discard_key: avoid providing the key back in our response
:param bool detached: continue this hidden service even after this control
connection is closed if **True**
:param bool await_publication: blocks until our descriptor is successfully
published if **True**
:returns: :class:`~stem.response.add_onion.AddOnionResponse` with the response
:raises: :class:`stem.ControllerError` if the call fails'

def create_ephemeral_hidden_service(self, ports, key_type='NEW', key_content='BEST', discard_key=False, detached=False, await_publication=False):

    if (self.get_version() < stem.version.Requirement.ADD_ONION):
        raise stem.UnsatisfiableRequest(message=('Ephemeral    hidden    services    were    added    in    tor    version    %s' % stem.version.Requirement.ADD_ONION))
    (hs_desc_queue, hs_desc_listener) = (queue.Queue(), None)
    if await_publication:
        def hs_desc_listener(event):
            hs_desc_queue.put(event)
        self.add_event_listener(hs_desc_listener, EventType.HS_DESC)
    request = ('ADD_ONION    %s:%s' % (key_type, key_content))
    flags = []
    if discard_key:
        flags.append('DiscardPK')
    if detached:
        flags.append('Detach')
    if flags:
        request += ('    Flags=%s' % ','.join(flags))
    if isinstance(ports, int):
        request += ('    Port=%s' % ports)
    elif isinstance(ports, list):
        for port in ports:
            request += ('    Port=%s' % port)
    elif isinstance(ports, dict):
        for (port, target) in ports.items():
            request += ('    Port=%s,%s' % (port, target))
    else:
        raise ValueError("The    'ports'    argument    of    create_ephemeral_hidden_service()    needs    to    be    an    int,    list,    or    dict")
    response = self.msg(request)
    stem.response.convert('ADD_ONION', response)
    if await_publication:
        (directories_uploaded_to, failures) = ([], [])
        try:
            while True:
                event = hs_desc_queue.get()
                if ((event.action == stem.HSDescAction.UPLOAD) and (event.address == response.service_id)):
                    directories_uploaded_to.append(event.directory_fingerprint)
                elif ((event.action == stem.HSDescAction.UPLOADED) and (event.directory_fingerprint in directories_uploaded_to)):
                    break
                elif ((event.action == stem.HSDescAction.FAILED) and (event.directory_fingerprint in directories_uploaded_to)):
                    failures.append(('%s    (%s)' % (event.directory_fingerprint, event.reason)))
                    if (len(directories_uploaded_to) == len(failures)):
                        raise stem.OperationFailed(message=('Failed    to    upload    our    hidden    service    descriptor    to    %s' % ',    '.join(failures)))
        finally:
            self.remove_event_listener(hs_desc_listener)
    return response
