# coding: utf-8
# Copyright (c) 2016, 2026, Oracle and/or its affiliates.  All rights reserved.
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.

# NOTE: This class is auto generated by OracleSDKGenerator. DO NOT EDIT. API Version: 20210415

from .create_container_instance_security_context_details import CreateContainerInstanceSecurityContextDetails
from oci.util import formatted_flat_dict, NONE_SENTINEL, value_allowed_none_or_none_sentinel  # noqa: F401
from oci.decorators import init_model_state_from_kwargs


@init_model_state_from_kwargs
class CreateLinuxContainerInstanceSecurityContextDetails(CreateContainerInstanceSecurityContextDetails):
    """
    Security context for all containers in a Linux container instance.
    """

    #: A constant which can be used with the fs_group_change_policy property of a CreateLinuxContainerInstanceSecurityContextDetails.
    #: This constant has a value of "ALWAYS"
    FS_GROUP_CHANGE_POLICY_ALWAYS = "ALWAYS"

    #: A constant which can be used with the fs_group_change_policy property of a CreateLinuxContainerInstanceSecurityContextDetails.
    #: This constant has a value of "ON_ROOT_MISMATCH"
    FS_GROUP_CHANGE_POLICY_ON_ROOT_MISMATCH = "ON_ROOT_MISMATCH"

    def __init__(self, **kwargs):
        """
        Initializes a new CreateLinuxContainerInstanceSecurityContextDetails object with values from keyword arguments. The default value of the :py:attr:`~oci.container_instances.models.CreateLinuxContainerInstanceSecurityContextDetails.security_context_type` attribute
        of this class is ``LINUX`` and it should not be changed.
        The following keyword arguments are supported (corresponding to the getters/setters of this class):

        :param security_context_type:
            The value to assign to the security_context_type property of this CreateLinuxContainerInstanceSecurityContextDetails.
        :type security_context_type: str

        :param fs_group:
            The value to assign to the fs_group property of this CreateLinuxContainerInstanceSecurityContextDetails.
        :type fs_group: int

        :param fs_group_change_policy:
            The value to assign to the fs_group_change_policy property of this CreateLinuxContainerInstanceSecurityContextDetails.
            Allowed values for this property are: "ALWAYS", "ON_ROOT_MISMATCH"
        :type fs_group_change_policy: str

        """
        self.swagger_types = {
            'security_context_type': 'str',
            'fs_group': 'int',
            'fs_group_change_policy': 'str'
        }
        self.attribute_map = {
            'security_context_type': 'securityContextType',
            'fs_group': 'fsGroup',
            'fs_group_change_policy': 'fsGroupChangePolicy'
        }
        self._security_context_type = None
        self._fs_group = None
        self._fs_group_change_policy = None
        self._security_context_type = 'LINUX'

    @property
    def fs_group(self):
        """
        Gets the fs_group of this CreateLinuxContainerInstanceSecurityContextDetails.
        A special supplemental group that applies to all containers in the container instance. Some volume types allow the container instance to change ownership of the volume. The owning GID will be the fsGroup, the setgid bit will be set (new files will be owned by the fsGroup), and the permission bits are OR'd with rw-rw----. If unset, the container instance will not modify the ownership and permissions of volumes.


        :return: The fs_group of this CreateLinuxContainerInstanceSecurityContextDetails.
        :rtype: int
        """
        return self._fs_group

    @fs_group.setter
    def fs_group(self, fs_group):
        """
        Sets the fs_group of this CreateLinuxContainerInstanceSecurityContextDetails.
        A special supplemental group that applies to all containers in the container instance. Some volume types allow the container instance to change ownership of the volume. The owning GID will be the fsGroup, the setgid bit will be set (new files will be owned by the fsGroup), and the permission bits are OR'd with rw-rw----. If unset, the container instance will not modify the ownership and permissions of volumes.


        :param fs_group: The fs_group of this CreateLinuxContainerInstanceSecurityContextDetails.
        :type: int
        """
        self._fs_group = fs_group

    @property
    def fs_group_change_policy(self):
        """
        Gets the fs_group_change_policy of this CreateLinuxContainerInstanceSecurityContextDetails.
        Defines behavior of changing ownership and permission of the volume before being exposed inside the containers. This only applies to volumes which support fsGroup ownership and permissions, and will have no effect on ephemeral volumes. ON_ROOT_MISMATCH only changes permissions and ownership if the permission and ownership of the root directory does not match the expected permissions and ownership of the volume. This can improve container instance start times. ALWAYS  changes permission and ownership of the volume when it is mounted. If unset, ALWAYS is used.

        Allowed values for this property are: "ALWAYS", "ON_ROOT_MISMATCH"


        :return: The fs_group_change_policy of this CreateLinuxContainerInstanceSecurityContextDetails.
        :rtype: str
        """
        return self._fs_group_change_policy

    @fs_group_change_policy.setter
    def fs_group_change_policy(self, fs_group_change_policy):
        """
        Sets the fs_group_change_policy of this CreateLinuxContainerInstanceSecurityContextDetails.
        Defines behavior of changing ownership and permission of the volume before being exposed inside the containers. This only applies to volumes which support fsGroup ownership and permissions, and will have no effect on ephemeral volumes. ON_ROOT_MISMATCH only changes permissions and ownership if the permission and ownership of the root directory does not match the expected permissions and ownership of the volume. This can improve container instance start times. ALWAYS  changes permission and ownership of the volume when it is mounted. If unset, ALWAYS is used.


        :param fs_group_change_policy: The fs_group_change_policy of this CreateLinuxContainerInstanceSecurityContextDetails.
        :type: str
        """
        allowed_values = ["ALWAYS", "ON_ROOT_MISMATCH"]
        if not value_allowed_none_or_none_sentinel(fs_group_change_policy, allowed_values):
            raise ValueError(
                f"Invalid value for `fs_group_change_policy`, must be None or one of {allowed_values}"
            )
        self._fs_group_change_policy = fs_group_change_policy

    def __repr__(self):
        return formatted_flat_dict(self)

    def __eq__(self, other):
        if other is None:
            return False

        return self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not self == other
