Skip to content
roei sabag edited this page Aug 23, 2020 · 4 revisions

API: Models

Use the following API methods to request details about Rhino Models and to create or modify them.

Get Models

Returns a list of available Rhino Models.

GET /api/v3/models

Response Content

{
    "data": {
        "collection": [
            {
                "id": "1ed4ea1c-9959-40d7-b40e-717b8fc1cfb4",
                "configurations": [
                    "03d1cd94-5e38-43d8-b010-e932d92f9067",
                    "8bed8025-3cgf-52g1-0919-533cbc6d523c"
                ],
                "models": 1,
                "entries": 3
            },
            {
                "id": "ba6b3da7-1979-48ea-9b00-e30682f5f111",
                "configurations": [],
                "models": 1,
                "entries": 3
            }
        ]
    }
}

The example response includes 2 models, with 1 entries each and 2 configurations for one of them.

Name Type Description
id string The ID of the Rhino Models.
configurations array All Rhino Configurations which are using the model.
models number Total models under the models collection.
entries number Total entries (elements) under the model.

Response Codes

Code Description
200 Success, the Rhino Models were returned as part of the response.
500 Fail, the server encountered an unexpected error.

Get Models Collection

Returns an existing Rhino Model collection.

GET /api/v3/models/:collection_id
Name Type Description
collection_id string The ID of the Rhino Model collection.

Response Content

Please see below for a typical response:

[
	{
		"name": "Students Input Models",
		"entries": [
			{
				"name": "search students text-box",
				"value": "#SearchString",
				"type": "css selector",
                "model": "Students Input Models",
				"comment": "Search students text-box on the top center panel under students page."
			},
			{
				"name": "search students button",
				"value": "//input[@id='SearchButton']",
                "type": "xpath",
				"model": "Students Input Models",
				"comment": "Search students button on the top center panel under students page."
			}	
		],
        "context": {
            "pageUrl": "https://gravitymvctestapplication.azurewebsites.net/student"
		}
	},
    "name": "Students Table Models",
    ...
]

The following system fields are always included in the response:

General

Name Type Description
name string The name of this Rhino Model.
entries array A collection of Rhino Model Entry.
context object A free style object which can be used to further describe the model.

Model Entry

Name Type Description
name string The name of the element (required and must be compliant with Rhino's language rules).
value string The value of selected locator (required).
type string The type of selected locator. If no type specified, default is XPath.
model string The model name to which this entry belongs to. Default is the parent model name (optional).
comment string Any comment relevant for further describing this model entry (optional).

Response Codes

Code Description
200 Success, the Models were returned as part of the response.
404 Not Found, the Models were not found under the models collection.
500 Fail, the server encountered an unexpected error.

Create Model

Creates a new Rhino Model.

POST /api/v3/models

Request Fields

The request body follows the same format as Get Model response content.

Request Example

[
	{
		"name": "Students Input Models",
		"entries": [
			{
				"name": "search students text-box",
				"value": "#SearchString",
				"type": "css selector",
                "model": "Students Input Models",
				"comment": "Search students text-box on the top center panel under students page."
			},
			{
				"name": "search students button",
				"value": "//input[@id='SearchButton']",
                "type": "xpath",
				"model": "Students Input Models",
				"comment": "Search students button on the top center panel under students page."
			}	
		],
        "context": {
            "pageUrl": "https://gravitymvctestapplication.azurewebsites.net/student"
		}
	}
]

Response Codes

Code Description
201 Success, the Models Collection created and identifier was returned as part of the response.
400 Bad Request, the request is missing a mandatory field(s) or bad formatted.
500 Fail, the server encountered an unexpected error.

Get Associated Configurations

Returns a list of available Rhino Configurations which are associated with this Rhino Model collection.

GET /api/v3/models/:collection_id/configurations
Name Type Description
collection_id string The ID of the Rhino Models collection.

Response Content

{
    "data": {
        "configurations": [
            "03d1cd94-5e38-43d8-b010-e932d92f9067",
            "8bed8025-3cgf-52g1-0919-533cbc6d523c"
        ]
    }
}

The example response includes 2 configuration which are associated with this collection.

Name Type Description
configurations array All Rhino Models which are using the model.

Response Codes

Code Description
200 Success, the Rhino Configurations were returned as part of the response.
404 Not Found, the Rhino Models collection was not found.
500 Fail, the server encountered an unexpected error.

Add Models to Collection

Add additional Rhino Models into an existing collection. If the model name is already exists on another model, it will be ignored.

PATCH /api/v3/models/:collection_id
Name Type Description
collection_id string The ID of the Rhino Models collection.

Request Fields

The request body follows the same format as Get Model response content.

Request Example

[
	{
		"name": "Students Input Models",
		"entries": [
			{
				"name": "search students text-box",
				"value": "#SearchString",
				"type": "css selector",
                "model": "Students Input Models",
				"comment": "Search students text-box on the top center panel under students page."
			},
			{
				"name": "search students button",
				"value": "//input[@id='SearchButton']",
                "type": "xpath",
				"model": "Students Input Models",
				"comment": "Search students button on the top center panel under students page."
			}	
		],
        "context": {
            "pageUrl": "https://gravitymvctestapplication.azurewebsites.net/student"
		}
	}
]

Response Codes

Code Description
200 Success, the Collection was returned as part of the response.
404 Not Found, the Collection was not found.
500 Fail, the server encountered an unexpected error.

Associate Configuration to Collection

Add additional Rhino Configuration into an existing collection.

PATCH /api/v3/models/:collection_id/configurations/:configuration_id
Name Type Description
collection_id string The ID of the Rhino Model collection.
configuration_id string The ID of the Rhino Configuration.

Response Codes

Code Description
200 Success, the Collection was returned as part of the response.
404 Not Found, the Collection or Configuration were not found.
500 Fail, the server encountered an unexpected error.

Delete Model Collection

Deletes an existing Rhino Model collection.

DELETE /api/v3/models/:collection_id
Name Type Description
collection_id string The ID of the Rhino Model collection.

Please Note: Deleting a collection cannot be undone and it can affect test cases and configurations which were using the models.

Response Codes

Code Description
204 Success, the Model collection was deleted.
404 Not Found, the Model was not found.
500 Fail, the server encountered an unexpected error.

Delete Model Collections

Deletes all existing Rhino Model collections.

DELETE /api/v3/models

Please Note: Deleting a collection cannot be undone and it can affect test cases and configurations which were using the models.

Response Codes

Code Description
204 Success, the Model collections were deleted.
500 Fail, the server encountered an unexpected error.