# 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
from . import outputs
from ._inputs import *

__all__ = [
    'GetSecurityPolicyDocumentResult',
    'AwaitableGetSecurityPolicyDocumentResult',
    'get_security_policy_document',
    'get_security_policy_document_output',
]

@pulumi.output_type
class GetSecurityPolicyDocumentResult:
    """
    A collection of values returned by getSecurityPolicyDocument.
    """
    def __init__(__self__, id=None, scan_execution_policies=None, yaml=None):
        if id and not isinstance(id, str):
            raise TypeError("Expected argument 'id' to be a str")
        pulumi.set(__self__, "id", id)
        if scan_execution_policies and not isinstance(scan_execution_policies, list):
            raise TypeError("Expected argument 'scan_execution_policies' to be a list")
        pulumi.set(__self__, "scan_execution_policies", scan_execution_policies)
        if yaml and not isinstance(yaml, str):
            raise TypeError("Expected argument 'yaml' to be a str")
        pulumi.set(__self__, "yaml", yaml)

    @_builtins.property
    @pulumi.getter
    def id(self) -> _builtins.str:
        """
        Unique identifier for this policy document (hash of generated YAML).
        """
        return pulumi.get(self, "id")

    @_builtins.property
    @pulumi.getter(name="scanExecutionPolicies")
    def scan_execution_policies(self) -> Optional[Sequence['outputs.GetSecurityPolicyDocumentScanExecutionPolicyResult']]:
        """
        Scan execution policy configuration. Multiple policies can be specified.
        """
        return pulumi.get(self, "scan_execution_policies")

    @_builtins.property
    @pulumi.getter
    def yaml(self) -> _builtins.str:
        """
        The generated policy document in YAML format, ready to write to `.gitlab/security-policies/policy.yml`.
        """
        return pulumi.get(self, "yaml")


class AwaitableGetSecurityPolicyDocumentResult(GetSecurityPolicyDocumentResult):
    # pylint: disable=using-constant-test
    def __await__(self):
        if False:
            yield self
        return GetSecurityPolicyDocumentResult(
            id=self.id,
            scan_execution_policies=self.scan_execution_policies,
            yaml=self.yaml)


def get_security_policy_document(scan_execution_policies: Optional[Sequence[Union['GetSecurityPolicyDocumentScanExecutionPolicyArgs', 'GetSecurityPolicyDocumentScanExecutionPolicyArgsDict']]] = None,
                                 opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetSecurityPolicyDocumentResult:
    """
    Generates a GitLab security policy YAML document from structured configuration.
    This data source performs pure transformation without any API calls.

    **Upstream API**: [GitLab Security Policies Documentation](https://docs.gitlab.com/ee/user/application_security/policies/scan_execution_policies/)

    ## Example Usage

    ```python
    import pulumi
    import pulumi_gitlab as gitlab

    # Use this with `gitlab_repository_file` to manage your policies using native HCL
    scan = gitlab.get_security_policy_document(scan_execution_policies=[{
        "name": "Basic SAST Policy",
        "enabled": True,
        "rules": [{
            "type": "pipeline",
            "branch_type": "all",
        }],
        "actions": [{
            "scan": "sast",
        }],
    }])
    # See `gitlab_project_security_policy_attachment` or `gitlab_group_security_policy_attachment`
    # for how to link a security policy project to a project or group.
    policy = gitlab.RepositoryFile("policy",
        project="1234",
        ref="main",
        file_path=".gitlab/security-policies/policy.yml",
        content=scan.yaml)
    ```


    :param Sequence[Union['GetSecurityPolicyDocumentScanExecutionPolicyArgs', 'GetSecurityPolicyDocumentScanExecutionPolicyArgsDict']] scan_execution_policies: Scan execution policy configuration. Multiple policies can be specified.
    """
    __args__ = dict()
    __args__['scanExecutionPolicies'] = scan_execution_policies
    opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke('gitlab:index/getSecurityPolicyDocument:getSecurityPolicyDocument', __args__, opts=opts, typ=GetSecurityPolicyDocumentResult).value

    return AwaitableGetSecurityPolicyDocumentResult(
        id=pulumi.get(__ret__, 'id'),
        scan_execution_policies=pulumi.get(__ret__, 'scan_execution_policies'),
        yaml=pulumi.get(__ret__, 'yaml'))
def get_security_policy_document_output(scan_execution_policies: Optional[pulumi.Input[Optional[Sequence[Union['GetSecurityPolicyDocumentScanExecutionPolicyArgs', 'GetSecurityPolicyDocumentScanExecutionPolicyArgsDict']]]]] = None,
                                        opts: Optional[Union[pulumi.InvokeOptions, pulumi.InvokeOutputOptions]] = None) -> pulumi.Output[GetSecurityPolicyDocumentResult]:
    """
    Generates a GitLab security policy YAML document from structured configuration.
    This data source performs pure transformation without any API calls.

    **Upstream API**: [GitLab Security Policies Documentation](https://docs.gitlab.com/ee/user/application_security/policies/scan_execution_policies/)

    ## Example Usage

    ```python
    import pulumi
    import pulumi_gitlab as gitlab

    # Use this with `gitlab_repository_file` to manage your policies using native HCL
    scan = gitlab.get_security_policy_document(scan_execution_policies=[{
        "name": "Basic SAST Policy",
        "enabled": True,
        "rules": [{
            "type": "pipeline",
            "branch_type": "all",
        }],
        "actions": [{
            "scan": "sast",
        }],
    }])
    # See `gitlab_project_security_policy_attachment` or `gitlab_group_security_policy_attachment`
    # for how to link a security policy project to a project or group.
    policy = gitlab.RepositoryFile("policy",
        project="1234",
        ref="main",
        file_path=".gitlab/security-policies/policy.yml",
        content=scan.yaml)
    ```


    :param Sequence[Union['GetSecurityPolicyDocumentScanExecutionPolicyArgs', 'GetSecurityPolicyDocumentScanExecutionPolicyArgsDict']] scan_execution_policies: Scan execution policy configuration. Multiple policies can be specified.
    """
    __args__ = dict()
    __args__['scanExecutionPolicies'] = scan_execution_policies
    opts = pulumi.InvokeOutputOptions.merge(_utilities.get_invoke_opts_defaults(), opts)
    __ret__ = pulumi.runtime.invoke_output('gitlab:index/getSecurityPolicyDocument:getSecurityPolicyDocument', __args__, opts=opts, typ=GetSecurityPolicyDocumentResult)
    return __ret__.apply(lambda __response__: GetSecurityPolicyDocumentResult(
        id=pulumi.get(__response__, 'id'),
        scan_execution_policies=pulumi.get(__response__, 'scan_execution_policies'),
        yaml=pulumi.get(__response__, 'yaml')))
