aboutsummaryrefslogtreecommitdiffstats
path: root/docs/modelingconcepts/data-type.rst
blob: 29143de803510185d368c5011581bc8b89f3d464 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
.. This work is a derivative of https://wiki.onap.org/display/DW/Modeling+Concepts#Concepts-1581473264
.. This work is licensed under a Creative Commons Attribution 4.0
.. International License. http://creativecommons.org/licenses/by/4.0
.. Copyright (C) 2020 Deutsche Telekom AG.

.. _data_type:

Data type
---------

Represents the **schema** of a specific type of **data**.

Supports both **primitive** and **complex** data types:

.. list-table::
   :widths: 50 50
   :header-rows: 1

   * - Primitive
     - Complex
   * - * string
       * integer
       * float
       * double
       * boolean
       * timestamp
       * null
     - * json
       * list
       * array

For complex data type, an **entry schema** is required, defining the
type of value contained within the complex type, if list or array.

Users can **create** as many **data type** as needed.

.. note::

   **Creating Custom Data Types:**

   To create a custom data-type you can use a POST call to CDS endpoint:
   "<cds-ip>:<cds-port>/api/v1/model-type"

   .. code-block:: python
      :caption: **Payload:**

      {
        "model-name": "<model-name>",
        "derivedFrom": "tosca.datatypes.Root",
        "definitionType": "data_type",
        "definition": {
          "description": "<description>",
          "version": "<version-number: eg 1.0.0>",
          "properties": {<add properties of your custom data type in JSON format>},
          "derived_from": "tosca.datatypes.Root"
        },
        "description": "<description",
        "version": "<version>",
        "tags": "<model-name>,datatypes.Root.data_type",
        "creationDate": "<creation timestamp>",
        "updatedBy": "<name>"
      }

Data type are useful to manipulate data during resource resolution.
They can be used to format the JSON output as needed.

List of existing data type:
`<https://github.com/onap/ccsdk-cds/tree/master/components/model-catalog/definition-type/starter-type/data_type>`_

`TOSCA specification
<http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.2/csd01/TOSCA-Simple-Profile-YAML-v1.2-csd01.html#_Toc494454187>`_

**Below is a list of existing data types**

.. tabs::

   .. tab:: resource-assignment

      **datatype-resource-assignment**

      Used to define entries within artifact-mapping-resource
      (see tab Artifact Type -> artifact-mapping-resource)

      That datatype represent a **resource** to be resolved. We also refer
      this as an **instance of a data dictionary** as it's directly linked to
      its definition.

      .. list-table::
         :widths: 50 50
         :header-rows: 1

         * - Property
           - Description
         * - property
           - Defines how the resource looks like (see datatype-property on the right tab)
         * - input-param
           - Whether the resource can be provided as input.
         * - dictionary-name
           - Reference to the name of the data dictionary (see :ref:`data_dictionary`).
         * - dictionary-source
           - Reference the source to use to resolve the resource (see :ref:`resource source`).
         * - dependencies
           - List of dependencies required to resolve this resource.
         * - updated-date
           - Date when mapping was upload.
         * - updated-by
           - Name of the person that updated the mapping.

      `<https://github.com/onap/ccsdk-cds/blob/master/components/model-catalog/definition-type/starter-type/data_type/datatype-resource-assignment.json>`_

      .. code-block:: json
         :caption: **datatype-resource-assignment**

        {
          "version": "1.0.0",
          "description": "This is Resource Assignment Data Type",
          "properties": {
            "property": {
              "required": true,
              "type": "datatype-property"
            },
            "input-param": {
              "required": true,
              "type": "boolean"
            },
            "dictionary-name": {
              "required": false,
              "type": "string"
            },
            "dictionary-source": {
              "required": false,
              "type": "string"
            },
            "dependencies": {
              "required": true,
              "type": "list",
              "entry_schema": {
                "type": "string"
              }
            },
            "updated-date": {
              "required": false,
              "type": "string"
            },
            "updated-by": {
              "required": false,
              "type": "string"
            }
          },
          "derived_from": "tosca.datatypes.Root"
        }

   .. tab:: property

      **datatype-property**

      Used to defined the **property** entry of a **resource assignment**.

      .. list-table::
         :widths: 25 75
         :header-rows: 1

         * - Property
           - Description
         * - type
           - Whether it's a primitive type, or a defined data-type
         * - description
           - Description of for the property
         * - required
           - Whether it's required or not
         * - default
           - If there is a default value to provide
         * - entry_schema
           - If the type is a complex one, such as list, define what is the type of element within the list.

      `<https://github.com/onap/ccsdk-cds/blob/master/components/model-catalog/definition-type/starter-type/data_type/datatype-property.json>`_

      .. code-block:: json
         :caption: **datatype-property**

         {
           "version": "1.0.0",
           "description": "This is Resource Assignment Data Type",
           "properties": {
             "property": {
               "required": true,
               "type": "datatype-property"
             },
             "input-param": {
               "required": true,
               "type": "boolean"
             },
             "dictionary-name": {
               "required": false,
               "type": "string"
             },
             "dictionary-source": {
               "required": false,
               "type": "string"
             },
             "dependencies": {
               "required": true,
               "type": "list",
               "entry_schema": {
                 "type": "string"
               }
             },
             "updated-date": {
               "required": false,
               "type": "string"
             },
             "updated-by": {
               "required": false,
               "type": "string"
             }
           },
           "derived_from": "tosca.datatypes.Root"
         }