DemoClient
A demo class implementing an API client interface.
Properties
Name | Type | Description |
---|---|---|
connection | Connection | The HTTP connection that can be used to retrieve data from the import source. For reference on the http module, see http. |
sslKeyName | string | The name of the SSL key if it is selected. |
token | string | The authorization token or the password entered by the user. |
url | string | The URL of the import source entered by the user. |
Constructors
DemoClient
Creating a DemoClient instance.
Parameters
Name | Type | Description |
---|---|---|
context | Object | The object holding parameters entered via the UI. |
Methods
getArticleUpdates
The method is only required if the client supports continuous import mode. The articles should be ordered either by internal ID or created date ascending. Returns articles that were updated after the specified timestamp.
Parameters
Name | Type | Description |
---|---|---|
projectInfo | ProjectInfo | The project where the requested articles belong. |
after | DocumentInfo | The article that the requested articles follow. |
updatedAfter | string | The requested articles are expected to be updated after this timestamp. |
top | number | The number of articles to be returned. If there are fewer articles left to import, the method returns them all. If the method returns more articles than it was requested, those extra articles are not processed, and the next time the method is called, the last of the processed articles is passed into `after` parameter. |
Return Value
Type | Description |
---|---|
Array.<Article> | Articles following the specified one in the specified project that were updated after the specified timestamp. |
getArticles
Returns articles from the specified project.
Parameters
Name | Type | Description |
---|---|---|
projectInfo | ProjectInfo | The project where the specified articles belong to. |
after | DocumentInfo | The article that the returned articles follow. |
top | number | The number of articles to be returned. If there are fewer articles left to import, the method returns them all. If the method returns more articles than it was requested, those extra articles are not processed, and the next time the method is called, the last of the processed articles is passed into `after` parameter. |
Return Value
Type | Description |
---|---|
Array.<Article> | Articles following the specified one in the specified project. |
getAttachmentContent
Returns the content of the specified attachment. Alternatively, you can get the attachment content as an HTTP response. For this option, you will need to use the http module. See the example below and use it to replace the default method implementation.
Parameters
Name | Type | Description |
---|---|---|
project | ProjectInfo | The project where the attachment belongs to. |
document | DocumentInfo | The type of the entity where the attachment belongs to (issue or article). |
attachment | Attachment | The specified attachment. |
Return Value
Type | Description |
---|---|
AttachmentContentWithMetadata | The content of the specified attachment. |
Example
getIssueUpdates
The method is only required if the client supports continuous import mode. The issues should be ordered either by internal ID or created date ascending. Returns issues that were updated after the specified timestamp.
Parameters
Name | Type | Description |
---|---|---|
projectInfo | ProjectInfo | The project where the requested issues belong. |
after | DocumentInfo | The issue that the requested issues follow. |
updatedAfter | string | The requested issues are expected to be updated after this timestamp. |
top | number | The number of issues to be returned. If there are fewer issues left to import, the method returns them all. If the method returns more issues than it was requested, those extra issues are not processed, and the next time the method is called, the last of the processed issues is passed into `after` parameter. |
Return Value
Type | Description |
---|---|
Array.<Issue> | Issues following the specified one in the specified project that were updated after the specified timestamp. |
getIssues
This method is invoked during the initial issues loading phase to load issues in chunks. It's recommended that the issues are ordered by either internal ID or created date ascending. The returned issues will be imported one by one in the same order. Returns issues from the specified project.
Parameters
Name | Type | Description |
---|---|---|
projectInfo | ProjectInfo | The project the returned issues belong to. |
after | DocumentInfo | The issue that the returned issues follow. |
top | number | The number of issues to be returned. If there are fewer issues left to import, the method returns them all, if the method returns more issues than it was requested, those extra issues are not processed, and the next time the method is called, the last of the processed issues is passed into `after` parameter. |
Return Value
Type | Description |
---|---|
Array.<Issue> | A list of issues that follow the specified one in the specified project. |
getLinkTypes
Returns all link types available in the import source.
Return Value
Type | Description |
---|---|
Array.<LinkType> | A list of link types. |
getProject
Returns an object containing a detailed description of a project including its custom field schema. In case the method is not defined by a client, the custom field schema (types, values, cardinality) will be defined based on the values provided in the `Issue` objects.
Parameters
Name | Type | Description |
---|---|---|
projectInfo | ProjectInfo | Information allowing the client to locate the project. |
Return Value
Type | Description |
---|---|
Project | The detailed project description. |
getProjects
Returns information about all projects available in the import source.
Return Value
Type | Description |
---|---|
Array.<ProjectInfo> | A list of projects available in the import source. |
getServerInfo
Returns the version and the time of the server.
Return Value
Type | Description |
---|---|
ServerInfo | An object with the version and time of the server set as its properties. |
getTimestampFormats
Returns timestamp formats (for example, `yyyy-MM-dd'T'HH:mm:ss.SSSX`) that are used by the import source. The first of the returned values will be used to format the timestamp passed into the `updateAfter` parameter in the `getIssueUpdates` function. If the list is `null` or empty, the import will behave as if the `DEFAULT_TIME_FORMATS` object was returned. The string presentations matching against the formats containing timezone (for example, `yyyy-MM-dd'T'HH:mm:ss.SSSX` or `yyyy-MM-dd'T'HH:mm:ss.SSSZ`) will be converted to timestamps in the timezone parsed from that string. Otherwise, the timezone returned by the `getUserTimeZoneId` method is used.
Return Value
Type | Description |
---|---|
Array.<string> | A list of timestamp formats. |
getUserTimeZoneId
ID of the timezone of the user who runs the import. If `null` or empty, the import script will use the timezone of the YouTrack user.
Return Value
Type | Description |
---|---|
string | The ID of the user timezone. |
getUsers
Returns users belonging to the specified group.
Parameters
Name | Type | Description |
---|---|---|
group | UserGroup | The user group to retrieve members of. |
skip | number | Number of heading records to skip. |
top | number | Maximum number of records to be returned. If more records are returned, only `top` number of these records will be processed and the rest will be ignored. |
Return Value
Type | Description |
---|---|
Array.<User> | A list of users that belong to the specified project. |
prepareToImport
A function that is invoked right before an import round is started. A client can perform any necessary initialization here.