Skip to content

Commit 8815e5b

Browse files
Updated entities based on latest GraphQL schema (2024-04-06)
1 parent e72fc8b commit 8815e5b

File tree

4 files changed

+68
-31
lines changed

4 files changed

+68
-31
lines changed

README.md

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,30 @@ The 4me GraphQL API has a data type called `ISO8601Timestamp` which includes thr
5151

5252
These specific values can be accessed through the `DateTimeValue` class.
5353

54+
### Interface-based properties
55+
Certain properties return objects that conform to an interface, providing flexibility in the variety of objects they can provide.
56+
To obtain a specific object type from an interface-based property, it's crucial to indicate the desired type in the select statement of the query. Without specifying a type in the select statement, the property will return null.
57+
The .NET SDK facilitates querying such properties by allowing multiple select statements. This feature enables the retrieval of diverse sets of values for each object.
58+
5459
## Mutations
5560
Mutations are used to create, update, or delete data. Like queries, the SDK provides a simple and intuitive way to perform mutations.
5661

5762
## Attachments
5863
The SDK features an `UploadAttachment` method for easily uploading attachments, which can later be associated with any create or update mutation.
5964
The response from this request includes information necessary for linking these attachments.
6065

61-
## Multi-token support
66+
## Events API
67+
The .NET SDK provides access to the 4me Events API as well. For more information check out the [4me developer pages](https://developer.4me.com/v1/requests/events/).
68+
69+
## Multiple tokens
6270
The client allows for the use of multiple authentication tokens. A single token is limited to 3600 API requests per hour or 5000 points per hour for Query Cost. In some situations, this may not be sufficient.
6371
When there are multiple tokens in use, the client will always select the token with the most remaining requests to use. More information about [Rate Limiting](https://developer.4me.com/graphql/#request-rate-limits) and [Query Cost Limits](https://developer.4me.com/graphql/#query-cost-limit) can be found on the [4me developer website](https://developer.4me.com/graphql).
6472

73+
## Multiple accounts
74+
When connecting to multiple accounts within a single application, it is recommended to use multiple `Sdk4meClient` instances.
75+
While the `AccountID` can be set via the `Sdk4meClient.AccountID`, using the same client instance to execute multiple requests simultaneously across different accounts can lead to potential issues and unexpected behavior.
76+
To ensure effective management of multiple accounts, it's advisable to utilize a dictionary structure. For further information, please refer to the [example](#multiple-accounts-usage).
77+
6578
## Response timing
6679
The 4me GraphQL API limits the number of requests to 20 per 2 seconds. The SDK will keep track of the response time and lock the process to make sure it takes at least 100 milliseconds per request.
6780

@@ -186,8 +199,7 @@ IQuery query = Query.Person.OrderBy(PersonOrderField.Name, OrderBySortOrder.Asce
186199
```
187200
Sorting can only be used on the top level query.
188201

189-
#### Example
190-
202+
#### Nested query with filtering and sorting
191203
```csharp
192204
PersonQuery query = new PersonQuery()
193205
.View(PersonView.All)
@@ -215,6 +227,21 @@ PersonQuery query = new PersonQuery()
215227
DataList<Person> people = client.Get(query).Result;
216228
```
217229

230+
#### Interface-based properties
231+
Retrieve all archived properties and cast only those belonging to `Person`, `Request`, or `Task` types, each with their unique properties.
232+
```csharp
233+
DataList<Archive> archives = client.Get(Query.Archive
234+
.SelectArchived(new PersonQuery()
235+
.Select(PersonField.ID, PersonField.Name, PersonField.PrimaryEmail))
236+
.SelectArchived(new RequestQuery()
237+
.Select(RequestField.ID, RequestField.RequestId))
238+
.SelectArchived(new TaskQuery()
239+
.Select(TaskField.ID, TaskField.Subject)
240+
.SelectWorkflow(new WorkflowQuery()
241+
.Select(WorkflowField.ID, WorkflowField.Subject)))
242+
).Result;
243+
```
244+
218245
### Mutations
219246

220247
#### Create a new person and return the `ID`
@@ -363,17 +390,7 @@ var updatedRequest = client.Mutation(new RequestUpdateInput()
363390
}).Result;
364391
```
365392

366-
### Trace output
367-
A trace output providing details of a GraphQL query request and response time.
368-
```json
369-
{"id":"b1685ff0-6356-49eb-ab58-6ef32b9b4a61","method":"POST","uri":"https://graphql.4me.qa/","content":"{\"query\":\"query{node(id: \\\"KG1jIx\\\") {... on Person {id}}}\"}","account_id":"account-name"}
370-
{"id":"b1685ff0-6356-49eb-ab58-6ef32b9b4a61","response_time_in_ms":44}
371-
```
372-
373-
### Events API
374-
The .NET SDK provides access to the 4me Events API as well. For more information check out the [4me developer pages](https://developer.4me.com/v1/requests/events/).
375-
376-
#### Create a new event request
393+
### Create a new event via the events API
377394
```csharp
378395
RequestEventCreateInput requestCreate = new RequestEventCreateInput()
379396
.Category(RequestCategory.Incident)
@@ -409,7 +426,7 @@ catch (Sdk4meException ex)
409426
```
410427
By default the SDK will throw an new exception. The mutation method has one additional argument `throwOnError`, when false the `result` property will contain the error messages.
411428

412-
### Multi-token, accounts, environment and environment regions usage
429+
### Authentication tokens, account, environment and environment regions usage
413430
```csharp
414431
AuthenticationTokenCollection tokens = new AuthenticationTokenCollection()
415432
{
@@ -421,7 +438,21 @@ Sdk4meClient client = new(tokens, "account-name", EnvironmentType.Demo, Environm
421438
client.AccountID = "new-account-name";
422439
```
423440

424-
### Multi-token - Request and cost scores
441+
### Multiple accounts usage
442+
To ensure effective management of multiple accounts, it's recommended to employ a dictionary structure. This structure facilitates mapping each account to its corresponding `Sdk4meClient instance.
443+
444+
```csharp
445+
Dictionary<string, Sdk4meClient> clients = new()
446+
{
447+
{ "account-1", new Sdk4meClient(new AuthenticationTokenCollection() { ... }, "account-1", EnvironmentType.Production, EnvironmentRegion.EU) },
448+
{ "account-2", new Sdk4meClient(new AuthenticationTokenCollection() { ... }, "account-2", EnvironmentType.Production, EnvironmentRegion.EU) },
449+
{ "account-3", new Sdk4meClient(new AuthenticationTokenCollection() { ... }, "account-3", EnvironmentType.Production, EnvironmentRegion.EU) }
450+
};
451+
452+
clients["account-1"].Get(new AccountQuery().Select(AccountField.ID)).Result;
453+
```
454+
455+
### Multiple tokens - Request and cost scores
425456
In the context of multiple 4me authentication tokens, request and cost scores are essential metrics used to determine the priority of tokens when making API requests. These scores help prioritize tokens efficiently by considering two critical factors.
426457

427458
**Request Score:**
@@ -441,18 +472,9 @@ client.ConfigureAuthenticationTokenWeight(requestWeight: 0.5, costWeight: 0.5);
441472

442473
To learn more about GraphQL Service Quotas, refer to the [Service Quota](https://developer.4me.com/graphql/#service-quotas-1) section, and for information on Rate Limiting, explore the [Rate Limiting](https://developer.4me.com/v1/#rate-limiting) section in the 4me developer documentation.
443474

444-
### Multiple accounts
445-
When connecting to multiple accounts within a single application, it is recommended to use multiple `Sdk4meClient` instances.
446-
While the `AccountID` can be set via the `Sdk4meClient.AccountID`, using the same client instance to execute multiple requests simultaneously across different accounts can lead to potential issues and unexpected behavior.
447-
To ensure effective management of multiple accounts, it's advisable to utilize a dictionary structure. This allows you to map each account to its respective `Sdk4meClient` instance.
448-
449-
```csharp
450-
Dictionary<string, Sdk4meClient> clients = new()
451-
{
452-
{ "account-1", new Sdk4meClient(new AuthenticationTokenCollection() { ... }, "account-1", EnvironmentType.Production, EnvironmentRegion.EU) },
453-
{ "account-2", new Sdk4meClient(new AuthenticationTokenCollection() { ... }, "account-2", EnvironmentType.Production, EnvironmentRegion.EU) },
454-
{ "account-3", new Sdk4meClient(new AuthenticationTokenCollection() { ... }, "account-3", EnvironmentType.Production, EnvironmentRegion.EU) }
455-
};
456-
457-
clients["account-1"].Get(new AccountQuery().Select(AccountField.ID)).Result;
475+
### Trace output
476+
A trace output providing details of a GraphQL query request and response time.
477+
```json
478+
{"id":"b1685ff0-6356-49eb-ab58-6ef32b9b4a61","method":"POST","uri":"https://graphql.4me.qa/","content":"{\"query\":\"query{node(id: \\\"KG1jIx\\\") {... on Person {id}}}\"}","account_id":"account-name"}
479+
{"id":"b1685ff0-6356-49eb-ab58-6ef32b9b4a61","response_time_in_ms":44}
458480
```

Scr/Sdk4me.GraphQL.Tests/Tests/ServiceInstanceTest.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ public void Get()
1818
.SelectParentServiceInstances(new ServiceInstanceQuery())
1919
.SelectRemarksAttachments(new AttachmentQuery())
2020
.SelectServiceLevelAgreements(new ServiceLevelAgreementQuery())
21-
.SelectTranslations(new TranslationQuery())
21+
.SelectTranslations(new TranslationQuery()
22+
.SelectOwner(new ServiceQuery()
23+
.Select(ServiceField.ID))
24+
.SelectOwner(new ServiceInstanceQuery()
25+
.Select(ServiceInstanceField.ID)))
2226
).Result;
2327

2428
Assert.IsNotNull(serviceInstances);

Scr/Sdk4me.GraphQL/Entities/Tag.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ public class Tag : Node
2323
[JsonProperty("name"), Sdk4meField(true)]
2424
public string? Name { get; internal set; }
2525

26+
/// <summary>
27+
/// Number of requests the tag is applied to.
28+
/// </summary>
29+
[JsonProperty("requestCount")]
30+
public long? RequestCount { get; internal set; }
31+
2632
/// <summary>
2733
/// The date and time of the last update of the record. If the record has no updates it contains the <c>createdAt</c> value.
2834
/// </summary>

Scr/Sdk4me.GraphQL/Enumerators/FieldEnumerators.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9275,6 +9275,11 @@ public enum TagField
92759275
[EnumMember(Value = "name")]
92769276
Name,
92779277
/// <summary>
9278+
/// The request count field.
9279+
/// </summary>
9280+
[EnumMember(Value = "requestCount")]
9281+
RequestCount,
9282+
/// <summary>
92789283
/// The updated at field.
92799284
/// </summary>
92809285
[EnumMember(Value = "updatedAt")]

0 commit comments

Comments
 (0)