Пример #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
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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()
Пример #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)
Пример #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()
Пример #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)
Пример #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()