1# Copyright (c) 2017, The MITRE Corporation. All rights reserved.
2# See LICENSE.txt for complete terms.
3
4from mixbox import fields
5from mixbox.vendor import six
6
7import cybox.bindings.uri_object as uri_binding
8from cybox.common import ObjectProperties, AnyURI
9
10
11@six.python_2_unicode_compatible
12class URI(ObjectProperties):
13    _binding = uri_binding
14    _binding_class = uri_binding.URIObjectType
15    _namespace = 'http://cybox.mitre.org/objects#URIObject-2'
16    _XSI_NS = 'URIObj'
17    _XSI_TYPE = "URIObjectType"
18
19    TYPE_URL = "URL"
20    TYPE_GENERAL = "General URN"
21    TYPE_DOMAIN = "Domain Name"
22
23    TYPES = (TYPE_URL, TYPE_GENERAL, TYPE_DOMAIN)
24
25    value = fields.TypedField("Value", AnyURI)
26    type_ = fields.TypedField("type_", key_name="type")
27
28    def __init__(self, value=None, type_=None):
29        super(URI, self).__init__()
30        self.value = value
31        self.type_ = type_
32
33    def __str__(self):
34        return six.text_type(self.value)
35