summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelie <elie>2015-09-18 05:59:01 +0000
committerelie <elie>2015-09-18 05:59:01 +0000
commit45355ded422185b96b41ee72f283eea764cbe0da (patch)
treeb7f062c7a168bfe01fe1b04b3b2da50896d6a985
parent69c5618398ac723f1e26f455aec56cd9dc51b789 (diff)
downloadpysnmp-45355ded422185b96b41ee72f283eea764cbe0da.tar.gz
started documenting base types
-rw-r--r--docs/source/docs/contents.rst6
-rw-r--r--docs/source/docs/snmp-data-types.rst16
-rw-r--r--pysnmp/proto/rfc1902.py66
3 files changed, 88 insertions, 0 deletions
diff --git a/docs/source/docs/contents.rst b/docs/source/docs/contents.rst
index 48475dc..ddde9cf 100644
--- a/docs/source/docs/contents.rst
+++ b/docs/source/docs/contents.rst
@@ -35,6 +35,12 @@ of SNMP Engine:
.. toctree::
/docs/v3arch/snmp-engine
+SNMP represents the information is manages in form of values belonging to
+a set of types.
+
+.. toctree::
+ /docs/snmp-data-types
+
At the other end of the complexity spectrum, PySNMP offers packet-level
ASN.1 data structures that let you build, parse and analyze SNMP messages
travelling over network. This extremely low-level programming interface is
diff --git a/docs/source/docs/snmp-data-types.rst b/docs/source/docs/snmp-data-types.rst
new file mode 100644
index 0000000..63d2f1a
--- /dev/null
+++ b/docs/source/docs/snmp-data-types.rst
@@ -0,0 +1,16 @@
+
+SNMP data types
+===============
+
+SNMP represents real-world objects it serves along with their
+states in form of values. Those values each belong to one
+of SNMP types (:RFC:`1902#section-2`) which, in turn, are based
+on *ASN.1* data description language. PySNMP types are derived
+from `Python ASN.1 types <http://pyasn1.sf.net>`_ implementation.
+
+.. toctree::
+ :maxdepth: 2
+
+.. autoclass:: pysnmp.proto.rfc1902.Integer(initializer)
+.. autoclass:: pysnmp.proto.rfc1902.Integer32(initializer)
+
diff --git a/pysnmp/proto/rfc1902.py b/pysnmp/proto/rfc1902.py
index 3c79418..4e0f41d 100644
--- a/pysnmp/proto/rfc1902.py
+++ b/pysnmp/proto/rfc1902.py
@@ -2,11 +2,77 @@ from pyasn1.type import univ, tag, constraint, namedtype, namedval
from pysnmp.proto import rfc1155, error
class Integer(univ.Integer):
+ """Creates an instance of SNMP INTEGER class.
+
+ The :py:class:`~pysnmp.proto.rfc1902.Integer` type used to represent
+ integer-valued information as named-number enumerations
+ (:RFC:`1902#section-7.1.1`). This type is indistinguishable from the
+ :py:class:`~pysnmp.proto.rfc1902.Integer32` type.
+ The :py:class:`~pysnmp.proto.rfc1902.Integer` type may be sub-typed
+ to be more constrained than the base
+ :py:class:`~pysnmp.proto.rfc1902.Integer` type.
+
+ Parameters
+ ----------
+ initializer : int
+ Python integer in range between -2147483648 to 2147483647 inclusive.
+ In case of named-numbered enumerations, initialization is also
+ possible by enumerated literal.
+
+ Raises
+ ------
+ PyAsn1Error :
+ On bad initilizer.
+
+ Examples
+ --------
+ >>> from pysnmp.proto.rfc1902 import *
+ >>> Integer(1234)
+ Integer(1234)
+ >>> Integer(1) > 2
+ True
+ >>> Integer(1) + 1
+ Integer(2)
+ >>>
+
+ """
subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint(
-2147483648, 2147483647
)
class Integer32(univ.Integer):
+ """Creates an instance of SNMP Integer32 class.
+
+ :py:class:`~pysnmp.proto.rfc1902.Integer32` type represents
+ integer-valued information between -2147483648 to 2147483647
+ inclusive (:RFC:`1902#section-7.1.1`). This type is indistinguishable
+ from the :py:class:`~pysnmp.proto.rfc1902.Integer` type.
+ The :py:class:`~pysnmp.proto.rfc1902.Integer32` type may be sub-typed
+ to be more constrained than the base
+ :py:class:`~pysnmp.proto.rfc1902.Integer32` type.
+
+ Parameters
+ ----------
+ initializer : int
+ Python integer in range between -2147483648 to 2147483647 inclusive.
+
+ Raises
+ ------
+ PyAsn1Error :
+ On bad initilizer.
+
+ Examples
+ --------
+ >>> from pysnmp.proto.rfc1902 import *
+ >>> Integer32(1234)
+ Integer32(1234)
+ >>> Integer32(1) > 2
+ True
+ >>> Integer32(1) + 1
+ Integer32(2)
+ >>>
+
+ """
subtypeSpec = univ.Integer.subtypeSpec+constraint.ValueRangeConstraint(
-2147483648, 2147483647
)