<?php

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

declare(strict_types=1);

namespace Dagger;

/**
 * Information about the host environment.
 */
class Host extends Client\AbstractObject implements Client\IdAble
{
    /**
     * Accesses a container image on the host.
     */
    public function containerImage(string $name): Container
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('containerImage');
        $innerQueryBuilder->setArgument('name', $name);
        return new \Dagger\Container($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Accesses a directory on the host.
     */
    public function directory(
        string $path,
        ?array $exclude = null,
        ?array $include = null,
        ?bool $noCache = false,
        ?bool $gitignore = false,
    ): Directory {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('directory');
        $innerQueryBuilder->setArgument('path', $path);
        if (null !== $exclude) {
        $innerQueryBuilder->setArgument('exclude', $exclude);
        }
        if (null !== $include) {
        $innerQueryBuilder->setArgument('include', $include);
        }
        if (null !== $noCache) {
        $innerQueryBuilder->setArgument('noCache', $noCache);
        }
        if (null !== $gitignore) {
        $innerQueryBuilder->setArgument('gitignore', $gitignore);
        }
        return new \Dagger\Directory($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Accesses a file on the host.
     */
    public function file(string $path, ?bool $noCache = false): File
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('file');
        $innerQueryBuilder->setArgument('path', $path);
        if (null !== $noCache) {
        $innerQueryBuilder->setArgument('noCache', $noCache);
        }
        return new \Dagger\File($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Search for a file or directory by walking up the tree from system workdir. Return its relative path. If no match, return null
     */
    public function findUp(string $name, ?bool $noCache = false): string
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('findUp');
        $leafQueryBuilder->setArgument('name', $name);
        if (null !== $noCache) {
        $leafQueryBuilder->setArgument('noCache', $noCache);
        }
        return (string)$this->queryLeaf($leafQueryBuilder, 'findUp');
    }

    /**
     * A unique identifier for this Host.
     */
    public function id(): HostId
    {
        $leafQueryBuilder = new \Dagger\Client\QueryBuilder('id');
        return new \Dagger\HostId((string)$this->queryLeaf($leafQueryBuilder, 'id'));
    }

    /**
     * Creates a service that forwards traffic to a specified address via the host.
     */
    public function service(array $ports, ?string $host = 'localhost'): Service
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('service');
        $innerQueryBuilder->setArgument('ports', $ports);
        if (null !== $host) {
        $innerQueryBuilder->setArgument('host', $host);
        }
        return new \Dagger\Service($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Creates a tunnel that forwards traffic from the host to a service.
     */
    public function tunnel(ServiceId|Service $service, ?bool $native = false, ?array $ports = null): Service
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('tunnel');
        $innerQueryBuilder->setArgument('service', $service);
        if (null !== $native) {
        $innerQueryBuilder->setArgument('native', $native);
        }
        if (null !== $ports) {
        $innerQueryBuilder->setArgument('ports', $ports);
        }
        return new \Dagger\Service($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }

    /**
     * Accesses a Unix socket on the host.
     */
    public function unixSocket(string $path): Socket
    {
        $innerQueryBuilder = new \Dagger\Client\QueryBuilder('unixSocket');
        $innerQueryBuilder->setArgument('path', $path);
        return new \Dagger\Socket($this->client, $this->queryBuilderChain->chain($innerQueryBuilder));
    }
}
