dxlclient.message.Request - python examples

Here are the examples of the python api dxlclient.message.Request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

10 Examples 7

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def send_mitigation_action_by_ip(self, ip_address, action):
        """
        Send an EPS mitigation action for an endpoint IP address.

        :param str ip_address: IP address of the endpoint for which the action
            should be performed.
        :param dxlciscopxgridclient.constants.EpsAction action: The action to
            perform.
        :return: Results of the attempt to send the action. The results for a
            successful send should look similar to this:

            .. code-block:: json

                {
                    "gid": "150",
                    "macInterface": "00:11:22:33:44:55",
                    "mitigationStatus": "complete"
                }
        :rtype: dict
        :raises Exception: If no session has been established for an endpoint
            which corresponds to the IP address.
        """
        request = Request(self._EPS_SEND_MITIGATION_ACTION_BY_IP)
        MessageUtils.dict_to_json_payload(
            request,
            {_PARAM_IP: ip_address,
             _PARAM_ACTION: action, "foo": "bar"})
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def send_mitigation_action_by_mac(self, mac_address, action):
        """
        Send an EPS mitigation action for an endpoint MAC address.

        :param str mac_address: MAC address of the endpoint for which the
            action should be performed.
        :param dxlciscopxgridclient.constants.EpsAction action: The action to
            perform.
        :return: Results of the attempt to send the action. The results for a
            successful send should look similar to this:

            .. code-block:: json

                {
                    "gid": "150",
                    "macInterface": "00:11:22:33:44:55",
                    "mitigationStatus": "complete"
                }
        :rtype: dict
        """
        request = Request(self._EPS_SEND_MITIGATION_ACTION_BY_MAC)
        MessageUtils.dict_to_json_payload(
            request,
            {_PARAM_MAC: mac_address,
             _PARAM_ACTION: action})
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def retrieve_all_policies(self):
        """
        Retrieve information for all ANC policies.

        :return: The policy information, which should look similar to this:

            .. code-block:: json

                {
                    "ancStatus": "success",
                    "ancpolicy": [
                        {
                            "action": [
                                "ShutDown"
                            ],
                            "name": "shutdown_policy"
                        },
                        {
                            "action": [
                                "Quarantine"
                            ],
                            "name": "quarantine_policy"
                        }
                    ]
                }
        :rtype: dict
        """
        request = Request(self._ANC_RETRIEVE_ALL_POLICIES)
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def retrieve_policy_by_name(self, policy_name):
        """
        Retrieve information for an ANC policy by name.

        :param str policy_name: Name of the policy.
        :return: The policy information, which should look similar to this:

            .. code-block:: json

                    {
                        "ancStatus": "success",
                        "ancpolicy": [
                            {
                                "action": [
                                    "Quarantine"
                                ],
                                "name": "quarantine_policy"
                            }
                        ]
                    }
        :rtype: dict
        :raises Exception: If the policy name has not been defined.
        """
        request = Request(self._ANC_RETRIEVE_POLICY_BY_NAME)
        MessageUtils.dict_to_json_payload(
            request,
            {_PARAM_POLICY_NAME: policy_name})
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def get_endpoint_by_ip(self, ip_address):
        """
        Get information for an endpoint by its IP address.

        :param str ip_address: IP address of the endpoint.
        :return: The endpoint information, which should look similar to this:

            .. code-block:: json

                    {
                        "ancEndpoint": [
                            {
                                "macAddress": "00:11:22:33:44:55",
                                "policyName": "quarantine_policy"
                            }
                        ],
                        "ancStatus": "success"
                    }
        :rtype: dict
        :raises Exception: If no policy has been astociated with the endpoint
            or if no session has been defined for an endpoint which corresponds
            to the IP address.
        """
        request = Request(self._ANC_GET_ENDPOINT_BY_IP)
        MessageUtils.dict_to_json_payload(
            request,
            {_PARAM_IP: ip_address})
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def get_endpoint_by_mac(self, mac_address):
        """
        Get information for an endpoint by its MAC address.

        :param str mac_address: MAC address of the endpoint.
        :return: The endpoint information, which should look similar to this:

            .. code-block:: json

                {
                    "ancEndpoint": [
                        {
                            "macAddress": "00:11:22:33:44:55",
                            "policyName": "quarantine_policy"
                        }
                    ],
                    "ancStatus": "success"
                }
        :rtype: dict
        :raises Exception: If no policy has been astociated with the endpoint.
        """
        request = Request(self._ANC_GET_ENDPOINT_BY_MAC)
        MessageUtils.dict_to_json_payload(request, {
            _PARAM_MAC: mac_address})
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def clear_endpoint_policy_by_ip(self, ip_address):
        """
        Clear the policy for an endpoint by its IP address.

        :param str ip_address: IP address of the endpoint.
        :return: Results of the attempt to clear the endpoint policy. On a
            successful clear attempt, the results should look similar to this:

            .. code-block:: json

                {
                    "ancStatus": "success"
                }
        :rtype: dict
        :raises Exception: If no policy has been astociated with the endpoint.
        """
        request = Request(self._ANC_CLEAR_ENDPOINT_POLICY_BY_IP)
        MessageUtils.dict_to_json_payload(
            request,
            {_PARAM_IP: ip_address})
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def clear_endpoint_policy_by_mac(self, mac_address):
        """
        Clear the policy for an endpoint by its MAC address.

        :param str mac_address: MAC address of the endpoint.
        :return: Results of the attempt to clear the endpoint policy. On a
            successful clear attempt, the results should look similar to this:

            .. code-block:: json

                {
                    "ancStatus": "success"
                }
        :rtype: dict
        :raises Exception: If no policy has been astociated with the endpoint.
        """
        request = Request(self._ANC_CLEAR_ENDPOINT_POLICY_BY_MAC)
        MessageUtils.dict_to_json_payload(
            request,
            {_PARAM_MAC: mac_address})
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def apply_endpoint_policy_by_ip(self, ip_address, policy_name):
        """
        Apply a policy to an endpoint by its IP address.

        :param str ip_address: IP address of the endpoint.
        :param str policy_name: Name of the policy to apply.
        :return: Results of the attempt to apply the endpoint policy. On a
            successful application, the results should look similar to this:

            .. code-block:: json

                {
                    "ancStatus": "success"
                }
        :rtype: dict
        :raises Exception: If the supplied policy name has already been
            applied to the endpoint, the policy name has not been defined, or
            if no session has been defined for an endpoint which corresponds to
            the IP address.
        """
        request = Request(self._ANC_APPLY_ENDPOINT_POLICY_BY_IP)
        MessageUtils.dict_to_json_payload(
            request,
            {_PARAM_IP: ip_address,
             _PARAM_POLICY_NAME: policy_name})
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))

0 View Complete Implementation : client.py
Copyright Apache License 2.0
Author : opendxl
    def apply_endpoint_policy_by_mac(self, mac_address, policy_name):
        """
        Apply a policy to an endpoint by its MAC address.

        :param str mac_address: MAC address of the endpoint.
        :param str policy_name: Name of the policy to apply.
        :return: Results of the attempt to apply the endpoint policy. On a
            successful application, the results should look similar to this:

            .. code-block:: json

                {
                    "ancStatus": "success"
                }
        :rtype: dict
        :raises Exception: If the supplied policy name has already been
            applied to the endpoint or the policy name has not been defined.
        """
        request = Request(self._ANC_APPLY_ENDPOINT_POLICY_BY_MAC)
        MessageUtils.dict_to_json_payload(
            request,
            {_PARAM_MAC: mac_address,
             _PARAM_POLICY_NAME: policy_name})
        return MessageUtils.json_payload_to_dict(
            self._pxgrid_client._dxl_sync_request(request))