# Module `netapp_ontap.resources.fpolicy_event`

Copyright © 2020 NetApp Inc. All rights reserved.

## Overview

FPolicy events configurations allow you to specify which file access is monitored. As part of an FPolicy event, you can configure the SVM for which the events are generated, the name of the event configuration, the protocol (cifs, nfsv3/nfsv4) for which the events are generated, the file operations which are monitored, and filters that can be used to filter the unwanted notification generation for a specified protocol and file operation. Each protocol has a set of supported file operations and filters. An SVM can have multiple events. A single FPolicy policy can have multiple FPolicy events.

## Examples

### Creating an FPolicy event for a CIFS protocol with all the supported file operations and filters

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FpolicyEvent

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = FpolicyEvent("4f643fb4-fd21-11e8-ae49-0050568e2c1e")
        resource.file_operations.close = True
        resource.file_operations.create = True
        resource.file_operations.create_dir = True
        resource.file_operations.delete = True
        resource.file_operations.delete_dir = True
        resource.file_operations.getattr = True
        resource.file_operations.open = True
        resource.file_operations.read = True
        resource.file_operations.rename = True
        resource.file_operations.rename_dir = True
        resource.file_operations.setattr = True
        resource.file_operations.write = True
        resource.filters.close_with_modification = True
        resource.filters.close_with_read = True
        resource.filters.close_without_modification = True
        resource.filters.first_read = True
        resource.filters.first_write = True
        resource.filters.monitor_ads = True
        resource.filters.offline_bit = True
        resource.filters.open_with_delete_intent = True
        resource.filters.open_with_write_intent = True
        resource.filters.write_with_size_change = True
        resource.name = "event_cifs"
        resource.protocol = "cifs"
        resource.volume_monitoring = True
        resource.post(hydrate=True)
        print(resource)

Try it out

    FpolicyEvent(
        {
            "volume_monitoring": True,
            "file_operations": {
                "rename": True,
                "open": True,
                "getattr": True,
                "create": True,
                "delete": True,
                "rename_dir": True,
                "delete_dir": True,
                "write": True,
                "close": True,
                "create_dir": True,
                "setattr": True,
                "read": True,
            },
            "protocol": "cifs",
            "name": "event_cifs",
            "filters": {
                "close_with_read": True,
                "monitor_ads": True,
                "offline_bit": True,
                "open_with_write_intent": True,
                "close_without_modification": True,
                "first_write": True,
                "open_with_delete_intent": True,
                "close_with_modification": True,
                "write_with_size_change": True,
                "first_read": True,
            },
        }
    )

### Creating an FPolicy event for an NFS protocol with all the supported file operations and filters

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FpolicyEvent

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = FpolicyEvent("4f643fb4-fd21-11e8-ae49-0050568e2c1e")
        resource.file_operations.create = True
        resource.file_operations.create_dir = True
        resource.file_operations.delete = True
        resource.file_operations.delete_dir = True
        resource.file_operations.link = True
        resource.file_operations.lookup = True
        resource.file_operations.read = True
        resource.file_operations.rename = True
        resource.file_operations.rename_dir = True
        resource.file_operations.setattr = True
        resource.file_operations.symlink = True
        resource.file_operations.write = True
        resource.filters.offline_bit = True
        resource.filters.write_with_size_change = True
        resource.name = "event_nfsv3"
        resource.protocol = "nfsv3"
        resource.volume_monitoring = False
        resource.post(hydrate=True)
        print(resource)

Try it out

    FpolicyEvent(
        {
            "volume_monitoring": False,
            "file_operations": {
                "symlink": True,
                "lookup": True,
                "rename": True,
                "create": True,
                "delete": True,
                "link": True,
                "rename_dir": True,
                "delete_dir": True,
                "write": True,
                "create_dir": True,
                "setattr": True,
                "read": True,
            },
            "protocol": "nfsv3",
            "name": "event_nfsv3",
            "filters": {"offline_bit": True, "write_with_size_change": True},
        }
    )

### Retrieving all of the FPolicy event configurations for a specified SVM

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FpolicyEvent

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(
            list(
                FpolicyEvent.get_collection(
                    "4f643fb4-fd21-11e8-ae49-0050568e2c1e", fields="*", return_timeout=15
                )
            )
        )

Try it out

    [
        FpolicyEvent(
            {
                "volume_monitoring": False,
                "file_operations": {
                    "symlink": False,
                    "lookup": False,
                    "rename": False,
                    "open": False,
                    "getattr": False,
                    "create": False,
                    "delete": False,
                    "link": False,
                    "rename_dir": False,
                    "delete_dir": False,
                    "write": False,
                    "close": True,
                    "create_dir": False,
                    "setattr": False,
                    "read": False,
                },
                "protocol": "cifs",
                "name": "cluster",
                "filters": {
                    "setattr_with_owner_change": False,
                    "setattr_with_allocation_size_change": False,
                    "setattr_with_sacl_change": False,
                    "close_with_read": True,
                    "setattr_with_dacl_change": False,
                    "setattr_with_mode_change": False,
                    "setattr_with_modify_time_change": False,
                    "monitor_ads": False,
                    "setattr_with_group_change": False,
                    "setattr_with_size_change": False,
                    "offline_bit": False,
                    "exclude_directory": False,
                    "setattr_with_creation_time_change": False,
                    "open_with_write_intent": False,
                    "close_without_modification": False,
                    "first_write": False,
                    "setattr_with_access_time_change": False,
                    "open_with_delete_intent": False,
                    "close_with_modification": False,
                    "write_with_size_change": False,
                    "first_read": False,
                },
            }
        ),
        FpolicyEvent(
            {
                "volume_monitoring": True,
                "file_operations": {
                    "symlink": False,
                    "lookup": False,
                    "rename": True,
                    "open": True,
                    "getattr": True,
                    "create": True,
                    "delete": True,
                    "link": False,
                    "rename_dir": True,
                    "delete_dir": True,
                    "write": True,
                    "close": True,
                    "create_dir": True,
                    "setattr": True,
                    "read": True,
                },
                "protocol": "cifs",
                "name": "event_cifs",
                "filters": {
                    "setattr_with_owner_change": False,
                    "setattr_with_allocation_size_change": False,
                    "setattr_with_sacl_change": False,
                    "close_with_read": True,
                    "setattr_with_dacl_change": False,
                    "setattr_with_mode_change": False,
                    "setattr_with_modify_time_change": False,
                    "monitor_ads": True,
                    "setattr_with_group_change": False,
                    "setattr_with_size_change": False,
                    "offline_bit": True,
                    "exclude_directory": False,
                    "setattr_with_creation_time_change": False,
                    "open_with_write_intent": True,
                    "close_without_modification": True,
                    "first_write": True,
                    "setattr_with_access_time_change": False,
                    "open_with_delete_intent": True,
                    "close_with_modification": True,
                    "write_with_size_change": True,
                    "first_read": True,
                },
            }
        ),
    ]

### Retrieving a specific FPolicy event configuration for an SVM

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FpolicyEvent

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = FpolicyEvent("4f643fb4-fd21-11e8-ae49-0050568e2c1e", name="event_cifs")
        resource.get(fields="*", return_timeout=15)
        print(resource)

Try it out

    FpolicyEvent(
        {
            "volume_monitoring": True,
            "file_operations": {
                "symlink": False,
                "lookup": False,
                "rename": True,
                "open": True,
                "getattr": True,
                "create": True,
                "delete": True,
                "link": False,
                "rename_dir": True,
                "delete_dir": True,
                "write": True,
                "close": True,
                "create_dir": True,
                "setattr": True,
                "read": True,
            },
            "protocol": "cifs",
            "name": "event_cifs",
            "filters": {
                "setattr_with_owner_change": False,
                "setattr_with_allocation_size_change": False,
                "setattr_with_sacl_change": False,
                "close_with_read": True,
                "setattr_with_dacl_change": False,
                "setattr_with_mode_change": False,
                "setattr_with_modify_time_change": False,
                "monitor_ads": True,
                "setattr_with_group_change": False,
                "setattr_with_size_change": False,
                "offline_bit": True,
                "exclude_directory": False,
                "setattr_with_creation_time_change": False,
                "open_with_write_intent": True,
                "close_without_modification": True,
                "first_write": True,
                "setattr_with_access_time_change": False,
                "open_with_delete_intent": True,
                "close_with_modification": True,
                "write_with_size_change": True,
                "first_read": True,
            },
        }
    )

### Updating a specific FPolicy event configuration for a specified SVM

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FpolicyEvent

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = FpolicyEvent("4f643fb4-fd21-11e8-ae49-0050568e2c1e", name="event_cifs")
        resource.file_operations.close = False
        resource.file_operations.create = False
        resource.file_operations.read = True
        resource.filters.close_with_modification = False
        resource.filters.close_with_read = False
        resource.filters.close_without_modification = False
        resource.protocol = "cifs"
        resource.volume_monitoring = False
        resource.patch()

### Deleting a specific FPolicy event configuration for a specific SVM

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import FpolicyEvent

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = FpolicyEvent("4f643fb4-fd21-11e8-ae49-0050568e2c1e", name="event_cifs")
        resource.delete()

## Classes

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

  The information that a FPolicy process needs to determine what file access operations to monitor and for which of the monitored events notifications should be sent to the external FPolicy server.

  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 FPolicy event configurations for all events for a specified SVM. ONTAP allows the creation of cluster-level FPolicy events that act as a template for all the data SVMs belonging to the cluster. These cluster-level FPolicy events are also retrieved for the specified SVM.

    ### Related ONTAP commands

    - `fpolicy policy event show`

    ### Learn more

    - `DOC /protocols/fpolicy/{svm.uuid}/events`

    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 specific FPolicy event configuration for an SVM. A cluster-level FPolicy event configuration cannot be modified for a data SVM through REST. An FPolicy event that is attached to an FPolicy policy cannot be deleted.

    ### Related ONTAP commands

    - `fpolicy policy event delete`

    ### Learn more

    - `DOC /protocols/fpolicy/{svm.uuid}/events`

    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 patched.

    ## 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 FPolicy event configurations for all events for a specified SVM. ONTAP allows the creation of cluster-level FPolicy events that act as a template for all the data SVMs belonging to the cluster. These cluster-level FPolicy events are also retrieved for the specified SVM.

    ### Related ONTAP commands

    - `fpolicy policy event show`

    ### Learn more

    - `DOC /protocols/fpolicy/{svm.uuid}/events`

    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 FPolicy event configurations for all events for a specified SVM. ONTAP allows the creation of cluster-level FPolicy events that act as a template for all the data SVMs belonging to the cluster. These cluster-level FPolicy events are also retrieved for the specified SVM.

    ### Related ONTAP commands

    - `fpolicy policy event show`

    ### Learn more

    - `DOC /protocols/fpolicy/{svm.uuid}/events`

    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 specific FPolicy event configuration for an SVM. A cluster-level FPolicy event configuration cannot be modified for a data SVM through REST. When the file operations and filters fields are modified, the previous values are retained and new values are added to the list of previous values. To remove a particular file operation or filter, set its value to false in the request.

    ### Related ONTAP commands

    - `fpolicy policy event modify`

    ### Learn more

    - `DOC /protocols/fpolicy/{svm.uuid}/events`

    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 specific FPolicy event configuration for an SVM. A cluster-level FPolicy event configuration cannot be modified for a data SVM through REST. An FPolicy event that is attached to an FPolicy policy cannot be deleted.

    ### Related ONTAP commands

    - `fpolicy policy event delete`

    ### Learn more

    - `DOC /protocols/fpolicy/{svm.uuid}/events`

    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 specific FPolicy event configuration for an SVM. A cluster-level FPolicy event configuration cannot be retrieved for a data SVM through a REST API.

    ### Related ONTAP commands

    - `fpolicy policy event show`

    ### Learn more

    - `DOC /protocols/fpolicy/{svm.uuid}/events`

    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 specific FPolicy event configuration for an SVM. A cluster-level FPolicy event configuration cannot be modified for a data SVM through REST. When the file operations and filters fields are modified, the previous values are retained and new values are added to the list of previous values. To remove a particular file operation or filter, set its value to false in the request.

    ### Related ONTAP commands

    - `fpolicy policy event modify`

    ### Learn more

    - `DOC /protocols/fpolicy/{svm.uuid}/events`

    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 an FPolicy event configuration for a specified SVM. FPolicy event creation is allowed only on data SVMs. When a protocol is specified, you must specify a file operation or a file operation and filters.

    ### Required properties

    - `svm.uuid` - Existing SVM in which to create the FPolicy event.
    - `name` - Name of the FPolicy event.

    ### Recommended optional properties

    - `file-operations` - List of file operations to monitor.
    - `protocol` - Protocol for which the file operations should be monitored.
    - `filters` - List of filters for the specified file operations.

    ### Default property values

    If not specified in POST, the following default property values are assigned: * `file_operations.*` - false * `filters.*` - false * `volume-monitoring` - false

    ### Related ONTAP commands

    - `fpolicy policy event create`

    ### Learn more

    - `DOC /protocols/fpolicy/{svm.uuid}/events`

    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 FpolicyEventSchema (*, 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 FpolicyEvent object

  ### Ancestors

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

  ### Class variables

  `file_operations GET POST PATCH`

    The file_operations field of the fpolicy_event.

  `filters GET POST PATCH`

    The filters field of the fpolicy_event.

  `name GET POST`

    Specifies the name of the FPolicy event.

    Example: event_nfs_close

  `protocol GET POST PATCH`

    Protocol for which event is created. If you specify protocol, then you must also specify a valid value for the file operation parameters. The value of this parameter must be one of the following:

        * cifs  - for the CIFS protocol.
        * nfsv3 - for the NFSv3 protocol.
        * nfsv4 - for the NFSv4 protocol.

    Valid choices:

    - cifs
    - nfsv3
    - nfsv4
  `volume_monitoring GET POST PATCH`

    Specifies whether volume operation monitoring is required.