1 # Copyright 2009 Shikhar Bhushan
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from rpc import RPC, RPCReply
17 from ncclient.xml_ import *
21 class GetReply(RPCReply):
23 """Adds attributes for the *data* element to `RPCReply`. This pertains to the `Get` and
24 `GetConfig` operations."""
26 def _parsing_hook(self, root):
29 self._data = root.find(qualify("data"))
33 "*data* element as an `~xml.etree.ElementTree.Element`"
40 "*data* element as an XML string"
43 return to_xml(self._data)
46 "Same as :attr:`data_ele`"
55 def request(self, filter=None):
57 if filter is not None:
58 node.append(util.build_filter(filter))
59 return self._request(node)
64 "The *get-config* RPC."
68 def request(self, source, filter=None):
69 node = new_ele("get-config")
70 node.append(util.datastore_or_url("source", source, self._assert))
71 if filter is not None:
72 node.append(util.build_filter(filter))
73 return self._request(node)