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
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)
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)
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)
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)
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)
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)
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)
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)
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)
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()
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)
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()
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)
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()