# coding=utf-8
# *** WARNING: this file was generated by pulumi-language-python. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import builtins as _builtins
import warnings
import sys
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
if sys.version_info >= (3, 11):
    from typing import NotRequired, TypedDict, TypeAlias
else:
    from typing_extensions import NotRequired, TypedDict, TypeAlias
from .. import _utilities

__all__ = ['IfileArgs', 'Ifile']

@pulumi.input_type
class IfileArgs:
    def __init__(__self__, *,
                 file_name: pulumi.Input[_builtins.str],
                 name: pulumi.Input[_builtins.str],
                 partition: Optional[pulumi.Input[_builtins.str]] = None,
                 sub_path: Optional[pulumi.Input[_builtins.str]] = None):
        """
        The set of arguments for constructing a Ifile resource.

        :param pulumi.Input[_builtins.str] file_name: The system iFile name to reference (e.g., `/Common/my-sys-ifile`). This should reference an existing system iFile created with `sys.Ifile`.
        :param pulumi.Input[_builtins.str] name: Name of the LTM iFile to be created on BIG-IP.
        :param pulumi.Input[_builtins.str] partition: Partition where the LTM iFile will be created. Defaults to `Common`.
        :param pulumi.Input[_builtins.str] sub_path: Subdirectory within the partition for organizing iFiles.
        """
        pulumi.set(__self__, "file_name", file_name)
        pulumi.set(__self__, "name", name)
        if partition is not None:
            pulumi.set(__self__, "partition", partition)
        if sub_path is not None:
            pulumi.set(__self__, "sub_path", sub_path)

    @_builtins.property
    @pulumi.getter(name="fileName")
    def file_name(self) -> pulumi.Input[_builtins.str]:
        """
        The system iFile name to reference (e.g., `/Common/my-sys-ifile`). This should reference an existing system iFile created with `sys.Ifile`.
        """
        return pulumi.get(self, "file_name")

    @file_name.setter
    def file_name(self, value: pulumi.Input[_builtins.str]):
        pulumi.set(self, "file_name", value)

    @_builtins.property
    @pulumi.getter
    def name(self) -> pulumi.Input[_builtins.str]:
        """
        Name of the LTM iFile to be created on BIG-IP.
        """
        return pulumi.get(self, "name")

    @name.setter
    def name(self, value: pulumi.Input[_builtins.str]):
        pulumi.set(self, "name", value)

    @_builtins.property
    @pulumi.getter
    def partition(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Partition where the LTM iFile will be created. Defaults to `Common`.
        """
        return pulumi.get(self, "partition")

    @partition.setter
    def partition(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "partition", value)

    @_builtins.property
    @pulumi.getter(name="subPath")
    def sub_path(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Subdirectory within the partition for organizing iFiles.
        """
        return pulumi.get(self, "sub_path")

    @sub_path.setter
    def sub_path(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "sub_path", value)


@pulumi.input_type
class _IfileState:
    def __init__(__self__, *,
                 file_name: Optional[pulumi.Input[_builtins.str]] = None,
                 full_path: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 partition: Optional[pulumi.Input[_builtins.str]] = None,
                 sub_path: Optional[pulumi.Input[_builtins.str]] = None):
        """
        Input properties used for looking up and filtering Ifile resources.

        :param pulumi.Input[_builtins.str] file_name: The system iFile name to reference (e.g., `/Common/my-sys-ifile`). This should reference an existing system iFile created with `sys.Ifile`.
        :param pulumi.Input[_builtins.str] full_path: The complete path of the LTM iFile on the BIG-IP system.
        :param pulumi.Input[_builtins.str] name: Name of the LTM iFile to be created on BIG-IP.
        :param pulumi.Input[_builtins.str] partition: Partition where the LTM iFile will be created. Defaults to `Common`.
        :param pulumi.Input[_builtins.str] sub_path: Subdirectory within the partition for organizing iFiles.
        """
        if file_name is not None:
            pulumi.set(__self__, "file_name", file_name)
        if full_path is not None:
            pulumi.set(__self__, "full_path", full_path)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if partition is not None:
            pulumi.set(__self__, "partition", partition)
        if sub_path is not None:
            pulumi.set(__self__, "sub_path", sub_path)

    @_builtins.property
    @pulumi.getter(name="fileName")
    def file_name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The system iFile name to reference (e.g., `/Common/my-sys-ifile`). This should reference an existing system iFile created with `sys.Ifile`.
        """
        return pulumi.get(self, "file_name")

    @file_name.setter
    def file_name(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "file_name", value)

    @_builtins.property
    @pulumi.getter(name="fullPath")
    def full_path(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The complete path of the LTM iFile on the BIG-IP system.
        """
        return pulumi.get(self, "full_path")

    @full_path.setter
    def full_path(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "full_path", value)

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Name of the LTM iFile to be created on BIG-IP.
        """
        return pulumi.get(self, "name")

    @name.setter
    def name(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "name", value)

    @_builtins.property
    @pulumi.getter
    def partition(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Partition where the LTM iFile will be created. Defaults to `Common`.
        """
        return pulumi.get(self, "partition")

    @partition.setter
    def partition(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "partition", value)

    @_builtins.property
    @pulumi.getter(name="subPath")
    def sub_path(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Subdirectory within the partition for organizing iFiles.
        """
        return pulumi.get(self, "sub_path")

    @sub_path.setter
    def sub_path(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "sub_path", value)


@pulumi.type_token("f5bigip:ltm/ifile:Ifile")
class Ifile(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 file_name: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 partition: Optional[pulumi.Input[_builtins.str]] = None,
                 sub_path: Optional[pulumi.Input[_builtins.str]] = None,
                 __props__=None):
        """
        `ltm.Ifile` This resource creates an LTM iFile on F5 BIG-IP that references an existing system iFile.
        LTM iFiles are used in iRules and LTM policies to access file content for traffic processing and decision making.

        ## Example Usage

        ### Using LTM iFile in iRule

        ```python
        import pulumi
        import pulumi_f5bigip as f5bigip

        server_list = f5bigip.sys.Ifile("server_list",
            name="server-mapping",
            partition="Production",
            content=\"\"\"web1:10.1.1.10
        web2:10.1.1.11
        web3:10.1.1.12
        \"\"\")
        ltm_servers = f5bigip.ltm.Ifile("ltm_servers",
            name="ltm-server-mapping",
            partition="Production",
            file_name="/Production/server-mapping")
        server_selector = f5bigip.ltm.IRule("server_selector",
            name="select-server-rule",
            irule=\"\"\"when HTTP_REQUEST {
          set server_map [ifile get ltm-server-mapping]
          # Process server mapping logic
          foreach line [split $server_map \\"\\
        \\"] {
            set parts [split $line \\":\\"]
            # Implement server selection logic
          }
        }
        \"\"\")
        ```

        ## Notes

        * The referenced system iFile (specified in `file_name`) must exist before creating the LTM iFile.
        * LTM iFiles are primarily used in iRules and LTM policies for traffic processing.
        * Changes to `name`, `partition`, or `sub_path` will force recreation of the resource.
        * The LTM iFile acts as a reference to the system iFile and doesn't store content directly.
        * Use `sys.Ifile` to upload file content, then reference it with `ltm.Ifile` for LTM usage.

        ## Related Resources

        * `sys.Ifile` - Creates system iFiles with content
        * `ltm.IRule` - Creates iRules that can reference LTM iFiles
        * `ltm.Policy` - Creates LTM policies that can use LTM iFiles

        ## Import

        LTM iFiles can be imported using their full path:

        ```sh
        $ pulumi import f5bigip:ltm/ifile:Ifile example /Common/my-ltm-ifile
        ```

        For iFiles with sub-paths:

        ```sh
        $ pulumi import f5bigip:ltm/ifile:Ifile example /Common/templates/my-ltm-ifile
        ```


        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[_builtins.str] file_name: The system iFile name to reference (e.g., `/Common/my-sys-ifile`). This should reference an existing system iFile created with `sys.Ifile`.
        :param pulumi.Input[_builtins.str] name: Name of the LTM iFile to be created on BIG-IP.
        :param pulumi.Input[_builtins.str] partition: Partition where the LTM iFile will be created. Defaults to `Common`.
        :param pulumi.Input[_builtins.str] sub_path: Subdirectory within the partition for organizing iFiles.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: IfileArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        `ltm.Ifile` This resource creates an LTM iFile on F5 BIG-IP that references an existing system iFile.
        LTM iFiles are used in iRules and LTM policies to access file content for traffic processing and decision making.

        ## Example Usage

        ### Using LTM iFile in iRule

        ```python
        import pulumi
        import pulumi_f5bigip as f5bigip

        server_list = f5bigip.sys.Ifile("server_list",
            name="server-mapping",
            partition="Production",
            content=\"\"\"web1:10.1.1.10
        web2:10.1.1.11
        web3:10.1.1.12
        \"\"\")
        ltm_servers = f5bigip.ltm.Ifile("ltm_servers",
            name="ltm-server-mapping",
            partition="Production",
            file_name="/Production/server-mapping")
        server_selector = f5bigip.ltm.IRule("server_selector",
            name="select-server-rule",
            irule=\"\"\"when HTTP_REQUEST {
          set server_map [ifile get ltm-server-mapping]
          # Process server mapping logic
          foreach line [split $server_map \\"\\
        \\"] {
            set parts [split $line \\":\\"]
            # Implement server selection logic
          }
        }
        \"\"\")
        ```

        ## Notes

        * The referenced system iFile (specified in `file_name`) must exist before creating the LTM iFile.
        * LTM iFiles are primarily used in iRules and LTM policies for traffic processing.
        * Changes to `name`, `partition`, or `sub_path` will force recreation of the resource.
        * The LTM iFile acts as a reference to the system iFile and doesn't store content directly.
        * Use `sys.Ifile` to upload file content, then reference it with `ltm.Ifile` for LTM usage.

        ## Related Resources

        * `sys.Ifile` - Creates system iFiles with content
        * `ltm.IRule` - Creates iRules that can reference LTM iFiles
        * `ltm.Policy` - Creates LTM policies that can use LTM iFiles

        ## Import

        LTM iFiles can be imported using their full path:

        ```sh
        $ pulumi import f5bigip:ltm/ifile:Ifile example /Common/my-ltm-ifile
        ```

        For iFiles with sub-paths:

        ```sh
        $ pulumi import f5bigip:ltm/ifile:Ifile example /Common/templates/my-ltm-ifile
        ```


        :param str resource_name: The name of the resource.
        :param IfileArgs args: The arguments to use to populate this resource's properties.
        :param pulumi.ResourceOptions opts: Options for the resource.
        """
        ...
    def __init__(__self__, resource_name: str, *args, **kwargs):
        resource_args, opts = _utilities.get_resource_args_opts(IfileArgs, pulumi.ResourceOptions, *args, **kwargs)
        if resource_args is not None:
            __self__._internal_init(resource_name, opts, **resource_args.__dict__)
        else:
            __self__._internal_init(resource_name, *args, **kwargs)

    def _internal_init(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 file_name: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 partition: Optional[pulumi.Input[_builtins.str]] = None,
                 sub_path: Optional[pulumi.Input[_builtins.str]] = None,
                 __props__=None):
        opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = IfileArgs.__new__(IfileArgs)

            if file_name is None and not opts.urn:
                raise TypeError("Missing required property 'file_name'")
            __props__.__dict__["file_name"] = file_name
            if name is None and not opts.urn:
                raise TypeError("Missing required property 'name'")
            __props__.__dict__["name"] = name
            __props__.__dict__["partition"] = partition
            __props__.__dict__["sub_path"] = sub_path
            __props__.__dict__["full_path"] = None
        super(Ifile, __self__).__init__(
            'f5bigip:ltm/ifile:Ifile',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            file_name: Optional[pulumi.Input[_builtins.str]] = None,
            full_path: Optional[pulumi.Input[_builtins.str]] = None,
            name: Optional[pulumi.Input[_builtins.str]] = None,
            partition: Optional[pulumi.Input[_builtins.str]] = None,
            sub_path: Optional[pulumi.Input[_builtins.str]] = None) -> 'Ifile':
        """
        Get an existing Ifile resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[_builtins.str] file_name: The system iFile name to reference (e.g., `/Common/my-sys-ifile`). This should reference an existing system iFile created with `sys.Ifile`.
        :param pulumi.Input[_builtins.str] full_path: The complete path of the LTM iFile on the BIG-IP system.
        :param pulumi.Input[_builtins.str] name: Name of the LTM iFile to be created on BIG-IP.
        :param pulumi.Input[_builtins.str] partition: Partition where the LTM iFile will be created. Defaults to `Common`.
        :param pulumi.Input[_builtins.str] sub_path: Subdirectory within the partition for organizing iFiles.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _IfileState.__new__(_IfileState)

        __props__.__dict__["file_name"] = file_name
        __props__.__dict__["full_path"] = full_path
        __props__.__dict__["name"] = name
        __props__.__dict__["partition"] = partition
        __props__.__dict__["sub_path"] = sub_path
        return Ifile(resource_name, opts=opts, __props__=__props__)

    @_builtins.property
    @pulumi.getter(name="fileName")
    def file_name(self) -> pulumi.Output[_builtins.str]:
        """
        The system iFile name to reference (e.g., `/Common/my-sys-ifile`). This should reference an existing system iFile created with `sys.Ifile`.
        """
        return pulumi.get(self, "file_name")

    @_builtins.property
    @pulumi.getter(name="fullPath")
    def full_path(self) -> pulumi.Output[_builtins.str]:
        """
        The complete path of the LTM iFile on the BIG-IP system.
        """
        return pulumi.get(self, "full_path")

    @_builtins.property
    @pulumi.getter
    def name(self) -> pulumi.Output[_builtins.str]:
        """
        Name of the LTM iFile to be created on BIG-IP.
        """
        return pulumi.get(self, "name")

    @_builtins.property
    @pulumi.getter
    def partition(self) -> pulumi.Output[Optional[_builtins.str]]:
        """
        Partition where the LTM iFile will be created. Defaults to `Common`.
        """
        return pulumi.get(self, "partition")

    @_builtins.property
    @pulumi.getter(name="subPath")
    def sub_path(self) -> pulumi.Output[Optional[_builtins.str]]:
        """
        Subdirectory within the partition for organizing iFiles.
        """
        return pulumi.get(self, "sub_path")

