# 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__, *,
                 content: 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] content: The content of the iFile. This can be inline text, file content loaded with `file()`, or dynamically generated content. This field is marked as sensitive.
        :param pulumi.Input[_builtins.str] name: Name of the system iFile to be created on BIG-IP. Changing this forces a new resource to be created.
        :param pulumi.Input[_builtins.str] partition: Partition where the iFile will be stored. Defaults to `Common`.
        :param pulumi.Input[_builtins.str] sub_path: Subdirectory within the partition for organizing iFiles hierarchically.
        """
        pulumi.set(__self__, "content", content)
        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
    def content(self) -> pulumi.Input[_builtins.str]:
        """
        The content of the iFile. This can be inline text, file content loaded with `file()`, or dynamically generated content. This field is marked as sensitive.
        """
        return pulumi.get(self, "content")

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

    @_builtins.property
    @pulumi.getter
    def name(self) -> pulumi.Input[_builtins.str]:
        """
        Name of the system iFile to be created on BIG-IP. Changing this forces a new resource to be created.
        """
        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 iFile will be stored. 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 hierarchically.
        """
        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__, *,
                 checksum: Optional[pulumi.Input[_builtins.str]] = None,
                 content: Optional[pulumi.Input[_builtins.str]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 partition: Optional[pulumi.Input[_builtins.str]] = None,
                 size: Optional[pulumi.Input[_builtins.int]] = None,
                 sub_path: Optional[pulumi.Input[_builtins.str]] = None):
        """
        Input properties used for looking up and filtering Ifile resources.

        :param pulumi.Input[_builtins.str] checksum: MD5 checksum of the iFile content, automatically calculated by BIG-IP.
        :param pulumi.Input[_builtins.str] content: The content of the iFile. This can be inline text, file content loaded with `file()`, or dynamically generated content. This field is marked as sensitive.
        :param pulumi.Input[_builtins.str] name: Name of the system iFile to be created on BIG-IP. Changing this forces a new resource to be created.
        :param pulumi.Input[_builtins.str] partition: Partition where the iFile will be stored. Defaults to `Common`.
        :param pulumi.Input[_builtins.int] size: Size of the iFile content in bytes.
        :param pulumi.Input[_builtins.str] sub_path: Subdirectory within the partition for organizing iFiles hierarchically.
        """
        if checksum is not None:
            pulumi.set(__self__, "checksum", checksum)
        if content is not None:
            pulumi.set(__self__, "content", content)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if partition is not None:
            pulumi.set(__self__, "partition", partition)
        if size is not None:
            pulumi.set(__self__, "size", size)
        if sub_path is not None:
            pulumi.set(__self__, "sub_path", sub_path)

    @_builtins.property
    @pulumi.getter
    def checksum(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        MD5 checksum of the iFile content, automatically calculated by BIG-IP.
        """
        return pulumi.get(self, "checksum")

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

    @_builtins.property
    @pulumi.getter
    def content(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        The content of the iFile. This can be inline text, file content loaded with `file()`, or dynamically generated content. This field is marked as sensitive.
        """
        return pulumi.get(self, "content")

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

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Name of the system iFile to be created on BIG-IP. Changing this forces a new resource to be created.
        """
        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 iFile will be stored. 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
    def size(self) -> Optional[pulumi.Input[_builtins.int]]:
        """
        Size of the iFile content in bytes.
        """
        return pulumi.get(self, "size")

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

    @_builtins.property
    @pulumi.getter(name="subPath")
    def sub_path(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Subdirectory within the partition for organizing iFiles hierarchically.
        """
        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:sys/ifile:Ifile")
class Ifile(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 content: 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):
        """
        `sys.Ifile` This resource uploads and manages system iFiles on F5 BIG-IP devices.
        System iFiles store file content on the BIG-IP that can be referenced by iRules, LTM policies, and other BIG-IP configurations for traffic processing and decision making.

        ## Example Usage

        ### System iFile with Sub-path

        ```python
        import pulumi
        import pulumi_f5bigip as f5bigip

        template_file = f5bigip.sys.Ifile("template_file",
            name="error-template",
            partition="Common",
            sub_path="templates",
            content=\"\"\"<html>
          <head><title>Service Unavailable</title></head>
          <body>
            <h1>503 - Service Temporarily Unavailable</h1>
            <p>Please try again later.</p>
          </body>
        </html>
        \"\"\")
        ```

        ### JSON Configuration File

        ```python
        import pulumi
        import json
        import pulumi_f5bigip as f5bigip

        server_list = json.dumps({
            "servers": [
                {
                    "name": "web1",
                    "ip": "10.1.1.10",
                    "port": 80,
                },
                {
                    "name": "web2",
                    "ip": "10.1.1.11",
                    "port": 80,
                },
                {
                    "name": "web3",
                    "ip": "10.1.1.12",
                    "port": 80,
                },
            ],
        })
        server_config = f5bigip.sys.Ifile("server_config",
            name="server-list",
            partition="MyApp",
            content=server_list)
        ```

        ### Using System iFile with LTM iFile

        ```python
        import pulumi
        import pulumi_f5bigip as f5bigip

        # Create system iFile with content
        lookup_table = f5bigip.sys.Ifile("lookup_table",
            name="url-rewrite-map",
            partition="Common",
            content=\"\"\"/old-api/v1/ /api/v2/
        /legacy/ /new/
        /deprecated/ /current/
        \"\"\")
        # Create LTM iFile that references the system iFile
        ltm_lookup = f5bigip.ltm.Ifile("ltm_lookup",
            name="ltm-url-rewrite-map",
            partition="Common",
            file_name="/Common/url-rewrite-map")
        # Use in an iRule
        url_rewriter = f5bigip.ltm.IRule("url_rewriter",
            name="url-rewrite-rule",
            irule=\"\"\"when HTTP_REQUEST {
          set uri [HTTP::uri]
          set mapping [ifile get ltm-url-rewrite-map]
          foreach line [split $mapping \\"\\
        \\"] {
            set parts [split $line \\" \\"]
            if {[string match [lindex $parts 0]* $uri]} {
              HTTP::uri [string map [list [lindex $parts 0] [lindex $parts 1]] $uri]
              break
            }
          }
        }
        \"\"\")
        ```

        ## Notes

        * The `content` field is marked as sensitive and will not be displayed in Terraform logs or state output.
        * Changes to `name` will force recreation of the resource since iFile names cannot be changed after creation.
        * The `checksum` and `size` attributes are automatically computed by the BIG-IP system.
        * iFile content is uploaded to the BIG-IP system and stored there permanently until the resource is destroyed.
        * Use `file()` function to load content from local files or `templatefile()` for dynamic content generation.
        * System iFiles can be referenced by `ltm.Ifile` resources for use in LTM configurations.

        ## Path Structure

        The full path of an iFile follows this pattern:
        - Without sub-path: `/{partition}/{name}`
        - With sub-path: `/{partition}/{sub_path}/{name}`

        Examples:
        - `/Common/config-file`
        - `/Production/templates/error-page`
        - `/MyApp/configs/database-settings`

        ## Related Resources

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

        ## Security Considerations

        * iFile content is stored on the BIG-IP system and may contain sensitive information
        * Use appropriate BIG-IP access controls to limit who can view or modify iFiles
        * Consider using Terraform's sensitive variable handling for confidential content
        * The `content` field is marked as sensitive in Terraform state to prevent accidental exposure

        ## Import

        System iFiles can be imported using their full path:

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

        For iFiles with sub-paths:

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


        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[_builtins.str] content: The content of the iFile. This can be inline text, file content loaded with `file()`, or dynamically generated content. This field is marked as sensitive.
        :param pulumi.Input[_builtins.str] name: Name of the system iFile to be created on BIG-IP. Changing this forces a new resource to be created.
        :param pulumi.Input[_builtins.str] partition: Partition where the iFile will be stored. Defaults to `Common`.
        :param pulumi.Input[_builtins.str] sub_path: Subdirectory within the partition for organizing iFiles hierarchically.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: IfileArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        `sys.Ifile` This resource uploads and manages system iFiles on F5 BIG-IP devices.
        System iFiles store file content on the BIG-IP that can be referenced by iRules, LTM policies, and other BIG-IP configurations for traffic processing and decision making.

        ## Example Usage

        ### System iFile with Sub-path

        ```python
        import pulumi
        import pulumi_f5bigip as f5bigip

        template_file = f5bigip.sys.Ifile("template_file",
            name="error-template",
            partition="Common",
            sub_path="templates",
            content=\"\"\"<html>
          <head><title>Service Unavailable</title></head>
          <body>
            <h1>503 - Service Temporarily Unavailable</h1>
            <p>Please try again later.</p>
          </body>
        </html>
        \"\"\")
        ```

        ### JSON Configuration File

        ```python
        import pulumi
        import json
        import pulumi_f5bigip as f5bigip

        server_list = json.dumps({
            "servers": [
                {
                    "name": "web1",
                    "ip": "10.1.1.10",
                    "port": 80,
                },
                {
                    "name": "web2",
                    "ip": "10.1.1.11",
                    "port": 80,
                },
                {
                    "name": "web3",
                    "ip": "10.1.1.12",
                    "port": 80,
                },
            ],
        })
        server_config = f5bigip.sys.Ifile("server_config",
            name="server-list",
            partition="MyApp",
            content=server_list)
        ```

        ### Using System iFile with LTM iFile

        ```python
        import pulumi
        import pulumi_f5bigip as f5bigip

        # Create system iFile with content
        lookup_table = f5bigip.sys.Ifile("lookup_table",
            name="url-rewrite-map",
            partition="Common",
            content=\"\"\"/old-api/v1/ /api/v2/
        /legacy/ /new/
        /deprecated/ /current/
        \"\"\")
        # Create LTM iFile that references the system iFile
        ltm_lookup = f5bigip.ltm.Ifile("ltm_lookup",
            name="ltm-url-rewrite-map",
            partition="Common",
            file_name="/Common/url-rewrite-map")
        # Use in an iRule
        url_rewriter = f5bigip.ltm.IRule("url_rewriter",
            name="url-rewrite-rule",
            irule=\"\"\"when HTTP_REQUEST {
          set uri [HTTP::uri]
          set mapping [ifile get ltm-url-rewrite-map]
          foreach line [split $mapping \\"\\
        \\"] {
            set parts [split $line \\" \\"]
            if {[string match [lindex $parts 0]* $uri]} {
              HTTP::uri [string map [list [lindex $parts 0] [lindex $parts 1]] $uri]
              break
            }
          }
        }
        \"\"\")
        ```

        ## Notes

        * The `content` field is marked as sensitive and will not be displayed in Terraform logs or state output.
        * Changes to `name` will force recreation of the resource since iFile names cannot be changed after creation.
        * The `checksum` and `size` attributes are automatically computed by the BIG-IP system.
        * iFile content is uploaded to the BIG-IP system and stored there permanently until the resource is destroyed.
        * Use `file()` function to load content from local files or `templatefile()` for dynamic content generation.
        * System iFiles can be referenced by `ltm.Ifile` resources for use in LTM configurations.

        ## Path Structure

        The full path of an iFile follows this pattern:
        - Without sub-path: `/{partition}/{name}`
        - With sub-path: `/{partition}/{sub_path}/{name}`

        Examples:
        - `/Common/config-file`
        - `/Production/templates/error-page`
        - `/MyApp/configs/database-settings`

        ## Related Resources

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

        ## Security Considerations

        * iFile content is stored on the BIG-IP system and may contain sensitive information
        * Use appropriate BIG-IP access controls to limit who can view or modify iFiles
        * Consider using Terraform's sensitive variable handling for confidential content
        * The `content` field is marked as sensitive in Terraform state to prevent accidental exposure

        ## Import

        System iFiles can be imported using their full path:

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

        For iFiles with sub-paths:

        ```sh
        $ pulumi import f5bigip:sys/ifile:Ifile example /Common/templates/my-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,
                 content: 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 content is None and not opts.urn:
                raise TypeError("Missing required property 'content'")
            __props__.__dict__["content"] = None if content is None else pulumi.Output.secret(content)
            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__["checksum"] = None
            __props__.__dict__["size"] = None
        secret_opts = pulumi.ResourceOptions(additional_secret_outputs=["content"])
        opts = pulumi.ResourceOptions.merge(opts, secret_opts)
        super(Ifile, __self__).__init__(
            'f5bigip:sys/ifile:Ifile',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            checksum: Optional[pulumi.Input[_builtins.str]] = None,
            content: Optional[pulumi.Input[_builtins.str]] = None,
            name: Optional[pulumi.Input[_builtins.str]] = None,
            partition: Optional[pulumi.Input[_builtins.str]] = None,
            size: Optional[pulumi.Input[_builtins.int]] = 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] checksum: MD5 checksum of the iFile content, automatically calculated by BIG-IP.
        :param pulumi.Input[_builtins.str] content: The content of the iFile. This can be inline text, file content loaded with `file()`, or dynamically generated content. This field is marked as sensitive.
        :param pulumi.Input[_builtins.str] name: Name of the system iFile to be created on BIG-IP. Changing this forces a new resource to be created.
        :param pulumi.Input[_builtins.str] partition: Partition where the iFile will be stored. Defaults to `Common`.
        :param pulumi.Input[_builtins.int] size: Size of the iFile content in bytes.
        :param pulumi.Input[_builtins.str] sub_path: Subdirectory within the partition for organizing iFiles hierarchically.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _IfileState.__new__(_IfileState)

        __props__.__dict__["checksum"] = checksum
        __props__.__dict__["content"] = content
        __props__.__dict__["name"] = name
        __props__.__dict__["partition"] = partition
        __props__.__dict__["size"] = size
        __props__.__dict__["sub_path"] = sub_path
        return Ifile(resource_name, opts=opts, __props__=__props__)

    @_builtins.property
    @pulumi.getter
    def checksum(self) -> pulumi.Output[_builtins.str]:
        """
        MD5 checksum of the iFile content, automatically calculated by BIG-IP.
        """
        return pulumi.get(self, "checksum")

    @_builtins.property
    @pulumi.getter
    def content(self) -> pulumi.Output[_builtins.str]:
        """
        The content of the iFile. This can be inline text, file content loaded with `file()`, or dynamically generated content. This field is marked as sensitive.
        """
        return pulumi.get(self, "content")

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

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

    @_builtins.property
    @pulumi.getter
    def size(self) -> pulumi.Output[_builtins.int]:
        """
        Size of the iFile content in bytes.
        """
        return pulumi.get(self, "size")

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

