Общая XSD-схема

XSD-схема XML-файла запроса/ответа aliases.xsd:


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<!-- propertyTypeType-->
	<xs:simpleType name="propertyTypeType">
		<xs:restriction base="xs:string">
			<xs:enumeration value="global"/>
			<xs:enumeration value="domain"/>
			<xs:enumeration value="domain_interface"/>
			<xs:enumeration value="domain_address"/>
			<xs:enumeration value="address"/>
			<xs:enumeration value="profile"/>
			<xs:enumeration value="alias"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- propertyType-->
	<xs:complexType name="propertyType">
		<xs:attribute name="name" type="xs:string" use="required"/>
		<xs:attribute name="type" type="propertyTypeType" use="required"/>
		<xs:attribute name="value" type="xs:string" use="required">
			<xs:annotation>
				<xs:documentation xml:lang="en">
					For other type of properties value will be formatted specifically.
					Key:    timetables\TIMETABLE_NAME
					Value:  {"name":"TIMETABLE_NAME", "filters":[{"date":"DAYS_LIST_OR_DAY_TYPE_NAME","from":"FROM_HH:FROM_MM","to":"TO_HH:TO_MM"}],"properties":{"description | KEY":"VALUE"}}
					Sample: {"name":"tt2","filters":[{"date":"1 2 3 4 5","from":"9:0","to":"12:59"},{"date":"HOLIDAY","from":"13:0","to":"17:59"}],"properties":{"description":"Мой 2","key3":"{hello,world}"}}
					In case of strong security restrictions password properties may be shown as ********
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<!-- aliasType-->
	<xs:complexType name="aliasType">
		<xs:sequence>
			<xs:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="iface" type="xs:string" use="required"/>
		<xs:attribute name="address" type="xs:string" use="required"/>
	</xs:complexType>
	<!-- addressType-->
	<xs:complexType name="addressType">
		<xs:sequence>
			<xs:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required"/>
	</xs:complexType>
	<!-- ifaceType-->
	<xs:complexType name="ifaceType">
		<xs:sequence>
			<xs:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required"/>
	</xs:complexType>
	<!-- errorType-->
	<xs:complexType name="errorType">
		<xs:attribute name="iface" type="xs:string" use="required"/>
		<xs:attribute name="address" type="xs:string" use="required"/>
		<xs:attribute name="value" type="xs:string" use="required"/>
	</xs:complexType>
	<!-- Properties elements-->
	<xs:complexType name="ifacesType">
		<xs:sequence>
			<xs:element name="iface" type="ifaceType" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="error" type="errorType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="domain" type="xs:string" use="required"/>
	</xs:complexType>
	<xs:complexType name="addressesType">
		<xs:sequence>
			<xs:element name="address" type="addressType" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="error" type="errorType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="domain" type="xs:string" use="required"/>
	</xs:complexType>
	<xs:complexType name="aliasesType">
		<xs:sequence>
			<xs:element name="alias" type="aliasType" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="error" type="errorType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="domain" type="xs:string" use="required"/>
	</xs:complexType>
	<xs:complexType name="domainType">
		<xs:sequence>
			<xs:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" use="required"/>
	</xs:complexType>
	<!-- in-->
	<xs:element name="in">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="aliases" minOccurs="1" maxOccurs="unbounded">
					<xs:complexType>
						<xs:attribute name="domain" type="xs:string" use="required"/>
						<xs:attribute name="addr" type="xs:string" use="optional"/>
						<xs:attribute name="iface" type="xs:string" use="optional"/> <!-- iface задавать только как iface_id! -->
						<xs:attribute name="prop" type="xs:string" use="optional"/>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<!-- out-->
	<xs:element name="out">
		<xs:complexType>
			<xs:choice>
				<xs:element name="domain" type="domainType"/>
				<xs:element name="ifaces" type="ifacesType"/>
				<xs:element name="addresses" type="addressesType"/>
				<xs:element name="aliases" type="aliasesType"/>
			</xs:choice>
		</xs:complexType>
	</xs:element>
</xs:schema>

CODE

aliases_list.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<!-- aliasType-->
	<xs:complexType name="aliasType">
		<xs:attribute name="domain" type="xs:string" use="required"/>
		<xs:attribute name="interface" type="xs:string" use="required"/>
		<xs:attribute name="interface_type" type="xs:string" use="optional"/>
		<xs:attribute name="interface_group" type="xs:string" use="optional"/>
		<xs:attribute name="address" type="xs:string" use="required"/>
		<xs:attribute name="iface_name" type="xs:string" use="optional"/>
        <xs:attribute name="active" type="xs:boolean" use="required"/>
		<xs:attribute name="binded" type="xs:boolean" use="optional"/>
		<xs:attribute name="displayName" type="xs:string" use="optional"/>
	</xs:complexType>
	<!-- errorType-->
	<xs:complexType name="errorType">
		<xs:simpleContent>
			<xs:extension base="xs:string">
				<xs:attribute name="interface" type="xs:string"/>
				<xs:attribute name="address" type="xs:string"/>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>
</xs:schema>

CODE

Hс_aliases_list

Команда возвращает список алиасов, определенных в домене для конкретного адреса.

Аналог команды в CoCon:

domain/<DOMAIN>/alias/list

Метод HTTP-запроса:

POST

Шаблон HTTP-запроса:

http://host:port/commands/alias_list

Код HTTP-ответа:

  • 200 – в случае успеха;
  • 404 – в случае ошибки.

XSD-схема XML-файла запроса/ответа hc_aliases_list.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!-- aliasType-->
    <xs:complexType name="aliasType">
        <xs:attribute name="domain" type="xs:string" use="required"/>
        <xs:attribute name="interface" type="xs:string" use="required"/>
        <xs:attribute name="interface_type" type="xs:string" use="optional"/>
        <xs:attribute name="interface_group" type="xs:string" use="optional"/>
        <xs:attribute name="address" type="xs:string" use="required"/>
        <xs:attribute name="iface_name" type="xs:string" use="optional"/>
        <xs:attribute name="active" type="xs:boolean" use="required"/>
        <xs:attribute name="binded" type="xs:boolean" use="optional"/>
        <xs:attribute name="displayName" type="xs:string" use="optional"/>
    </xs:complexType>
    <!-- errorType-->
    <xs:complexType name="errorType">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="interface" type="xs:string"/>
                <xs:attribute name="address" type="xs:string"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:schema>
XML

Пример

Запрос: http://192.168.1.21:9999/commands/alias_list

<?xml version="1.0" encoding="UTF-8"?>
<in xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="hc_alias_list.xsd">
    <aliases domain="biysk.local" addr="24046{4-5}" />
</in>
XML

Ответ:

<?xml version="1.0"?>
<out
    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="hc_alias_list.xsd">
    <aliases>
        <alias domain="biysk.local" interface="0616e1cdf89ba684" interface_type="sip" interface_group="loc.gr" address="240464" active="true"/>
        <alias domain="biysk.local" interface="0616e1cdfa62ad0e" interface_type="sip" interface_group="loc.gr" address="240465" active="true"/>
    </aliases>
</out>
XML

Hс_aliases_list2

Команда возвращает список алиасов, определенных в домене с фильтрацией по свойствам алиаса. В случае, если запрос выполняется длительное время (более 3х секунд), то команда прерывается, и возвращаются только те алиасы, что найдены на текущий момент. При этом возвращается курсор для продолжения поиска. Если же курсор не вернулся, это значит что все данные были возвращены.

Аналог команды в CoCon:

Нет прямого аналога. Работает как комбинация следующих команд:

domain/<DOMAIN>/alias/list

domain/<DOMAIN>/alias/info

Метод HTTP-запроса:

POST

Шаблон HTTP-запроса:

http://host:port/commands/alias_list2

Код HTTP-ответа:

  • 200 – в случае успеха;
  • 404 – в случае ошибки.

XSD-схема XML-файла запроса/ответа:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
    xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <!-- opType-->
    <xs:simpleType name="opType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="=="/>
            <xs:enumeration value="~"/>
            <xs:enumeration value="/="/>
            <xs:enumeration value=">"/>
            <xs:enumeration value="<"/>
            <xs:enumeration value="=<"/>
            <xs:enumeration value=">="/>
            <xs:enumeration value="in"/>
        </xs:restriction>
    </xs:simpleType>
    <!-- filterType -->
    <xs:complexType name="filterType">
        <xs:attribute name="name" type="xs:string" use="required"/>
        <xs:attribute name="op" type="opType" use="required"/>
        <xs:attribute name="value" type="xs:string" use="required"/>
    </xs:complexType>
    <!-- andFiltersType -->
    <xs:complexType name="andFiltersType">
        <xs:sequence>
            <xs:element name="filter" type="filterType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <!-- filtersType -->
    <xs:complexType name="filtersType">
        <xs:sequence>
            <xs:element name="and" type="andFiltersType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <!-- aliasType -->
    <xs:complexType name="aliasType">
        <xs:attribute name="domain" type="xs:string" use="required"/>
        <xs:attribute name="iface" type="xs:string" use="required"/>
        <xs:attribute name="address" type="xs:string" use="required"/>
        <xs:attribute name="active" type="xs:boolean" use="required"/>
        <xs:attribute name="binded" type="xs:boolean" use="required"/>
        <xs:attribute name="display_name" type="xs:string" use="required"/>
        <xs:attribute name="regime" type="xs:string" use="required"/>
        <xs:attribute name="interface_name" type="xs:string" use="required"/>
        <xs:attribute name="interface_type" type="xs:string" use="required"/>
        <xs:attribute name="interface_owner" type="xs:string" use="required"/>
        <xs:attribute name="interface_group" type="xs:string" use="required"/>
    </xs:complexType>
    <!-- in-->
    <xs:element name="in">
        <xs:complexType>
            <xs:all>
                <xs:element name="request">
                    <xs:complexType>
                        <xs:all>
                            <xs:element name="filters" type="filtersType"/>
                        </xs:all>
                        <xs:attribute name="domain" type="xs:string" use="required"/>
                        <xs:attribute name="limit" type="xs:string" use="required"/>
                        <xs:attribute name="address_range" type="xs:string" use="optional"/>
                        <xs:attribute name="cursor" type="xs:string" use="optional"/>
                    </xs:complexType>
                </xs:element>
            </xs:all>
        </xs:complexType>
    </xs:element>
    <!-- out -->
    <xs:element name="out">
        <xs:complexType>
            <xs:all>
                <xs:element name="result">
                    <xs:complexType>
                        <xs:sequence minOccurs="0" maxOccurs="unbounded">
                            <xs:element name="alias" type="aliasType" minOccurs="0" maxOccurs="unbounded"/>
                        </xs:sequence>
                        <xs:attribute name="cursor" type="xs:string" use="optional"/>
                    </xs:complexType>
                </xs:element>
            </xs:all>
        </xs:complexType>
    </xs:element>
</xs:schema>

XML

Запрос: http://192.168.1.21:9999/commands/alias_list2

<?xml version="1.0" encoding="UTF-8"?>
<in
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="hc_alias_list2.xsd">
    <request address_range="240{500-510}" domain="biysk.local" limit="5">
        <filters>
            <and>
                <filter name="regime" op="==" value="accsusp"/>
            </and>
            <and>
                <filter name="active" op="==" value="true"/>
            </and>
        </filters>
    </request>
</in>
XML

Ответ:

<?xml version="1.0"?>
<out
    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="hc_alias_list2.xsd">
    <result>
        <alias domain="biysk.local" iface="0616e1cdf6d17ece" address="240462" active="true" binded="true" display_name="" regime="accsusp" interface_name="240462@biysk.local" interface_type="sip" interface_owner="sip1" interface_group="loc.gr"/>
        <alias domain="biysk.local" iface="0616e1ce554bc90e" address="240466" active="true" binded="false" display_name="" regime="accsusp" interface_name="240466@biysk.local" interface_type="sip" interface_owner="sip1" interface_group="loc.gr"/>
    </result>
</out>
XML