-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,351 changed files
with
35,696 additions
and
42,494 deletions.
There are no files selected for viewing
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
Collections in the Microsoft Graph .NET Client Library | ||
===== | ||
|
||
Whenever a request returns a collection of objects that allow paging or navigation into the collection, the library generates a complex collection page object. | ||
|
||
## Getting a collection | ||
|
||
To retrieve a collection, like the list of groups in the service, you call `GetAsync` on the collection request: | ||
|
||
```csharp | ||
await graphServiceClient | ||
.Groups | ||
.Request() | ||
.GetAsync(); | ||
``` | ||
|
||
`GetAsync` returns an `ICollectionPage<T>` implementation on success and throws a `ServiceException` on error. For the groups collection, the type returned is `IGraphServiceGroupsCollectionPage`, which inherits `ICollectionPage<Item>`. | ||
|
||
`IGraphServiceGroupsCollectionPage` contains three properties: | ||
|
||
|Name |Description | | ||
|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
|**CurrentPage** |An `IList<Item>`. | | ||
|**NextPageRequest** |An `IGraphServiceGroupsCollectionRequest` used to get to the next page of items, if another page exists. This value will be null if there is not a next page.| | ||
|**AdditionData** |An `IDictionary<string, object>` to any additional values returned by the service. In this case, none. | | ||
|
||
## Adding to a collection | ||
|
||
Some collections, like the groups collection, can be changed. To create a group you can call: | ||
|
||
```csharp | ||
var groupToCreate = new Group | ||
{ | ||
GroupTypes = new List<string> { "Unified" }, | ||
DisplayName = "Unified group", | ||
Description = "Best group ever", | ||
... | ||
}; | ||
|
||
var newGroup = await graphServiceClient | ||
.Groups | ||
.Request() | ||
.AddAsync(groupToCreate); | ||
``` | ||
|
||
`AddAsync` returns the created group on success and throws a `ServiceException` on error. | ||
|
||
## Expanding a collection | ||
|
||
To expand a collection, you call `Expand` on the collection request object with the string value of the expand: | ||
|
||
```csharp | ||
var children = await graphServiceClient | ||
.Me | ||
.Drive | ||
.Items[itemId] | ||
.Children | ||
.Request() | ||
.Expand("thumbnails") | ||
.GetAsync(); | ||
``` |
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,28 @@ | ||
Contributing to the Microsoft Graph .NET Client Library | ||
===== | ||
|
||
The Microsoft Graph .NET Client Library is avaliable for all manner of contribution. There are a few different recommended paths to get contributions into the released version of this library. | ||
|
||
**NOTE** A signed a contribution license agreement is required for all contributions and is checked automatically on new pull requests. Please read and sign the agreement https://cla.microsoft.com/ before starting any work for this repository. | ||
|
||
## File issues | ||
|
||
The best way to get started with a contribution is to start a dialog with the owners of the repository. Sometimes features will be under development or out of scope for this library and it's best to check before starting work on contribution. | ||
|
||
## Pull requests | ||
|
||
If you are making documentation changes, feel free to submit a pull request against the **master** branch. All other pull requests should be submitted against the **dev** branch or a specific **feature** branch. The **master** branch is intended to represent the code released in the most-recent Nuget package. | ||
|
||
When a new package is about to be released, changes in **dev** will be merged into **master**. The package will be generated from **master**. | ||
|
||
## Submit pull requests for trivial changes | ||
|
||
If you are making a change that does not affect the interface components and does not affect other downstream callers, feel free to make a pull request against the **dev** branch. | ||
|
||
Revisions of this nature will result in a 0.0.X change of the version number. | ||
|
||
## Submit pull requests for features | ||
|
||
If major functionality is being added it should be submitted against the **dev** branch. If the functionality will require multiple changes or iterations before it is ready for **dev**, feel free to submit pull requests into a dedicated **feature** branch until the whole change is ready. | ||
|
||
Revisions of this nature will result in a 0.X.X change of the version number. |
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,22 @@ | ||
Handling errors in the Microsoft Graph .NET Client Library | ||
===== | ||
|
||
Errors in the Microsoft Graph .NET Client Library behave like errors returned from the Microsoft Graph service. You can read more about them [here](https://graph.microsoft.io/en-us/docs/overview/errors). | ||
|
||
Anytime you make a request against the service there is the potential for an error. In the case of an error, the request will throw a `ServiceException` object with an inner `Error` object that contains the service error details. | ||
|
||
## Checking the error | ||
|
||
There are a few different types of errors that can occur during a network call. These error codes are defined in [GraphErrorCode.cs](../src/Microsoft.Graph/Enums/GraphErrorCode.cs). | ||
|
||
### Checking the error code | ||
You can easily check if an error has a specific code by calling `IsMatch` on the error code value. `IsMatch` is not case sensitive: | ||
|
||
```csharp | ||
if (exception.IsMatch(GraphErrorCode.AccessDenied.ToString()) | ||
{ | ||
// Handle access denied error | ||
} | ||
``` | ||
|
||
Each error object has a `Message` property as well as code. This message is for debugging purposes and is not be meant to be displayed to the user. Common error codes are defined in [GraphErrorCode.cs](../src/Microsoft.Graph/Enums/GraphErrorCode.cs). |
Oops, something went wrong.