-
Notifications
You must be signed in to change notification settings - Fork 3
SySML2.NET.REST
samatrhea edited this page Feb 6, 2023
·
2 revisions
The SySML2.NET.REST
is a netstandard2.0 library which is an implementation of the REST/HTTP Platform-Specific Model (PSM) for the Systems Modeling API and Services is described in Systems Modeling Application Programming Interface (API) and Services.
The library exposes the IRestClient
interface to interact with the PSM REST API.
The IRestClient
interface exposes 8 methods to read/request data from the API.
Task<IEnumerable<Project>> Open(string username, string password, string uri, CancellationToken cancellationToken);
void Close();
Task<IEnumerable<Project>> RequestProjects(Guid? project, QueryParameters queryParameters, CancellationToken cancellationToken);
Task<IEnumerable<Branch>> RequestBranches(Guid project, Guid? branch, QueryParameters queryParameters, CancellationToken cancellationToken);
Task<IEnumerable<Commit>> RequestCommits(Guid project, Guid? commit, QueryParameters queryParameters, CancellationToken cancellationToken);
Task<IEnumerable<Tag>> RequestTags(Guid project, Guid? tag, QueryParameters queryParameters, CancellationToken cancellationToken);
Task<IEnumerable<IElement>> RequestElements(Guid project, Guid commit, Guid? element, QueryParameters queryParameters, CancellationToken cancellationToken);
Task<IEnumerable<IElement>> RequestRootElements(Guid project, Guid commit, QueryParameters queryParameters, CancellationToken cancellationToken);
The following code snippet demonstrates how the IRestClient
works:
var uri = "http://sysml2-sst.intercax.com:9000";
var cancellationTokenSource = new CancellationTokenSource();
var httpClient = new HttpClient();
var deserializer = new DeSerializer();
var serializer = new Serializer();
IRestClient restClient = new RestClient(httpClient, deserializer, serializer);
await restClient.Open("john", "doe", uri, cancellationTokenSource.Token)
var projects = await restClient.RequestProjects(null, null, this.cancellationTokenSource.Token);
var projectId = projects.First().Id;
await restClient.RequestProjects(projectId, null, this.cancellationTokenSource.Token)).Single();
var commit = await this.restClient.RequestCommits(projectId, null, null, this.cancellationTokenSource.Token).First();
var elements = await restClient.RequestElements(project.Id, commit.Id, null, null, this.cancellationTokenSource.Token);
copyright @ Starion Group S.A.