code: async def add_relation(self, relation1, relation2):
          
          connection = self.connection()
          app_facade = client.ApplicationFacade.from_connection(connection)
  
          log.debug(
              'Adding relation %s <-> %s', relation1, relation2)
  
          def _find_relation(*specs):
              for rel in self.relations:
                  if rel.matches(*specs):
                      return rel
              return None
  
          try:
              result = await app_facade.AddRelation([relation1, relation2])
          except JujuAPIError as e:
              if 'relation already exists' not in e.message:
                  raise
              rel = _find_relation(relation1, relation2)
              if rel:
                  return rel
              raise JujuError('Relation {} {} exists but not in model'.format(
                  relation1, relation2))
  
          specs = ['{}:{}'.format(app, data['name'])
                   for app, data in result.endpoints.items()]
  
          await self.block_until(lambda: _find_relation(*specs) is not None)
          return _find_relation(*specs)
docs: Add a relation between two applications.
  
          :param str relation1: '<application>[:<relation_name>]'
          :param str relation2: '<application>[:<relation_name>]'