<?php

/**
 * This class has been generated by dagger-php-sdk. DO NOT EDIT.
 */

declare(strict_types=1);

namespace Dagger;

/**
 * An active function call.
 */
class FunctionCall extends Client\AbstractObject implements Client\IdAble
{
    /**
     * A unique identifier for this FunctionCall.
     */
    public function id(): FunctionCallId
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('id');
        return new \Dagger\FunctionCallId((string)$this->queryLeaf($leafQueryBuilder, 'id'));
    }

    /**
     * The argument values the function is being invoked with.
     */
    public function inputArgs(): array
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('inputArgs');
        return (array)$this->queryLeaf($leafQueryBuilder, 'inputArgs');
    }

    /**
     * The name of the function being called.
     */
    public function name(): string
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('name');
        return (string)$this->queryLeaf($leafQueryBuilder, 'name');
    }

    /**
     * The value of the parent object of the function being called. If the function is top-level to the module, this is always an empty object.
     */
    public function parent(): Json
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('parent');
        return new \Dagger\Json((string)$this->queryLeaf($leafQueryBuilder, 'parent'));
    }

    /**
     * The name of the parent object of the function being called. If the function is top-level to the module, this is the name of the module.
     */
    public function parentName(): string
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('parentName');
        return (string)$this->queryLeaf($leafQueryBuilder, 'parentName');
    }

    /**
     * Return an error from the function.
     */
    public function returnError(ErrorId|Error $error): void
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('returnError');
        $leafQueryBuilder->setArgument('error', $error);
        $this->queryLeaf($leafQueryBuilder, 'returnError');
    }

    /**
     * Set the return value of the function call to the provided value.
     */
    public function returnValue(Json $value): void
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('returnValue');
        $leafQueryBuilder->setArgument('value', $value);
        $this->queryLeaf($leafQueryBuilder, 'returnValue');
    }
}
