Exemplo n.º 1
0
 def check_and_get_provider():
     if not input.get("provider"):
         return None
     provider_key = get_key(input.get("provider"))
     if provider_key.parent() != info.context.user_key:
         raise ExecutionUnauthorized
     return provider_key
Exemplo n.º 2
0
    def mutate_and_get_payload(cls, root, info, id):
        service_key = get_key(id)
        if service_key.parent().parent() != info.context.user_key:
            raise ExecutionUnauthorized

        service = reset_balance(service_key)
        return ResetBalance(service=service)
Exemplo n.º 3
0
    def mutate_and_get_payload(cls, root, info, **input):
        service_key = get_key(input.get("id"))
        if service_key.parent().parent() != info.context.user_key:
            raise ExecutionUnauthorized

        service = load_balance(service_key, input.get("amount"))
        return LoadBalance(service=service)
Exemplo n.º 4
0
 def mutate_and_get_payload(cls, root, info, **input):
     provider_key = get_key(input.get("id"))
     if provider_key.parent() != info.context.user_key:
         raise ExecutionUnauthorized
     body = pick(_provider_config_fields, input)
     provider = put_config(provider_key, body)
     return UpdateProviderConfig(provider=provider)
Exemplo n.º 5
0
    def mutate_and_get_payload(cls, root, info, **input):
        service_key = get_key(input.get("id"))
        if service_key.parent().parent() != info.context.user_key:
            raise ExecutionUnauthorized

        service = remove_static(service_key, input.get("field"))
        return DeleteServiceStatic(service=service)
Exemplo n.º 6
0
    def mutate_and_get_payload(cls, root, info, **input):
        account_key = get_key(input.get("account"))
        provider_key = get_key(input.get("provider"))
        if (
            account_key.parent() != info.context.user_key
            or provider_key.parent() != info.context.user_key
        ):
            raise ExecutionUnauthorized

        service = create(
            fields=filter(lambda x: x != "account", cls.Input._meta.fields.keys()),
            account=account_key,
            provider=provider_key,
            body=pick(_service_fields, input),
            as_obj=True,
        )
        return CreateService(service=service)
Exemplo n.º 7
0
    def mutate_and_get_payload(cls, root, info, **input):
        service_key = get_key(input.get("id"))
        if service_key.parent().parent() != info.context.user_key:
            raise ExecutionUnauthorized

        body = pick(_service_static_fields, input)
        service = put_static(service_key, body)
        return UpdateServiceStatic(service=service)
Exemplo n.º 8
0
 def mutate_and_get_payload(cls, root, info, **input):
     account_key = get_key(input.get("id"))
     if account_key.parent() != info.context.user_key:
         raise ExecutionUnauthorized
     account = update(
         fields=filter(lambda x: x != "id", cls.Input._meta.fields.keys()),
         account=account_key,
         body=pick(["site", "name"], input),
         as_obj=True,
     )
     return UpdateAccount(account=account)
Exemplo n.º 9
0
 def mutate_and_get_payload(cls, root, info, **input):
     provider_key = get_key(input.get("id"))
     if provider_key.parent() != info.context.user_key:
         raise ExecutionUnauthorized
     provider = update(
         fields=filter(lambda x: x != "id", cls.Input._meta.fields.keys()),
         provider=provider_key,
         body=pick(_provider_fields, input),
         as_obj=True,
     )
     return UpdateProvider(provider=provider)
Exemplo n.º 10
0
    def mutate_and_get_payload(cls, root, info, **input):
        def check_and_get_provider():
            if not input.get("provider"):
                return None
            provider_key = get_key(input.get("provider"))
            if provider_key.parent() != info.context.user_key:
                raise ExecutionUnauthorized
            return provider_key

        service_key = get_key(input.get("id"))
        if service_key.parent().parent() != info.context.user_key:
            raise ExecutionUnauthorized

        service = update(
            fields=filter(lambda x: x != "id", cls.Input._meta.fields.keys()),
            service=service_key,
            provider=check_and_get_provider(),
            body=pick(_service_fields, input),
            as_obj=True,
        )
        return UpdateService(service=service)
Exemplo n.º 11
0
 def mutate_and_get_payload(cls, root, info, id):
     account_key = get_key(id)
     if account_key.parent() != info.context.user_key:
         raise ExecutionUnauthorized
     delete(account_key)
     return DeleteAccount()
Exemplo n.º 12
0
 def mutate_and_get_payload(cls, root, info, **input):
     account_key = get_key(input.get("id"))
     if account_key.parent() != info.context.user_key:
         raise ExecutionUnauthorized
     key = generate_api_key(account_key)
     return CreateAccountKey(key=key)
Exemplo n.º 13
0
 def mutate_and_get_payload(cls, root, info, id):
     service_key = get_key(id)
     if service_key.parent().parent() != info.context.user_key:
         raise ExecutionUnauthorized
     delete(service_key)
     return DeleteService()
Exemplo n.º 14
0
 def mutate_and_get_payload(cls, root, info, **input):
     provider_key = get_key(input.get("id"))
     if provider_key.parent() != info.context.user_key:
         raise ExecutionUnauthorized
     provider = remove_method(provider_key, input.get("action"))
     return UpdateProviderMethod(provider=provider)
Exemplo n.º 15
0
 def mutate_and_get_payload(cls, root, info, id):
     provider_key = get_key(id)
     if provider_key.parent() != info.context.user_key:
         raise ExecutionUnauthorized
     delete(provider_key)
     return DeleteProvider()