Child pages
  • GetSchema
Skip to end of metadata
Go to start of metadata

Description

The GetSchema API allows the Account Owner to retrieve a previously created Schema

 

In apstrata, Schemas are used to define the kind of data you expect to store for a certain business entity, along with the validation and security rules, in a declarative way. You can think of a Schema as a template for business entities. For example, you might want to have an employee entity in your application. You can define a schema for that entity, specifying that first name, last name, age, and employment date represent the data to be collected by default for each employee. For each of these employee attributes, you can associate validation and security rules. Hence, a Schema provides a uniform way of dealing with employees. Note that employee attributes that are not defined in the schema can still be persisted as part of an employee Document; however, no specific validation or security rules can be applied to them. Such fields or attributes are called dynamic fields.

Apstrata does not enforce the use of Schemas. Alternatively, you can always persist data without specifying a Schema. In this case, no security or validation rules can be applied at the level of the fields. Note that "schema-less" Documents are actually Documents with a default Schema, which gets created for each account upon registration. The default Schema is not exposed, and hence cannot be customized. The default Schema is totally based on dynamic fields, implying that no field-level security or validation rules can be applied. This "schema-less" mode is meant for prototyping and experimenting purposes. We fully recommend that business applications be built in a "schema-full" mode.

Please refer to Document Schema Definitions or Saved Query Schema Definition to showcase a schema example as well as the schema syntax (XSD) that you should use to create your schemas.

For specific details on schema creation, please check the SaveSchema API.

Specific Request Parameters

(Refer to Common Request Parameters)

Name

Description

Required

Default

Possible Values

apsdb.schemaName

Represents the schema name

Yes

 

 

Specific Response Elements

(Refer to Common Response Elements)

The following specific "result" element is a child of the common root element "response" and a sibling of the common "metadata" element:

{
	"result": "XML definition of the requested schema"
}

Specific Logical Errors

(Refer to Common Logical Error Codes)

Error

Message

Status Code

SCHEMA_NOT_FOUND

The schema [schemaName] was not found

404

PARAMETER_REQUIRED

 

400

INVALID_SCHEMA_NAME

 

400

Examples

Sample Request

Request URL: http://sandbox.apstrata.com/apsdb/rest/[authenticationkey]/GetSchema?apsws.time=[timestamp]&apsws.authSig=[signature]



POST parameters:

apsdb.schemaName=mySchema1 



Sample XML Response

Success XML:

<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd">
    <metadata>
        <requestId>550e8400-e29b-41d4-a716-446655440000</requestId>
        <status>success</status>
    </metadata>
    <result>
        <schema>
        <aclGroups>
          <aclGroup name="aclGroup1">
              <read>anonymous</read>
              <write>creator</write>
              <fields>
                  <field>field1</field>
                  <field>field2</field>
              </fields>
          </aclGroup>
          <defaultAcl>
              <read>all</read>
              <write>all</write>
              <delete>all</delete>
          </defaultAcl>
          <schemaAcl>
              <read>user1;user2;group:group1</read>
              <write>user1;user2;group:group1</write>
              <delete>user1;user2;group:group1</delete>
          </schemaAcl>
        </aclGroups>
        <fields>
            <field searchable="false" name="field1" type="numeric">
                <validation>
                    <cardinality max="1" min="0"/>                    
                    <regex> ([0-9]{0,2})</regex>
                    <range max="10" min="0"/>
                </validation>
            </field>
            <field name="field2" type="string" />
        </fields>
        </schema>    
    </result>
</response> 



Failure XML:

<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd">
    <metadata>
        <requestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</requestId>
        <status>failure</status>
        <errorCode>[errorCode]</errorCode>
        <errorDetail>[failMsg]</errorDetail>
    </metadata>
</response> 



Sample JSON Response

{"response": {
  "metadata": {
    "requestId": "b950f782-0444-4c38-aa19-2dbdd2e14ca9",
    "status": "success"
  },
  "result": "<schema><aclGroups><aclGroup name=\"aclGroup1\"><read>anonymous</read><write>creator</write><fields><field>field1</field>
             <field>field2</field></fields></aclGroup><defaultAcl><read>all</read><write>all</write><delete>all</delete></defaultAcl>
             <schemaAcl><read>user1;user2;group:group1</read><write>user1;user2;group:group1</write><delete>user1;user2;group:group1</delete></schemaAcl>
             </aclGroups><fields><field name=\"field1\"  type=\"numeric\"   searchable=\"false\"><validation>
             <regex> ([0-9]{0,2})</regex><cardinality min=\"0\" max=\"1\"></cardinality><range  min=\"0\"  max=\"10\"></range></validation></field>
             <field name=\"field2\"  type=\"string\"   searchable=\"false\"><validation></validation></field></fields></schema>"
}} 


 

 

  • No labels