Interface IAgentService
Represents the Agent API service.
Namespace: Relativity.Testing.Framework.Api.Services
Assembly: Relativity.Testing.Framework.Api.dll
Syntax
public interface IAgentService
Examples
_agentService = relativityFacade.Resolve<IAgentService>();
Methods
| Improve this Doc View SourceCreate(Agent)
Creates the specified agent.
Declaration
Agent Create(Agent entity)
Parameters
Type | Name | Description |
---|---|---|
Agent | entity | The Agent entity to create. |
Returns
Type | Description |
---|---|
Agent | The created Agent entity. |
Examples
var agentType = relativityFacade.Resolve<IGetByNameStrategy<AgentType>>()
.Get("Some Agent Type");
var agentServer = relativityFacade.Resolve<IAgentServerGetAvailableStrategy>().GetAvailable(_agentType.Name)[0];
var entity = new Agent
{
AgentType = agentType,
AgentServer = agentServer,
RunInterval = 25
}
var createdAgent = _agentService.Create(entity);
|
Improve this Doc
View Source
Delete(Int32)
Deletes the agent by ID.
Declaration
void Delete(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The artifact ID of the agent. |
Examples
_agentService.Delete(agentToDeleteArtifactId);
|
Improve this Doc
View Source
Get(Int32)
Gets the agent by the specified ID.
Declaration
Agent Get(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The artifact ID of the agent. |
Returns
Type | Description |
---|---|
Agent | The Agent entity or null. |
Examples
Agent agent = _agentService.Get(someAgentArtifatId);
|
Improve this Doc
View Source
GetAgentType(String)
Gets agent type by specified name.
Declaration
AgentType GetAgentType(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The agent type name. |
Returns
Type | Description |
---|---|
AgentType | The collection of AgentType entities. |
Examples
AgentType sampleAgentType = _agentService.GetAgentType("Sample Agent Type Name");
|
Improve this Doc
View Source
GetAllAgents()
Gets all agents.
Declaration
IEnumerable<Agent> GetAllAgents()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Agent> | The collection of Agent entities. |
Examples
IEnumerable<Agent> allAgents = _agentService.GetAllAgents();
|
Improve this Doc
View Source
GetAllAgentsForAgentType(String)
Gets all agents by specified agent type.
Declaration
IEnumerable<Agent> GetAllAgentsForAgentType(string agentTypeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | agentTypeName | The agent type name. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Agent> | The collection of Agent entities. |
Examples
IEnumerable<Agent> = _agentService.GetAllAgentsForAgentType("Sample Agent Type Name");
|
Improve this Doc
View Source
GetAllAgentTypes()
Gets all agent types.
Declaration
IEnumerable<AgentType> GetAllAgentTypes()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<AgentType> | The collection of AgentType entities. |
Examples
IEnumerable<AgentType> allAgentTypes = _agentService.GetAllAgentTypes();
|
Improve this Doc
View Source
GetAvailableAgentServers(String)
Gets available agent servers for specified agent type.
Declaration
IEnumerable<AgentServer> GetAvailableAgentServers(string agentTypeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | agentTypeName | The agent type name. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<AgentServer> | The collection of AgentServer entities. |
Examples
IEnumerable<AgentServer> availableAgentServes = _agentService.GetAvailableAgentServers(someAgent.AgentType.Name);
|
Improve this Doc
View Source
Require(Agent)
Requires the specified Agent(s).
- If Artifact.ArtifactID property of
entity
has positive value, gets entity by id and updates it. - If Agent.AgentType property of
entity
exists, gets entity by type and updates it. - Otherwise creates a new entity using ICreateStrategy<T>.
Declaration
Agent Require(Agent entity)
Parameters
Type | Name | Description |
---|---|---|
Agent | entity | The Agent entity to require. |
Returns
Type | Description |
---|---|
Agent | The required entity . |
Examples
var agentToUpdate = _agentService.Get(agentArtifactId);
agentToUpdate.LoggingLevel = AgentLoggingLevelType.Critical;
var updatedAgent = _agentService.Require(agentToUpdate); // Finds agent by id, updates LoggingLevel property and returns it
var agentType = relativityFacade.Resolve<IGetByNameStrategy<AgentType>>()
.Get("Some Agent Type");
var agentServer = relativityFacade.Resolve<IAgentServerGetAvailableStrategy>().GetAvailable(_agentType.Name)[0];
var agentToCreate = new Agent
{
AgentType = agentType,
AgentServer = agentServer,
RunInterval = 25
}
var createdAgent = _agentService.Require(agentToCreate); // Creates new agent and returns it
|
Improve this Doc
View Source
Update(Agent)
Updates the specified Agent.
Declaration
void Update(Agent entity)
Parameters
Type | Name | Description |
---|---|---|
Agent | entity | The entity to update. |
Examples
var agentToUpdate = _agentService.Get(agentArtifactId);
agentToUpdate.Enabled = false;
_agentService.Update(agentToUpdate);