# Module `netapp_ontap.resources.cifs_share`

Copyright © 2021 NetApp Inc. All rights reserved.

## Overview

Before any users or applications can access data on the CIFS server over SMB, a CIFS share must be created with sufficient share permissions. CIFS share is a named access point in a volume which is tied to the CIFS server on the SVM. Before creating a CIFS share make sure that the path is valid within the scope of the SVM and that it is reachable. Permissions can be assigned to this newly created share by specifying the 'acls' field. When a CIFS share is created, ONTAP creates a default ACL for this share with 'Full-Control' permissions for an 'Everyone' user.

## Examples

### Creating a CIFS share

To create a CIFS share for a CIFS server, use the following API. Note the return_records=true query parameter used to obtain the newly created entry in the response.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import CifsShare

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = CifsShare()
        resource.access_based_enumeration = False
        resource.acls = [
            {"permission": "no_access", "type": "unix_user", "user_or_group": "root"}
        ]
        resource.change_notify = True
        resource.comment = "HR Department Share"
        resource.encryption = False
        resource.home_directory = False
        resource.name = "TEST"
        resource.oplocks = True
        resource.no_strict_security = True
        resource.path = "/"
        resource.svm.name = "vs1"
        resource.svm.uuid = "000c5cd2-ebdf-11e8-a96e-0050568ea3cb"
        resource.unix_symlink = "local"
        resource.post(hydrate=True)
        print(resource)

Try it out

    CifsShare(
        {
            "comment": "HR Department Share",
            "access_based_enumeration": False,
            "encryption": False,
            "svm": {"name": "vs1", "uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb"},
            "unix_symlink": "local",
            "oplocks": True,
            "change_notify": True,
            "path": "/",
            "no_strict_security": True,
            "home_directory": False,
            "name": "TEST",
            "acls": [
                {"user_or_group": "root", "permission": "no_access", "type": "unix_user"}
            ],
        }
    )

### Retrieving CIFS Shares for all SVMs in the cluster

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import CifsShare

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(list(CifsShare.get_collection(fields="*", return_timeout=15)))

Try it out

    [
        CifsShare(
            {
                "access_based_enumeration": False,
                "encryption": False,
                "svm": {
                    "name": "vs1",
                    "uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/000c5cd2-ebdf-11e8-a96e-0050568ea3cb"
                        }
                    },
                },
                "volume": {"name": "vol1", "uuid": "4e06f1bc-1ddc-42e2-abb2-f221c6a2ab2a"},
                "oplocks": False,
                "_links": {
                    "self": {
                        "href": "/api/protocols/cifs/shares/000c5cd2-ebdf-11e8-a96e-0050568ea3cb/admin%24"
                    }
                },
                "change_notify": False,
                "path": "/",
                "no_strict_security": True,
                "home_directory": False,
                "name": "admin$",
            }
        ),
        CifsShare(
            {
                "access_based_enumeration": False,
                "encryption": False,
                "svm": {
                    "name": "vs1",
                    "uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/000c5cd2-ebdf-11e8-a96e-0050568ea3cb"
                        }
                    },
                },
                "unix_symlink": "local",
                "volume": {"name": "vol1", "uuid": "4e06f1bc-1ddc-42e2-abb2-f221c6a2ab2a"},
                "oplocks": True,
                "_links": {
                    "self": {
                        "href": "/api/protocols/cifs/shares/000c5cd2-ebdf-11e8-a96e-0050568ea3cb/c%24"
                    }
                },
                "change_notify": True,
                "path": "/",
                "no_strict_security": True,
                "home_directory": False,
                "name": "c$",
                "acls": [
                    {
                        "user_or_group": "BUILTIN\\Administrators",
                        "permission": "full_control",
                        "type": "windows",
                    }
                ],
            }
        ),
        CifsShare(
            {
                "access_based_enumeration": False,
                "encryption": False,
                "svm": {
                    "name": "vs1",
                    "uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/000c5cd2-ebdf-11e8-a96e-0050568ea3cb"
                        }
                    },
                },
                "volume": {"name": "vol1", "uuid": "4e06f1bc-1ddc-42e2-abb2-f221c6a2ab2a"},
                "oplocks": False,
                "_links": {
                    "self": {
                        "href": "/api/protocols/cifs/shares/000c5cd2-ebdf-11e8-a96e-0050568ea3cb/ipc%24"
                    }
                },
                "change_notify": False,
                "path": "/",
                "home_directory": False,
                "name": "ipc$",
            }
        ),
        CifsShare(
            {
                "comment": "HR Department Share",
                "access_based_enumeration": False,
                "encryption": False,
                "svm": {
                    "name": "vs1",
                    "uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb",
                    "_links": {
                        "self": {
                            "href": "/api/svm/svms/000c5cd2-ebdf-11e8-a96e-0050568ea3cb"
                        }
                    },
                },
                "unix_symlink": "local",
                "volume": {"name": "vol1", "uuid": "4e06f1bc-1ddc-42e2-abb2-f221c6a2ab2a"},
                "oplocks": True,
                "_links": {
                    "self": {
                        "href": "/api/protocols/cifs/shares/000c5cd2-ebdf-11e8-a96e-0050568ea3cb/TEST"
                    }
                },
                "change_notify": True,
                "path": "/",
                "home_directory": False,
                "name": "TEST",
                "acls": [
                    {
                        "user_or_group": "Everyone",
                        "permission": "full_control",
                        "type": "windows",
                    },
                    {
                        "user_or_group": "root",
                        "permission": "no_access",
                        "type": "unix_user",
                    },
                ],
            }
        ),
    ]

### Retrieving all CIFS Shares for all SVMs in the cluster for which the acls are configured for a "root" user

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import CifsShare

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(
            list(
                CifsShare.get_collection(
                    fields="*", return_timeout=15, **{"acls.user_or_group": "root"}
                )
            )
        )

Try it out

    [
        CifsShare(
            {
                "comment": "HR Department Share",
                "access_based_enumeration": False,
                "encryption": False,
                "svm": {"name": "vs1", "uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb"},
                "unix_symlink": "local",
                "volume": {"name": "vol1", "uuid": "4e06f1bc-1ddc-42e2-abb2-f221c6a2ab2a"},
                "oplocks": True,
                "change_notify": True,
                "path": "/",
                "no_strict_security": True,
                "home_directory": False,
                "name": "TEST",
                "acls": [
                    {
                        "user_or_group": "Everyone",
                        "permission": "full_control",
                        "type": "windows",
                    },
                    {
                        "user_or_group": "root",
                        "permission": "no_access",
                        "type": "unix_user",
                    },
                ],
            }
        )
    ]

### Retrieving a specific CIFS share configuration for an SVM

The configuration being returned is identified by the UUID of its SVM and the name of the share.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import CifsShare

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = CifsShare(
            name="TEST", **{"svm.uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb"}
        )
        resource.get()
        print(resource)

Try it out

    CifsShare(
        {
            "comment": "HR Department Share",
            "access_based_enumeration": False,
            "encryption": False,
            "svm": {"name": "vs1", "uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb"},
            "unix_symlink": "local",
            "volume": {"name": "vol1", "uuid": "4e06f1bc-1ddc-42e2-abb2-f221c6a2ab2a"},
            "oplocks": True,
            "change_notify": True,
            "path": "/",
            "no_strict_security": True,
            "home_directory": False,
            "name": "TEST",
            "acls": [
                {
                    "user_or_group": "Everyone",
                    "permission": "full_control",
                    "type": "windows",
                },
                {"user_or_group": "root", "permission": "no_access", "type": "unix_user"},
            ],
        }
    )

### Updating a specific CIFS share for an SVM

The CIFS share being modified is identified by the UUID of its SVM and the CIFS share name. The CIFS share ACLs cannot be modified with this API.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import CifsShare

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = CifsShare(
            name="TEST", **{"svm.uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb"}
        )
        resource.access_based_enumeration = True
        resource.change_notify = True
        resource.comment = "HR Department Share"
        resource.encryption = False
        resource.oplocks = True
        resource.no_strict_security = True
        resource.path = "/"
        resource.unix_symlink = "widelink"
        resource.patch()

### Removing a specific CIFS share for an SVM

The CIFS share being removed is identified by the UUID of its SVM and the CIFS share name.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import CifsShare

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = CifsShare(
            name="test", **{"svm.uuid": "000c5cd2-ebdf-11e8-a96e-0050568ea3cb"}
        )
        resource.delete()

## Classes

`class CifsShare (*args, **kwargs)`

  CIFS share is a named access point in a volume. Before users and applications can access data on the CIFS server over SMB, a CIFS share must be created with sufficient share permission. CIFS shares are tied to the CIFS server on the SVM. When a CIFS share is created, ONTAP creates a default ACL for the share with Full Control permissions for Everyone.

  Initialize the instance of the resource.

  Any keyword arguments are set on the instance as properties. For example, if the class was named 'MyResource', then this statement would be true:

      MyResource(name='foo').name == 'foo'

  ## Args

  `*args`
    Each positional argument represents a parent key as used in the URL of the object. That is, each value will be used to fill in a segment of the URL which refers to some parent object. The order of these arguments must match the order they are specified in the URL, from left to right.
  `**kwargs`
    each entry will have its key set as an attribute name on the instance and its value will be the value of that attribute.

  ### Ancestors

  - Resource

  ### Static methods

  `def count_collection(*args, connection: HostConnection = None, **kwargs) -> int`

    Retrieves CIFS shares.

    ### Related ONTAP commands

    - `vserver cifs share show`
    - `vserver cifs share properties show`

    ### Learn more

    - `DOC /protocols/cifs/shares`

    Fetch a count of all objects of this type from the host.

    This calls GET on the object to determine the number of records. It is more efficient than calling get_collection() because it will not construct any objects. Query parameters can be passed in as kwargs to determine a count of objects that match some filtered criteria.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to get the count of bars for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host. These query parameters can affect the count. A return_records query param will be ignored.

    ## Returns

    On success, returns an integer count of the objects of this type. On failure, returns -1.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400, or if there is no connection available to use either passed in or on the library.

  `def delete_collection(*args, body: typing.Union = None, connection: HostConnection = None, **kwargs) -> NetAppResponse`

    Deletes a CIFS share.

    ### Related ONTAP commands

    - `vserver cifs share delete`

    ### Learn more

    - `DOC /protocols/cifs/shares`

    Delete all objects in a collection which match the given query.

    All records on the host which match the query will be deleted.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to delete the collection of bars for a particular foo, the foo.name value should be passed.
    `body`
      The body of the delete request. This could be a Resource instance or a dictionary object.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host. Only resources matching this query will be deleted.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def find(*args, connection: HostConnection = None, **kwargs) -> Resource`

    Retrieves CIFS shares.

    ### Related ONTAP commands

    - `vserver cifs share show`
    - `vserver cifs share properties show`

    ### Learn more

    - `DOC /protocols/cifs/shares`

    Find an instance of an object on the host given a query.

    The host will be queried with the provided key/value pairs to find a matching resource. If 0 are found, None will be returned. If more than 1 is found, an error will be raised or returned. If there is exactly 1 matching record, then it will be returned.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to find a bar for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host.

    ## Returns

    A `Resource` object containing the details of the object or None if no matches were found.

    ## Raises

    `NetAppRestError`: If the API call returned more than 1 matching resource.

  `def get_collection(*args, connection: HostConnection = None, max_records: int = None, **kwargs) -> typing.Iterable`

    Retrieves CIFS shares.

    ### Related ONTAP commands

    - `vserver cifs share show`
    - `vserver cifs share properties show`

    ### Learn more

    - `DOC /protocols/cifs/shares`

    Fetch a list of all objects of this type from the host.

    This is a lazy fetch, making API calls only as necessary when the result of this call is iterated over. For instance, if max_records is set to 5, then iterating over the collection causes an API call to be sent to the server once for every 5 records. If the client stops iterating before getting to the 6th record, then no additional API calls are made.

    ## Args

    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to get the collection of bars for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `max_records`
      The maximum number of records to return per call
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host.

    ## Returns

    A list of `Resource` objects

    ## Raises

    `NetAppRestError`: If there is no connection available to use either passed in or on the library. This would be not be raised when get_collection() is called, but rather when the result is iterated.

  `def patch_collection(body: dict, *args, connection: HostConnection = None, **kwargs) -> NetAppResponse`

    Updates a CIFS share.

    ### Related ONTAP commands

    - `vserver cifs share modify`
    - `vserver cifs share properties add`
    - `vserver cifs share properties remove`

    ### Learn more

    - `DOC /protocols/cifs/shares`

    Patch all objects in a collection which match the given query.

    All records on the host which match the query will be patched with the provided body.

    ## Args

    `body`
      A dictionary of name/value pairs to set on all matching members of the collection.
    `*args`
      Each entry represents a parent key which is used to build the path to the child object. If the URL definition were /api/foos/{foo.name}/bars, then to patch the collection of bars for a particular foo, the foo.name value should be passed.
    `connection`
      The `HostConnection` object to use for this API call. If unset, tries to use the connection which is set globally for the library or from the current context.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host. Only resources matching this query will be patched.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  ### Methods

  `def delete(self, body: typing.Union = None, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse`

    Deletes a CIFS share.

    ### Related ONTAP commands

    - `vserver cifs share delete`

    ### Learn more

    - `DOC /protocols/cifs/shares`

    Send a deletion request to the host for this object.

    ## Args

    `body`
      The body of the delete request. This could be a Resource instance or a dictionary object.
    `poll`
      If set to True, the call will not return until the asynchronous job on the host has completed. Has no effect if the host did not return a job response.
    `poll_interval`
      If the operation returns a job, this specifies how often to query the job for updates.
    `poll_timeout`
      If the operation returns a job, this specifies how long to continue monitoring the job's status for completion.
    `**kwargs`
      Any key/value pairs passed will be sent as query parameters to the host.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def get(self, **kwargs) -> NetAppResponse`

    Retrieves a CIFS share.

    ### Related ONTAP commands

    - `vserver cifs share show`
    - `vserver cifs share properties show`

    ### Learn more

    - `DOC /protocols/cifs/shares`

    Fetch the details of the object from the host.

    Requires the keys to be set (if any). After returning, new or changed properties from the host will be set on the instance.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def patch(self, hydrate: bool = False, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse`

    Updates a CIFS share.

    ### Related ONTAP commands

    - `vserver cifs share modify`
    - `vserver cifs share properties add`
    - `vserver cifs share properties remove`

    ### Learn more

    - `DOC /protocols/cifs/shares`

    Send the difference in the object's state to the host as a modification request.

    Calculates the difference in the object's state since the last time we interacted with the host and sends this in the request body.

    ## Args

    `hydrate`
      If set to True, after the response is received from the call, a a GET call will be made to refresh all fields of the object.
    `poll`
      If set to True, the call will not return until the asynchronous job on the host has completed. Has no effect if the host did not return a job response.
    `poll_interval`
      If the operation returns a job, this specifies how often to query the job for updates.
    `poll_timeout`
      If the operation returns a job, this specifies how long to continue monitoring the job's status for completion.
    `**kwargs`
      Any key/value pairs passed will normally be sent as query parameters to the host. If any of these pairs are parameters that are sent as formdata then only parameters of that type will be accepted and all others will be discarded.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  `def post(self, hydrate: bool = False, poll: bool = True, poll_interval: typing.Union = None, poll_timeout: typing.Union = None, **kwargs) -> NetAppResponse`

    Creates a CIFS share.

    ### Required properties

    - `svm.uuid` or `svm.name` - Existing SVM in which to create the CIFS share.
    - `name` - Name of the CIFS share.
    - `path` - Path in the owning SVM namespace that is shared through this share.

    ### Recommended optional properties

    - `comment` - Optionally choose to add a text comment of up to 256 characters about the CIFS share.
    - `acls` - Optionally choose to add share permissions that users and groups have on the CIFS share.

    ### Default property values

    If not specified in POST, the following default property values are assigned: * `home_directory` - false * `oplocks` - true * `access_based_enumeration` - false * `change_notify` - true * `encryption` - false * `unix_symlink` - local

    ### Related ONTAP commands

    - `vserver cifs share create`
    - `vserver cifs share properties add`
    - `vserver cifs share access-control create`

    ### Learn more

    - `DOC /protocols/cifs/shares`

    Send this object to the host as a creation request.

    ## Args

    `hydrate`
      If set to True, after the response is received from the call, a a GET call will be made to refresh all fields of the object.
    `poll`
      If set to True, the call will not return until the asynchronous job on the host has completed. Has no effect if the host did not return a job response.
    `poll_interval`
      If the operation returns a job, this specifies how often to query the job for updates.
    `poll_timeout`
      If the operation returns a job, this specifies how long to continue monitoring the job's status for completion.
    `**kwargs`
      Any key/value pairs passed will normally be sent as query parameters to the host. If any of these pairs are parameters that are sent as formdata then only parameters of that type will be accepted and all others will be discarded.

    ## Returns

    A `NetAppResponse` object containing the details of the HTTP response.

    ## Raises

    `NetAppRestError`: If the API call returned a status code >= 400

  ### Inherited members

  - `Resource`:
    - `from_dict`
    - `get_collection_url`
    - `get_connection`
    - `instance_location`
    - `path_keys`
    - `poll`
    - `set_connection`
    - `to_dict`
`class CifsShareSchema (*, only: typing.Union = None, exclude: typing.Union = (), many: bool = False, context: typing.Dict = None, load_only: typing.Union = (), dump_only: typing.Union = (), partial: typing.Union = False, unknown: str = None)`

  The fields of the CifsShare object

  ### Ancestors

  - netapp_ontap.resource.ResourceSchema
  - marshmallow.schema.Schema
  - marshmallow.base.SchemaABC

  ### Class variables

  `access_based_enumeration GET POST PATCH`

    If enabled, all folders inside this share are visible to a user based on that individual user access right; prevents the display of folders or other shared resources that the user does not have access to.

  `acls GET POST`

    The acls field of the cifs_share.

  `change_notify GET POST PATCH`

    Specifies whether CIFS clients can request for change notifications for directories on this share.

  `comment GET POST PATCH`

    Specify the CIFS share descriptions.

    Example: HR Department Share

  `encryption GET POST PATCH`

    Specifies that SMB encryption must be used when accessing this share. Clients that do not support encryption are not able to access this share.

  `home_directory GET POST`

    Specifies whether or not the share is a home directory share, where the share and path names are dynamic. ONTAP home directory functionality automatically offer each user a dynamic share to their home directory without creating an individual SMB share for each user. The ONTAP CIFS home directory feature enable us to configure a share that maps to different directories based on the user that connects to it. Instead of creating a separate shares for each user, a single share with a home directory parameters can be created. In a home directory share, ONTAP dynamically generates the share-name and share-path by substituting %w, %u, and %d variables with the corresponding Windows user name, UNIX user name, and domain name, respectively.

  `links GET`

    The links field of the cifs_share.

  `name GET POST`

    Specifies the name of the CIFS share that you want to create. If this is a home directory share then the share name includes the pattern as %w (Windows user name), %u (UNIX user name) and %d (Windows domain name) variables in any combination with this parameter to generate shares dynamically.

    Example: HR_SHARE

  `no_strict_security GET POST PATCH`

    Specifies whether or not CIFS clients can follow a unix symlinks outside the share boundaries.

  `oplocks GET POST PATCH`

    Specify whether opportunistic locks are enabled on this share. "Oplocks" allow clients to lock files and cache content locally, which can increase performance for file operations.

  `path GET POST PATCH`

    The fully-qualified pathname in the owning SVM namespace that is shared through this share. If this is a home directory share then the path should be dynamic by specifying the pattern %w (Windows user name), %u (UNIX user name), or %d (domain name) variables in any combination. ONTAP generates the path dynamically for the connected user and this path is appended to each search path to find the full Home Directory path.

    Example: /volume_1/eng_vol/

  `svm GET POST PATCH`

    The svm field of the cifs_share.

  `unix_symlink GET POST PATCH`

    Controls the access of UNIX symbolic links to CIFS clients. The supported values are:

        * local - Enables only local symbolic links which is within the same CIFS share.
        * widelink - Enables both local symlinks and widelinks.
        * disable - Disables local symlinks and widelinks.

    Valid choices:

    - local
    - widelink
    - disable
  `volume GET POST PATCH`

    The volume field of the cifs_share.