@classmethod
def update_or_create(cls, external_gateway, name, with_status=False, **kw):
    """
        Update or create external endpoints for the specified external gateway.
        An ExternalEndpoint is considered unique based on the IP address for the
        endpoint (you cannot add two external endpoints with the same IP). If the
        external endpoint is dynamic, then the name is the unique identifier.
        
        :param ExternalGateway external_gateway: external gateway reference
        :param str name: name of the ExternalEndpoint. This is only used as
            a direct match if the endpoint is dynamic. Otherwise the address
            field in the keyword arguments will be used as you cannot add
            multiple external endpoints with the same IP address.
        :param bool with_status: If set to True, returns a 3-tuple of
            (ExternalEndpoint, modified, created), where modified and created
            is the boolean status for operations performed.
        :param dict kw: keyword arguments to satisfy ExternalEndpoint.create
            constructor
        :raises CreateElementFailed: Failed to create external endpoint with reason
        :raises ElementNotFound: If specified ExternalGateway is not valid
        :return: if with_status=True, return tuple(ExternalEndpoint, created). Otherwise
            return only ExternalEndpoint.
        """
    if 'address' in kw:
        external_endpoint = external_gateway.external_endpoint.get_contains(
            '({})'.format(kw['address']))
    else:
        external_endpoint = external_gateway.external_endpoint.get_contains(
            name)
    updated = False
    created = False
    if external_endpoint:
        for name, value in kw.items():
            if getattr(external_endpoint, name, None) != value:
                external_endpoint.data[name] = value
                updated = True
        if updated:
            external_endpoint.update()
    else:
        external_endpoint = external_gateway.external_endpoint.create(name,
            **kw)
        created = True
    if with_status:
        return external_endpoint, updated, created
    return external_endpoint
