# Module `netapp_ontap.resources.autosupport_message`

Copyright © 2021 NetApp Inc. All rights reserved.

## Overview

Use this API to invoke and retrieve AutoSupport messages from the nodes in the cluster.

This API supports POST and GET calls. Use a POST call to invoke AutoSupport and a GET call to retrieve AutoSupport messages.

## Examples

### Invoking an AutoSupport on all nodes in the cluster

The following example invokes an AutoSupport on every node in the cluster. Note that AutoSupport is invoked on all nodes in the cluster if the `node` parameter is omitted. Also, note that the `subject` line is the same when invoking on all nodes.

By default, the response is an empty object. If `return_records=true` is passed in the request, the response includes information about the node and the index of the invoked AutoSupport message.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import AutosupportMessage

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = AutosupportMessage()
        resource.message = "test_msg"
        resource.type = "all"
        resource.post(hydrate=True)
        print(resource)

Try it out

    AutosupportMessage(
        {
            "index": 4,
            "node": {
                "name": "node1",
                "uuid": "092e0298-f250-11e8-9a05-005056bb6666",
                "_links": {
                    "self": {
                        "href": "/api/cluster/nodes/092e0298-f250-11e8-9a05-005056bb6666"
                    }
                },
            },
        }
    )

### Invoking an AutoSupport on a single node

The following examples invoke an AutoSupport on a single node in the cluster. Note that AutoSupport is invoked on all nodes in the cluster if the `node` parameter is omitted. You can specify the node-name with either `node` or `node.name` parameter. You can also specify UUID of the node with the `node.uuid` parameter.

By default, the response is an empty object. If `return_records=true` is passed in the request, the response includes information about the node and the index of the invoked AutoSupport message.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import AutosupportMessage

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = AutosupportMessage()
        resource.message = "test_msg"
        resource.type = "test"
        resource.node.name = "node1"
        resource.post(hydrate=True)
        print(resource)

Try it out

    AutosupportMessage(
        {
            "index": 8,
            "node": {
                "name": "node1",
                "uuid": "092e0298-f250-11e8-9a05-005056bb6666",
                "_links": {
                    "self": {
                        "href": "/api/cluster/nodes/092e0298-f250-11e8-9a05-005056bb6666"
                    }
                },
            },
        }
    )

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import AutosupportMessage

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = AutosupportMessage()
        resource.message = "test_msg"
        resource.type = "test"
        resource.node.name = "node2"
        resource.post(hydrate=True)
        print(resource)

Try it out

    AutosupportMessage(
        {
            "index": 4,
            "node": {
                "name": "node2",
                "uuid": "e47d2630-f250-11e8-b186-005056bb5cab",
                "_links": {
                    "self": {
                        "href": "/api/cluster/nodes/e47d2630-f250-11e8-b186-005056bb5cab"
                    }
                },
            },
        }
    )

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import AutosupportMessage

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        resource = AutosupportMessage()
        resource.message = "test_msg"
        resource.type = "test"
        resource.node.uuid = "092e0298-f250-11e8-9a05-005056bb6666"
        resource.post(hydrate=True)
        print(resource)

Try it out

    AutosupportMessage(
        {
            "index": 5,
            "node": {
                "name": "node1",
                "uuid": "092e0298-f250-11e8-9a05-005056bb6666",
                "_links": {
                    "self": {
                        "href": "/api/cluster/nodes/092e0298-f250-11e8-9a05-005056bb6666"
                    }
                },
            },
        }
    )

### Retrieving AutoSupport messages from all nodes in the cluster

The following example retrieves AutoSupport messages from every node in the cluster. Note that if the fields=* parameter is not specified, only node, index, and destination fields are returned. Filters can be added on the fields to limit the results.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import AutosupportMessage

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

Try it out

    [
        AutosupportMessage(
            {
                "index": 1,
                "state": "ignore",
                "destination": "smtp",
                "node": {
                    "name": "node1",
                    "uuid": "092e0298-f250-11e8-9a05-005056bb6666",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/092e0298-f250-11e8-9a05-005056bb6666"
                        }
                    },
                },
                "generated_on": "2019-03-28T10:18:04-04:00",
                "subject": "USER_TRIGGERED (TEST:test_msg)",
            }
        ),
        AutosupportMessage(
            {
                "index": 1,
                "state": "sent_successful",
                "destination": "http",
                "node": {
                    "name": "node1",
                    "uuid": "092e0298-f250-11e8-9a05-005056bb6666",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/092e0298-f250-11e8-9a05-005056bb6666"
                        }
                    },
                },
                "generated_on": "2019-03-28T10:18:04-04:00",
                "subject": "USER_TRIGGERED (TEST:test_msg)",
            }
        ),
        AutosupportMessage(
            {
                "index": 1,
                "state": "ignore",
                "destination": "noteto",
                "node": {
                    "name": "node1",
                    "uuid": "092e0298-f250-11e8-9a05-005056bb6666",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/092e0298-f250-11e8-9a05-005056bb6666"
                        }
                    },
                },
                "generated_on": "2019-03-28T10:18:04-04:00",
                "subject": "USER_TRIGGERED (TEST:test_msg)",
            }
        ),
        AutosupportMessage(
            {
                "index": 1,
                "state": "ignore",
                "destination": "smtp",
                "node": {
                    "name": "node2",
                    "uuid": "e47d2630-f250-11e8-b186-005056bb5cab",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/e47d2630-f250-11e8-b186-005056bb5cab"
                        }
                    },
                },
                "generated_on": "2019-03-28T10:18:06-04:00",
                "subject": "USER_TRIGGERED (TEST:test_msg)",
            }
        ),
        AutosupportMessage(
            {
                "index": 1,
                "state": "sent_successful",
                "destination": "http",
                "node": {
                    "name": "node2",
                    "uuid": "e47d2630-f250-11e8-b186-005056bb5cab",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/e47d2630-f250-11e8-b186-005056bb5cab"
                        }
                    },
                },
                "generated_on": "2019-03-28T10:18:06-04:00",
                "subject": "USER_TRIGGERED (TEST:test_msg)",
            }
        ),
        AutosupportMessage(
            {
                "index": 1,
                "state": "ignore",
                "destination": "noteto",
                "node": {
                    "name": "node2",
                    "uuid": "e47d2630-f250-11e8-b186-005056bb5cab",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/e47d2630-f250-11e8-b186-005056bb5cab"
                        }
                    },
                },
                "generated_on": "2019-03-28T10:18:06-04:00",
                "subject": "USER_TRIGGERED (TEST:test_msg)",
            }
        ),
    ]

### Retrieving AutoSupport messages from a specific node and has 'sent_succesful' state

The following example retrieves AutoSupport messages from a specific node in the cluster. Note that if the `fields=*` parameter is not specified, only node, index, and destination fields are returned. This example uses a filter on the `node.name` and `state` fields. You can add filters to any fields in the response.

    from netapp_ontap import HostConnection
    from netapp_ontap.resources import AutosupportMessage

    with HostConnection("<mgmt-ip>", username="admin", password="password", verify=False):
        print(
            list(
                AutosupportMessage.get_collection(
                    state="sent_successful",
                    fields="*",
                    return_timeout=15,
                    **{"node.name": "node1"}
                )
            )
        )

Try it out

    [
        AutosupportMessage(
            {
                "index": 1,
                "state": "sent_successful",
                "destination": "http",
                "node": {
                    "name": "node1",
                    "uuid": "092e0298-f250-11e8-9a05-005056bb6666",
                    "_links": {
                        "self": {
                            "href": "/api/cluster/nodes/092e0298-f250-11e8-9a05-005056bb6666"
                        }
                    },
                },
                "generated_on": "2019-03-28T10:18:04-04:00",
                "subject": "USER_TRIGGERED (TEST:test_msg)",
            }
        )
    ]

## Classes

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

  Allows interaction with AutosupportMessage objects on the host

  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 AutoSupport message history from all nodes in the cluster.

    There can be a short delay on invoked AutoSupport messages showing in history, dependent on processing of other AutoSupports in the queue.

    ### Related ONTAP commands

    - `system node autosupport history show`

    ### Learn more

    - `DOC /support/autosupport/messages`

    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 find(*args, connection: HostConnection = None, **kwargs) -> Resource`

    Retrieves AutoSupport message history from all nodes in the cluster.

    There can be a short delay on invoked AutoSupport messages showing in history, dependent on processing of other AutoSupports in the queue.

    ### Related ONTAP commands

    - `system node autosupport history show`

    ### Learn more

    - `DOC /support/autosupport/messages`

    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 AutoSupport message history from all nodes in the cluster.

    There can be a short delay on invoked AutoSupport messages showing in history, dependent on processing of other AutoSupports in the queue.

    ### Related ONTAP commands

    - `system node autosupport history show`

    ### Learn more

    - `DOC /support/autosupport/messages`

    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.

  ### Methods

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

    Creates and sends an AutoSupport message with the provided input parameters.

    Important note: * By default, the response is an empty object. If `return_records=true` is passed in the request, the response includes information about the node and the index of the invoked AutoSupport message.

    ### Recommended optional properties

    - `message` - Message included in the AutoSupport subject. Use this to identify the generated AutoSupport message.

    ### Default property values

    If not specified in POST, the following are the default property values: * `type` - all * `node.name` or `node.uuid` - Not specifying these properties invokes AutoSupport on all nodes in the cluster.

    ### Related ONTAP commands

    - `system node autosupport invoke`

    ### Learn more

    - `DOC /support/autosupport/messages`

    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 AutosupportMessageSchema (*, 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 AutosupportMessage object

  ### Ancestors

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

  ### Class variables

  `destination GET`

    Destination for the AutoSupport

    Valid choices:

    - smtp
    - http
    - noteto
    - retransmit
  `error GET POST PATCH`

    The error field of the autosupport_message.

  `generated_on GET`

    Date and Time of AutoSupport generation in ISO-8601 format

    Example: 2019-03-25T21:30:04.000+0000

  `index GET`

    Sequence number of the AutoSupport

    Example: 9

  `message POST`

    Message included in the AutoSupport subject

    Example: invoked_test_autosupport_rest

  `node GET POST`

    The node field of the autosupport_message.

  `state GET`

    State of AutoSupport delivery

    Valid choices:

    - initializing
    - collection_failed
    - collection_in_progress
    - queued
    - transmitting
    - sent_successful
    - ignore
    - re_queued
    - transmission_failed
    - ondemand_ignore
    - cancelled
  `subject GET`

    Subject line for the AutoSupport

    Example: WEEKLY_LOG

  `type POST`

    Type of AutoSupport collection to issue

    Valid choices:

    - test
    - performance
    - all
  `uri POST`

    Alternate destination for the AutoSupport

    Example: http://1.2.3.4/delivery_uri