# autogenerated file, do not modify

from os import PathLike, curdir
from typing import Union

from flopy.mf6.data.mfdatautil import ArrayTemplateGenerator, ListTemplateGenerator
from flopy.mf6.mfpackage import MFChildPackages, MFPackage


class ModflowGwfapi(MFPackage):
    """
    ModflowGwfapi defines a API package.

    Parameters
    ----------
    model
        Model that this package is a part of. Package is automatically
        added to model when it is initialized.
    loading_package : bool, default False
        Do not set this parameter. It is intended for debugging and internal
        processing purposes only.
    boundnames : keyword
        keyword to indicate that boundary names may be provided with the list of api
        boundary cells.
    print_input : keyword
        keyword to indicate that the list of api boundary information will be written
        to the listing file immediately after it is read.
    print_flows : keyword
        keyword to indicate that the list of api boundary flow rates will be printed to
        the listing file for every stress period time step in which 'budget print' is
        specified in output control.  if there is no output control option and
        'print_flows' is specified, then flow rates are printed for the last time step
        of each stress period.
    save_flows : keyword
        keyword to indicate that api boundary flow terms will be written to the file
        specified with 'budget fileout' in output control.
    observations : record obs6 filein obs6_filename
        Contains data for the obs package. Data can be passed as a dictionary to the
        obs package with variable names as keys and package data as values. Data for
        the observations variable is also acceptable. See obs package documentation for
        more information.
    mover : keyword
        keyword to indicate that this instance of the api boundary package can be used
        with the water mover (mvr) package.  when the mover option is specified,
        additional memory is allocated within the package to store the available,
        provided, and received water.
    maxbound : integer
        integer value specifying the maximum number of api boundary cells that will be
        specified for use during any stress period.

    filename : str or PathLike, optional
        Name or path of file where this package is stored.
    pname : str, optional
        Package name.
    **kwargs
        Extra keywords for :class:`flopy.mf6.mfpackage.MFPackage`.

    """

    obs_filerecord = ListTemplateGenerator(("gwf6", "api", "options", "obs_filerecord"))
    package_abbr = "gwfapi"
    _package_type = "api"
    dfn_file_name = "gwf-api.dfn"
    dfn = [
        ["header", "multi-package"],
        [
            "block options",
            "name boundnames",
            "type keyword",
            "shape",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name print_input",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal iprpak",
        ],
        [
            "block options",
            "name print_flows",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal iprflow",
        ],
        [
            "block options",
            "name save_flows",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal ipakcb",
        ],
        [
            "block options",
            "name obs_filerecord",
            "type record obs6 filein obs6_filename",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package obs",
            "construct_data observations",
            "parameter_name continuous",
        ],
        [
            "block options",
            "name obs6",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name filein",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name obs6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block options",
            "name mover",
            "type keyword",
            "tagged true",
            "reader urword",
            "optional true",
        ],
        [
            "block dimensions",
            "name maxbound",
            "type integer",
            "reader urword",
            "optional false",
        ],
    ]

    def __init__(
        self,
        model,
        loading_package=False,
        boundnames=None,
        print_input=None,
        print_flows=None,
        save_flows=None,
        observations=None,
        mover=None,
        maxbound=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowGwfapi."""
        super().__init__(
            parent=model,
            package_type="api",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.boundnames = self.build_mfdata("boundnames", boundnames)
        self.print_input = self.build_mfdata("print_input", print_input)
        self.print_flows = self.build_mfdata("print_flows", print_flows)
        self.save_flows = self.build_mfdata("save_flows", save_flows)
        self._obs_filerecord = self.build_mfdata("obs_filerecord", None)
        self._obs_package = self.build_child_package(
            "obs", observations, "continuous", self._obs_filerecord
        )
        self.mover = self.build_mfdata("mover", mover)
        self.maxbound = self.build_mfdata("maxbound", maxbound)

        self._init_complete = True
