Package: milena
What is Milena?milena is a SIP stack made for us to create testing tools for anyone working with VoIP.API ReferencesMost of our classes follow a very similar API, providing.string()and.dict()methods to access information either raw or with a native python interface.SIP URIThe SIP URI is a Uniform Resource Identifier (URI) scheme for the Session Initiation Protocol (SIP) multimedia communications protocol. A SIP address is a URI that addresses a specific telephone extension on a voice over IP system. Such a number could be a private branch exchange or an E.164 telephone number dialled through a specific gateway. The scheme was defined in RFC 3261.Bywikipedia.Examplefrommilena.sipimportURIstring="sip:alice@atlanta.com"dictionary={"schema":"sip","user":"alice","password":None,"host":"atlanta.com","port":None,"parameters":{},"headers":{},}alice=URI.setup(source="string",content=string)assertalice.string()==stringassertalice.dict()==dictionaryalice=URI.setup(source="dict",content=dictionary)assertalice.string()==stringassertalice.dict()==dictionaryExceptionsIn case an incorrect parameter will be passed to the API we will have an exception of typeValueError.In case of a failure during the parse or stringify process we will have an exception of typeRuntimeError.Address of RecordA address of record (AOR) is very similar to a SIP URI, except that it can carry some more information, such as the display name.Examplefrommilena.sipimportAORstring="Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl"dictionary={"name":"Alice","uri":"sip:alice@atlanta.example.com","parameters":{"tag":"9fxced76sl"},}alice=URI.setup(source="string",content=string)assertalice.string()==stringassertalice.dict()==dictionaryalice=URI.setup(source="dict",content=dictionary)assertalice.string()==stringassertalice.dict()==dictionaryExceptionsIn case an incorrect parameter will be passed to the API we will have an exception of typeValueError.In case of a failure during the parse or stringify process we will have an exception of typeRuntimeError.Sip HeadersHere is a list of implemented sip headers with a brief code demo.CSeqfrommilena.sipimportCSeqstring="4711 INVITE",dictionary={"seq":4711,"method":"INVITE"}header=CSeq.setup(source="string",content=string)assertheader.string()==stringassertheader.dict()==dictionaryheader=CSeq.setup(source="dict",content=dictionary)assertheader.string()==stringassertheader.dict()==dictionaryprint(header)# CSeq: 4711 INVITEAuthentication Infofrommilena.sipimportAuthenticationInfostring='nextnonce="47364c23432d2e131a5fb210812c",qop="auth,auth-int"',dictionary={"nextnonce":'"47364c23432d2e131a5fb210812c"',"qop":'"auth,auth-int"',}header=AuthenticationInfo.setup(source="string",content=string)assertheader.string()==stringassertheader.dict()==dictionaryheader=AuthenticationInfo.setup(source="dict",content=dictionary)assertheader.string()==stringassertheader.dict()==dictionaryprint(header)# CSeq: 4711 INVITEExceptionsIn case an incorrect parameter will be passed to the SIP header API we will have an exception of typeValueError.In case of a failure during the parse or stringify process we will have an exception of typeRuntimeError.CommentsBy design choice, the properties of each API are read-only. If you want to change a certain value, work with a copy of the API dictionary you want to change and then create a new instance.APIs have asetupmethod that must be used to inform if we are using it from astringor adict.By design choice, thestringmethod will return the value of the formatted SIP header, but converting the object to a literal string (str(API)) will return the header in key=value format, ready to go. used on your User Agent.How to contribute?If you are thinking of contributing in any way to the project, you will be very welcome. Whether it's improving existing documentation, suggesting new features or running existing bugs, it's only by working together that the project will grow.Do not forget to see ourContributing Guideand ourCode of Conductto always be aligned with the ideas of the project.ContributorsWill be welcome ❤️Author@Otoru