27 DOMAIN TYPE ACTION INVOKE RESOURCE

The domain type action invoke resource represents an action that can be invoked on the domain type itself. Conceptually it is similar to the domain object action invoke resource, §C19, but the action is on the type rather than an instance of the type.

Restful Objects defines the following type actions.

Type
action
See Description

isSubtypeOf()

to determine if a domain type is a subtype of (or the same as) a given type.

isSupertypeOf()

to determine if a domain type is a supertype of (or the same as) a given type.

The endpoint URL for this resource is:

/domain-types/{domainType}/type-actions/{typeactionId}/invoke

where:

  • {domainType} is either

    • the domain type id or

    • is a built-in JSON type

  • {typeactionId} identifies the action

Both of the defined type actions take a single argument representing a link to the supertype.

As for the invocation of object actions (§C19), type actions return a representation that links back to the type action and also to the result of the action. Both the currently defined type actions return a scalar §B12. The links from the domain type action result representation to other resources are as shown in the diagram below:

figure 22
Figure 1. DOMAIN TYPE ACTION REPRESENTATION

The representations returned by type actions follow the format:

{
  "links" : [ {
      "rel" : "self",
      "href" : "http://~/domain-types/CUS/typeactions/... /invoke",
      "method" : "GET",
      "type": "application/json;profile=\".../type-action-result\"",
      "arguments" : ...
   } ],
   "id": ...,
   "value" : ...,
   "extensions" : { ... }
}

where:

JSON-Property Description

links

list of links to other resources.

links[rel=self]

link to a resource that can obtain this representation

id

the typeActionId of this action value the result of the action

extensions

map of additional information about the resource.

27.1 HTTP GET isSubtypeOf()

Obtain a representation resulting from the invocation of the isSubtypeOf() domain type action.

27.1.1 GET Request

27.1.1.1 URL and Query String

The endpoint URL for this resource is:

/domain-types/{domainType}/type-actions/isSubtypeOf/invoke

where:

  • {domainType} is either

    • the domain type id, or

    • is a built-in JSON type

This resource requires a parameter "supertype" which can be specified either in the simple style, or in the formal style.

Simple Style

If query arguments are specified using the simple style (§A2.9.1 then the query string is simply:

?supertype=xxx

where xxx is the domain type id of the supertype.

Formal Style

If query arguments are specified using the formal style (§A2.9.2) then the supertype should be specified as a map and then the map encoded as a URL (§A2.9.2.5).

For example:

{
  "supertype": {
    "value": {
      "href": "http://~/domain-types/x.BasketOwner"
    }
  }
}

Note that the value should be a link to the supertype, rather than simply the name of the supertype.

27.1.1.2 Headers

  • Accept

    • application/json

    • application/json;profile="…​/type-action-result"

27.1.1.3 Body

  • N/A

27.1.2 GET Response

27.1.2.1 Status Code

  • 200 "OK"

27.1.2.2 Headers

  • Content-Type

    • application/json;profile="…​/type-action-result"

  • Caching headers:

    • NON_EXPIRING, see §A2.13

      • the structure of a domain type will not vary between deployments

27.1.2.3 Body (representation)

The JSON representation returned The JSON representation returned is a type-action-result representation (as described earlier) with a scalar representation §B12 in-lined.

For example, if checking that the Customer domain type is a subtype of BasketOwner interface type, then the returned representation might look something like:

{
  "links" : [ {
      "rel" : "self",
      "href" : "http://~/domain-types/CUS/typeactions/isSubtypeOf/invoke",
      "method" : "GET",
      "type" : "application/json;profile=\".../type-action-result\"",
      "arguments" : {
        "supertype" : {
          "href" : "http://~/domain-types/x.BasketOwner"
         }
      }
  } ],
  "id": "isSubtypeOf",
  "value" : true,
  "extensions" : { ... }
}

where:

JSON-Property Description

id

the literal "isSubtypeOf" for this type action

value

a scalar boolean value.

...and other properties are as described earlier.

27.1.3 GET Not found Response

27.1.3.1 Status Code

  • 404 "Not found"

27.1.3.2 Headers

  • Warning:

    • No such domain type {domainType}

    • No such domain type action {actionId} in domain type `{domainType}

    • No such super/subtype

27.1.3.3 Body

empty

27.2 HTTP GET isSupertypeOf()

Obtain a representation resulting from the invocation of the isSupertypeOf() domain type action.

27.2.1 GET Request

27.2.1.1 URL and Query String

The endpoint URL for this resource is:

/domain-types/{domainType}/type-actions/isSupertypeOf/invoke

This resource requires a parameter "subtype" which can be specified either in the simple style, or in the formal style.

Simple Style

If query arguments are specified using the simple style (§A2.9.1) then the query string is simply:

?subtype=xxx

where xxx is the domain type id of the subtype.

Formal Style

If query arguments are specified using the formal style (§A2.9.2) then the subtype should be specified as a map and then the map encoded as a URL (§A2.9.2.5).

For example:

{
  "subtype": {
    "value": {
      "href": "http://~/domain-types/CUS"
    }
  }
}

Note that the value should be a link to the subtype, rather than simply the name of the subtype.

27.2.1.2 Headers

  • Accept

    • application/json

    • application/json;profile="…​/type-action-result"

27.2.1.3 Body

  • N/A

27.2.2 GET Response

27.2.2.1 Status Code

  • 200 "OK"

27.2.2.2 Headers

  • Content-Type

    • application/json;profile="…​/type-action-result"

  • Caching headers:

    • NON_EXPIRING, see §A2.13

      • the structure of a domain type will not vary between deployments

27.2.2.3 Body (representation)

The JSON representation returned The JSON representation returned is a typeactionresult representation (as described earlier) with a scalar representation §B12 in-lined.

For example, if checking that the BasketOwner domain type is a supertype of the Customer domain type, then the returned representation might look something like:

{
  "links" : [ {
      "rel" : "self",
      "href" : "http://~/domain-types/x.BasketOwner /typeactions/isSupertypeOf/invoke",
      "method" : "GET",
      "type" : "application/json;profile=\".../type-action-result\"",
      "arguments" : {
        "supertype" : {
          "href" : "http://~/domain-types/CUS"
         }
      }
  } ],
  "id": "isSupertypeOf",
  "value" : true,
  "extensions" : { ... }
}

where:

JSON-Property Description

id

the literal "isSupertypeOf" for this type action

value

a scalar boolean value.

... and other properties are as described earlier.

27.2.3 GET Not found Response

27.2.3.1 Status Code

  • 404 "Not found"

27.2.3.2 Headers

  • Warning:

    • No such domain type `{domainType}`.

    • No such domain type action {actionId} in domain type {domainType}

    • No such super/subtype

27.2.3.3 Body

empty