-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 2.0.7 - Add SLA ServiceInstance Relations
- Loading branch information
1 parent
5eb317b
commit f670fa6
Showing
5 changed files
with
187 additions
and
3 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
Source/Sdk4me.Tests/ServiceLevelAgreementServiceInstancesTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
|
||
namespace Sdk4me.Tests | ||
{ | ||
[TestClass] | ||
public class ServiceLevelAgreementServiceInstancesTest | ||
{ | ||
[TestMethod] | ||
public void Get() | ||
{ | ||
Sdk4meClient client = Client.Get(); | ||
ServiceLevelAgreement sla = client.ServiceLevelAgreements.Get(313); | ||
Assert.IsNotNull(sla); | ||
|
||
List<ServiceLevelAgreementServiceInstanceRelation> relations = client.ServiceLevelAgreements.GetServiceInstances(sla, "*"); | ||
Assert.IsNotNull(relations); | ||
|
||
ServiceLevelAgreementServiceInstanceRelation relation = relations.Where(x => x.ServiceInstance.ID == 87).FirstOrDefault(); | ||
Assert.IsNotNull(relation); | ||
|
||
bool result = client.ServiceLevelAgreements.DeleteServiceInstance(sla, relation); | ||
Assert.AreEqual(true, result); | ||
|
||
relation = client.ServiceLevelAgreements.AddServiceInstance(sla, new ServiceLevelAgreementServiceInstanceRelation() | ||
{ | ||
ImpactRelation = ServiceLevelAgreementServiceInstanceRelationStatus.Down, | ||
ServiceInstance = new ServiceInstance() { ID = 87 } | ||
}); | ||
Assert.IsNotNull(relation); | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
Source/Sdk4me/Entities/ServiceLevelAgreementServiceInstanceRelation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
|
||
namespace Sdk4me | ||
{ | ||
/// <summary> | ||
/// A 4me <see href="https://developer.4me.com/v1/service_level_agreements/service_instances/">service instance relation</see> object. | ||
/// </summary> | ||
public class ServiceLevelAgreementServiceInstanceRelation : BaseItem | ||
{ | ||
private ServiceLevelAgreementServiceInstanceRelationStatus impactRelation; | ||
private ServiceInstance serviceInstance; | ||
|
||
#region Created at (override) | ||
|
||
/// <summary> | ||
/// The creation date and time; which is obsolete for this object. | ||
/// </summary> | ||
[JsonProperty("created_at"), Sdk4meIgnoreInFieldSelection()] | ||
public override DateTime? CreatedAt | ||
{ | ||
get => base.CreatedAt; | ||
internal set => base.CreatedAt = null; | ||
} | ||
|
||
#endregion | ||
|
||
#region Impact relation | ||
|
||
/// <summary> | ||
/// The type of the relation. | ||
/// </summary> | ||
[JsonProperty("impact_relation"), Sdk4meIgnoreInFieldSelection()] | ||
public ServiceLevelAgreementServiceInstanceRelationStatus ImpactRelation | ||
{ | ||
get => impactRelation; | ||
set => impactRelation = SetValue("impact_relation", impactRelation, value); | ||
} | ||
|
||
#endregion | ||
|
||
#region Service instance | ||
|
||
/// <summary> | ||
/// The linked service instance. | ||
/// </summary> | ||
[JsonProperty("service_instance"), Sdk4meIgnoreInFieldSelection()] | ||
public ServiceInstance ServiceInstance | ||
{ | ||
get => serviceInstance; | ||
set => serviceInstance = SetValue("service_instance_id", serviceInstance, value); | ||
} | ||
|
||
[JsonProperty("service_instance_id"), Sdk4meIgnoreInFieldSelection()] | ||
internal long? ServiceInstanceID => serviceInstance?.ID; | ||
|
||
#endregion | ||
|
||
#region Updated at (override) | ||
|
||
/// <summary> | ||
/// The updated date and time; which is obsolete for this object. | ||
/// </summary> | ||
[JsonProperty("updated_at"), Sdk4meIgnoreInFieldSelection()] | ||
public override DateTime? UpdatedAt | ||
{ | ||
get => base.UpdatedAt; | ||
internal set => base.UpdatedAt = null; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters