yegor256/thindeck

View on GitHub
src/main/resources/com/thindeck/api/deck.xsd

Summary

Maintainability
Test Coverage
<?xml version="1.0"?>
<!--
 * Copyright (c) 2014-2019, Thindeck.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met: 1) Redistributions of source code must retain the above
 * copyright notice, this list of conditions and the following
 * disclaimer. 2) Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following
 * disclaimer in the documentation and/or other materials provided
 * with the distribution. 3) Neither the name of the thindeck.com nor
 * the names of its contributors may be used to endorse or promote
 * products derived from this software without specific prior written
 * permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @author Yegor Bugayenko (yegor256@gmail.com)
 * @version $Id$
 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:simpleType name="imageName">
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9a-zA-Z\-]+/[0-9a-zA-Z\-]+-[0-9a-f]{8}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="repoName">
        <xs:restriction base="xs:string">
            <xs:pattern value="[0-9a-f]{8}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="port">
        <xs:restriction base="xs:integer">
            <xs:maxExclusive value="65536"/>
            <xs:minInclusive value="1024"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:complexType name="image">
        <xs:all>
            <xs:element name="name" type="imageName"/>
            <xs:element name="repo" type="repoName"/>
            <xs:element name="uri" type="xs:string"/>
        </xs:all>
        <xs:attribute name="waste" type="xs:dateTime" use="optional"/>
        <xs:attribute name="type" use="required">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="green"/>
                    <xs:enumeration value="blue"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
    <xs:complexType name="tank">
        <xs:all>
            <xs:element name="host" type="xs:string"/>
        </xs:all>
    </xs:complexType>
    <xs:complexType name="container">
        <xs:all>
            <xs:element name="image" type="imageName"/>
            <xs:element name="host" type="xs:string"/>
            <xs:element name="http" type="port" minOccurs="0"/>
            <xs:element name="https" type="port" minOccurs="0"/>
            <xs:element name="name">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:pattern value="[0-9a-f]{8}"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
        </xs:all>
        <xs:attribute name="waste" type="xs:dateTime" use="optional"/>
        <xs:attribute name="state" use="required">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="dead"/>
                    <xs:enumeration value="alive"/>
                    <xs:enumeration value="unknown"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="checked" use="optional" type="xs:dateTime"/>
        <xs:attribute name="type" use="required">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="green"/>
                    <xs:enumeration value="blue"/>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
    <xs:element name="deck">
        <xs:complexType>
            <xs:all>
                <xs:element name="domains" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="domain" minOccurs="0" maxOccurs="unbounded">
                                <xs:simpleType>
                                    <xs:restriction base="xs:string">
                                        <xs:pattern value="[a-zA-Z0-9\-\.]+"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                    <xs:unique name="uniqueDomainName">
                        <xs:selector xpath="./domain" />
                        <xs:field xpath="." />
                    </xs:unique>
                </xs:element>
                <xs:element name="repo" minOccurs="0">
                    <xs:complexType>
                        <xs:all>
                            <xs:element name="name" type="repoName"/>
                            <xs:element name="uri" type="xs:string"/>
                        </xs:all>
                        <xs:attribute name="added" type="xs:dateTime" use="required"/>
                    </xs:complexType>
                </xs:element>
                <xs:element name="images" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="image" type="image" minOccurs="0" maxOccurs="unbounded"/>
                        </xs:sequence>
                    </xs:complexType>
                    <xs:unique name="imageName">
                        <xs:selector xpath="./image" />
                        <xs:field xpath="name" />
                    </xs:unique>
                </xs:element>
                <xs:element name="tanks" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="tank" type="tank" minOccurs="0" maxOccurs="unbounded"/>
                        </xs:sequence>
                    </xs:complexType>
                    <xs:unique name="uniqueTankHost">
                        <xs:selector xpath="./tank" />
                        <xs:field xpath="host" />
                    </xs:unique>
                </xs:element>
                <xs:element name="containers" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="container" type="container" minOccurs="0" maxOccurs="unbounded"/>
                        </xs:sequence>
                    </xs:complexType>
                    <xs:unique name="uniqueContainerName">
                        <xs:selector xpath="./container" />
                        <xs:field xpath="name" />
                    </xs:unique>
                </xs:element>
            </xs:all>
            <xs:attribute name="name">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:pattern value="[a-z0-9A-Z\-]+/[a-z]+"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
</xs:schema>