[DO-1652] remove old methods in eva package (!69)
Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech> Co-authored-by: Denis Patrakeev <denis.patrakeev@avroid.team> Reviewed-on: https://git.avroid.tech/DevOps/jenkins-shared-lib/pulls/69 Reviewed-by: Vasiliy Chipizhin <vasiliy.chipizhin@avroid.team> Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.team>
This commit is contained in:
@@ -1,97 +0,0 @@
|
|||||||
package tech.avroid.api
|
|
||||||
|
|
||||||
import groovy.json.JsonOutput
|
|
||||||
import groovy.json.JsonSlurper
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for work with API Eva
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
class Eva implements Serializable {
|
|
||||||
private Script script
|
|
||||||
private String host
|
|
||||||
private String creds
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param script Script - script context
|
|
||||||
* @param host String - url of Eva service
|
|
||||||
* @param creds String - jenkins credentials with eva token for API work
|
|
||||||
*/
|
|
||||||
Eva(Script script, String host, String creds) {
|
|
||||||
this.script = script
|
|
||||||
this.host = host
|
|
||||||
this.creds = creds
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new link for Eva Object. For example, tasks
|
|
||||||
* !WARNING: can to create multiple similar links
|
|
||||||
* @param parentId String - id of Object for which created link
|
|
||||||
* @param linkName String - name of link
|
|
||||||
* @param url String - full url of link
|
|
||||||
*/
|
|
||||||
public void createLink(String parentId, String linkName, String url) {
|
|
||||||
Map body = [
|
|
||||||
jsonrpc: "1.2",
|
|
||||||
method: "CmfLink.create",
|
|
||||||
kwargs: [
|
|
||||||
parent: parentId,
|
|
||||||
name: linkName,
|
|
||||||
url: url
|
|
||||||
]]
|
|
||||||
|
|
||||||
script.withCredentials([script.string(credentialsId: creds, variable: 'token')]) {
|
|
||||||
script.httpRequest(
|
|
||||||
url: "$host/api/",
|
|
||||||
contentType: 'APPLICATION_JSON',
|
|
||||||
httpMode: 'POST',
|
|
||||||
customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]],
|
|
||||||
validResponseCodes: '200',
|
|
||||||
requestBody: JsonOutput.toJson(body)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getting Eva task id
|
|
||||||
* @param filterValue String - value for search task
|
|
||||||
* @param filterParam String - type of filter for search task. Default value - "code"
|
|
||||||
* @return String - id of task
|
|
||||||
*/
|
|
||||||
public String getTaskId(String filterValue, String filterParam = "code") {
|
|
||||||
String response = getTask(filterValue, filterParam)
|
|
||||||
Object result = new JsonSlurper().parseText(response).result
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
return result.id
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getting Eva task information
|
|
||||||
* @param filterValue String - value for search task
|
|
||||||
* @param filterParam String - type of filter for search task. Default value - "code"
|
|
||||||
* @return String - id of task
|
|
||||||
*/
|
|
||||||
private String getTask(String filterValue, String filterParam = "code") {
|
|
||||||
Map body = [
|
|
||||||
jsonrpc: "1.2",
|
|
||||||
method: "CmfTask.get",
|
|
||||||
kwargs: [
|
|
||||||
filter: [filterParam, "==", filterValue],
|
|
||||||
]]
|
|
||||||
|
|
||||||
script.withCredentials([script.string(credentialsId: creds, variable: 'token')]) {
|
|
||||||
return script.httpRequest(
|
|
||||||
url: "$host/api/",
|
|
||||||
contentType: 'APPLICATION_JSON',
|
|
||||||
httpMode: 'POST',
|
|
||||||
customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]],
|
|
||||||
validResponseCodes: '200',
|
|
||||||
requestBody: JsonOutput.toJson(body)
|
|
||||||
).content.toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package tech.avroid.eva
|
package tech.avroid.eva
|
||||||
|
|
||||||
import groovy.json.JsonOutput
|
import groovy.json.JsonOutput
|
||||||
import groovy.json.JsonSlurper
|
import groovy.json.JsonSlurperClassic
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for work with API Eva
|
* Class for work with API Eva
|
||||||
@@ -26,16 +26,16 @@ class Eva implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Create new link for Eva Object. For example, tasks
|
* Create new link for Eva Object. For example, tasks
|
||||||
* !WARNING: can to create multiple similar links
|
* !WARNING: can to create multiple similar links
|
||||||
* @param parentId String - id of Object for which created link
|
* @param taskId String - id of Object for which created link
|
||||||
* @param linkName String - name of link
|
* @param linkName String - name of link
|
||||||
* @param url String - full url of link
|
* @param url String - full url of link
|
||||||
*/
|
*/
|
||||||
public void createLink(String parentId, String linkName, String url) {
|
public void createLink(String taskId, String linkName, String url) {
|
||||||
Map body = [
|
Map body = [
|
||||||
jsonrpc: "1.2",
|
jsonrpc: "1.2",
|
||||||
method: "CmfLink.create",
|
method: "CmfLink.create",
|
||||||
kwargs: [
|
kwargs: [
|
||||||
parent: parentId,
|
parent: taskId,
|
||||||
name: linkName,
|
name: linkName,
|
||||||
url: url
|
url: url
|
||||||
]]
|
]]
|
||||||
@@ -51,49 +51,6 @@ class Eva implements Serializable {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getting Eva task id
|
|
||||||
* @param filterValue String - value for search task
|
|
||||||
* @param filterParam String - type of filter for search task. Default value - "code"
|
|
||||||
* @return String - id of task
|
|
||||||
*/
|
|
||||||
public String getTaskId(String filterValue, String filterParam = "code") {
|
|
||||||
String response = getTask(filterValue, filterParam)
|
|
||||||
Object result = new JsonSlurper().parseText(response).result
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
return result.id
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getting Eva task information @Deprecated use getTaskInfo
|
|
||||||
* @param filterValue String - value for search task
|
|
||||||
* @param filterParam String - type of filter for search task. Default value - "code"
|
|
||||||
* @return String - id of task
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
private String getTask(String filterValue, String filterParam = "code") {
|
|
||||||
Map body = [
|
|
||||||
jsonrpc: "1.2",
|
|
||||||
method: "CmfTask.get",
|
|
||||||
kwargs: [
|
|
||||||
filter: [filterParam, "==", filterValue],
|
|
||||||
]]
|
|
||||||
|
|
||||||
script.withCredentials([script.string(credentialsId: creds, variable: 'token')]) {
|
|
||||||
return script.httpRequest(
|
|
||||||
url: "$host/api/",
|
|
||||||
contentType: 'APPLICATION_JSON',
|
|
||||||
httpMode: 'POST',
|
|
||||||
customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]],
|
|
||||||
validResponseCodes: '200',
|
|
||||||
requestBody: JsonOutput.toJson(body)
|
|
||||||
).content.toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getting Eva task information
|
* Getting Eva task information
|
||||||
@@ -110,14 +67,18 @@ class Eva implements Serializable {
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
script.withCredentials([script.string(credentialsId: creds, variable: 'token')]) {
|
script.withCredentials([script.string(credentialsId: creds, variable: 'token')]) {
|
||||||
return script.readJSON( text: script.httpRequest(
|
String response = script.httpRequest(
|
||||||
url: "$host/api/",
|
url: "$host/api/",
|
||||||
contentType: 'APPLICATION_JSON',
|
contentType: 'APPLICATION_JSON',
|
||||||
httpMode: 'POST',
|
httpMode: 'POST',
|
||||||
customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]],
|
customHeaders: [[name: 'Authorization', value: "Bearer $script.token"]],
|
||||||
validResponseCodes: '200',
|
validResponseCodes: '200',
|
||||||
requestBody: JsonOutput.toJson(body)
|
requestBody: JsonOutput.toJson(body)
|
||||||
).content.toString())['result']
|
).content
|
||||||
|
|
||||||
|
Map result = new JsonSlurperClassic().parseText(response).result
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user