diff --git a/README.md b/README.md index 0102678b3f5..541cd21522b 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -# Microsoft Graph SDK for C# +# Microsoft Graph .NET Client Library -Integrate the [Microsoft Graph API](https://graph.microsoft.io) into your C# +Integrate the [Microsoft Graph API](https://graph.microsoft.io) into your .NET project! -The Microsoft Graph SDK is built as a Portable Class Library and targets the -following frameworks: +The Microsoft Graph .NET Client Library is built as a Portable Class Library targeting profile 111. +This targets the following frameworks: -* .NET 4.5.1 +* .NET 4.5 * .NET for Windows Store apps * Windows Phone 8.1 and higher ## Installation via NuGet -To install the Graph SDK via NuGet: +To install the client library via NuGet: * Search for `Microsoft.Graph` in the NuGet Library, or * Type `Install-Package Microsoft.Graph` into the Package Manager Console. @@ -22,94 +22,63 @@ To install the Graph SDK via NuGet: ### 1. Register your application Register your application to use Microsoft Graph API using one of the following -supported authentication providers: +supported authentication portals: * [Microsoft Application Registration Portal](https://apps.dev.microsoft.com): Register a new application that works with Microsoft Account and/or - organizational accounts using the Azure unified authentication end point. + organizational accounts using the unified V2 Authentication Endpoint. * [Microsoft Azure Active Directory](https://manage.windowsazure.com): Register a new application in your tenant's Active Directory to support work or school users for your tenant or multiple tenants. + +### 2. Authenticate for the Microsoft Graph service -### 2. Setting your application id and scopes +The Microsoft Graph .NET Client Library does not include any default authentication implementations. +Instead, the user will want to authenticate with the library of their choice, or against the OAuth +endpoint directly, and built-in **DelegateAuthenticationProvider** class to authenticate each request. +For more information on `DelegateAuthenticationProvider`, see the [library overview](docs/overview) -Before being granted access to Microsoft Graph APIs your application requests -consent from the user for the aspects of Microsoft Graph it will be using. These -are defined using authorization scopes. Your application can either ask for all -required permissions initially, or can request essential scopes and then request -additional scopes as necessary. +The recommended library for authenticating against AAD is [ADAL](https://github.com/AzureAD/azure-activedirectory-library-for-dotnet). -For more information on available scopes, see [Authentication scopes](https://dev.onedrive.com/auth/msa_oauth.htm#authentication-scopes). +For an example of authenticating a UWP app using the V2 Authentication Endpoint, see the [Microsoft Graph UWP Connect Library](https://github.com/ginach/Microsoft-Graph-UWP-Connect-Library). -### 3. Create a Microsoft Graph Client object with an authentication provider +### 3. Create a Microsoft Graph client object with an authentication provider -An instance of the **GraphServicesClient** class handles building requests, +An instance of the **GraphServiceClient** class handles building requests, sending them to Microsoft Graph API, and processing the responses. To create a new instance of this class, you need to provide an instance of -IAuthenticationProvider which can authenticate requests to Microsoft Graph. +`IAuthenticationProvider` which can authenticate requests to Microsoft Graph. -For consumer and converged scenarios, you can use the OAuth2AuthProvider supplied -by the **Microsoft.Graph.OAuth** NuGet package. - -```csharp -var scopes = new string[] { - "https://graph.microsoft.com/files.readwrite", - "https://graph.microsoft.com/users.read", - "https://graph.microsoft.com/mail.read" -}; -var authProvider = new Microsoft.Graph.OAuth2AuthProvider("app_id", scopes) -var graphClient = new Microsoft.Graph.GraphServicesClient("https://graph.microsoft.com", authProvider); -``` - -Before using the newly created **graphCliet** object, you need to have the user -login and consent to the requested scopes. You initiate the login flow by calling -**LoginAsync()** on the **OAuth2AuthProvider** instance. - -```csharp -await authProvider.LoginAsync(); -``` - -For more information on using the OAuth2AuthProvider, see -[Using the OAuth2 Authentication Provider](docs/oauth2authprovider.md). - -For enterprise and advanced scenarios, you can use ADAL or another authentication -library and built-in **DelegateAuthProvider** class to authenticate each request. For an -example, see -[more information about using ADAL with Microsoft Graph SDK](docs/UsingAdalWithGraphSDK.md). +For more information on initializing a client instance, see the [library overview](docs/overview) ### 4. Make requests to the graph -Once you have completed authentication and have a GraphServicesClient, you can +Once you have completed authentication and have a GraphServiceClient, you can begin to make calls to the service. The requests in the SDK follow the format of the Microsoft Graph API's RESTful syntax. -For example, to retrieve a user's OneDrive: +For example, to retrieve a user's default drive: ```csharp var drive = await graphClient.Me.Drive.Request().GetAsync(); ``` `GetAsync` will return a `Drive` object on success and throw a -`GraphException` on error. +`ServiceException` on error. -To get the current user's root folder of their OneDrive: +To get the current user's root folder of their default drive: ```csharp var rootItem = await graphClient.Me.Drive.Root.Request().GetAsync(); ``` `GetAsync` will return a `DriveItem` object on success and throw a -`GraphException` on error. +`ServiceException` on error. For a general overview of how the SDK is designed, see [overview](docs/overview.md). The following sample applications are also available: -* [OneDrive API Browser](samples/OneDriveApiBrowser) - Windows Forms app -* [OneDrive Photo Browser](samples/OneDrivePhotoBrowser) - Windows Universal app - -To run the OneDrivePhotoBrowser sample app your machine will need to be -configured for [UWP app development](https://msdn.microsoft.com/en-us/library/windows/apps/dn609832.aspx) -and the project must be associated with the Windows Store. +* [Microsoft Graph UWP Connect Library](https://github.com/ginach/Microsoft-Graph-UWP-Connect-Library) - Windows Universal app ## Documentation and resources @@ -122,13 +91,13 @@ and the project must be associated with the Windows Store. ## Issues -To view or log issues, see [issues](https://github.com/OneDrive/onedrive-sdk-csharp/issues). +To view or log issues, see [issues](https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues). ## Other resources -* NuGet Package: [https://www.nuget.org/packages/Microsoft.OneDriveSDK](https://www.nuget.org/packages/Microsoft.OneDriveSDK) +* NuGet Package: [https://www.nuget.org/packages/Microsoft.Graph](https://www.nuget.org/packages/Microsoft.Graph) ## License -[License](LICENSE.txt) +Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT [license](LICENSE.txt) diff --git a/build/35MSSharedLib1024.snk b/build/35MSSharedLib1024.snk new file mode 100644 index 00000000000..695f1b38774 Binary files /dev/null and b/build/35MSSharedLib1024.snk differ diff --git a/common/Microsoft.Graph.nuspec b/common/Microsoft.Graph.nuspec index 1e9617a0a43..e3e6befa4fe 100644 --- a/common/Microsoft.Graph.nuspec +++ b/common/Microsoft.Graph.nuspec @@ -3,24 +3,24 @@ Microsoft.Graph 1.0.0 - Microsoft Graph .NET SDK + Microsoft Graph Client Library Microsoft Microsoft true - Integrate the Microsoft Graph API into your .NET app! - Copyright 2016 Microsoft Corporation - https://github.com/microsoftgraph/sdk-dotnet - http://msdn.microsoft.com/en-US/cc300389 - microsoft graph o365 outlook exchange sharepoint onedrive files cloud storage windowsphone windowsstore metro xaml html + Microsoft Graph Client Library allows you to call Office 365, Azure AD and other Microsoft services through a single unified developer experience. + This package includes the client libraries for connecting your app to the Microsoft Graph. Microsoft Graph enables your app to interact with data entities and their relationships from many Microsoft cloud services with a unified developer experience. Learn more about Microsoft Graph at http://graph.microsoft.io. + Copyright (c) Microsoft Corporation + https://graph.microsoft.io + http://aka.ms/devservicesagreement + Microsoft Office365 Graph GraphServiceClient Outlook OneDrive AzureAD GraphAPI Productivity SharePoint SDK - + - - + - \ No newline at end of file + diff --git a/docs/collections.md b/docs/collections.md new file mode 100644 index 00000000000..03cc2d92ca8 --- /dev/null +++ b/docs/collections.md @@ -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` implementation on success and throws a `ServiceException` on error. For the groups collection, the type returned is `IGraphServiceGroupsCollectionPage`, which inherits `ICollectionPage`. + +`IGraphServiceGroupsCollectionPage` contains three properties: + +|Name |Description | +|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| +|**CurrentPage** |An `IList`. | +|**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` 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 { "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(); +``` \ No newline at end of file diff --git a/docs/contributions.md b/docs/contributions.md new file mode 100644 index 00000000000..bb9abd52693 --- /dev/null +++ b/docs/contributions.md @@ -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. \ No newline at end of file diff --git a/docs/errors.md b/docs/errors.md new file mode 100644 index 00000000000..7f7e4789065 --- /dev/null +++ b/docs/errors.md @@ -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). \ No newline at end of file diff --git a/docs/overview.md b/docs/overview.md new file mode 100644 index 00000000000..0ae4f997783 --- /dev/null +++ b/docs/overview.md @@ -0,0 +1,112 @@ +Microsoft Graph .NET Client Library Overview +===== + +The Microsoft Graph .NET Client Library is made up of 6 major components: + +* A client object +* An authentication provider +* An HTTP provider + serializer +* Request builder objects +* Request objects +* Property bag object model classes for serialization and deserialization + +The library is designed to be highly extensible. This overview covers basic scenarios but many of the individual components can be replaced with custom implementations. + +## GraphServiceClient + +To begin making requests with the library, you will need to initialize a **GraphServiceClient** instance for building and sending requests. + +### GraphServiceClientConstructor + +| Parameter | Required? | Default vaule | +|:-----------------------------------------------|:---------------|:-------------------------------------------------| +|`string` baseUrl | No | https://graph.microsoft.com/currentServiceVersion| +|`IAuthenticationProvider` authenticationProvider| Yes | n/a | +|`IHttpProvider` httpProvider | No | `new HttpProvider(new Serializer())` | + +## IAuthenticationProvider + +The authentication provider is responsible for authenticating requests before sending them to the service. The Microsoft Graph .NET Client Library doesn't implement any authentication by default. Instead, you will need to retrieve access tokens for the service via the authentication library of their choice or by coding against one of the authentication endpoints directly. Please [read here](https://graph.microsoft.io/en-us/docs/authorization/app_authorization) for more details about authenticating the Microsoft Graph service. + +### DelegateAuthenticationProvider + +The `DelegateAuthenticationProvider` is an implementation of `IAuthenticationProvider` that accepts a delegate to call during `AuthenticateRequestAsync`. This is the simplest way to append a retrieved access token to a request message: + +```csharp + var graphserviceClient = new GraphServiceClient( + new DelegateAuthenticationProvider( + (requestMessage) => + { + requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken); + + return Task.FromResult(0); + })); +``` + + +## Resource model + +Microsoft Graph service resource are represented by property bag model classes of the same name in the client library. For example, the [user resource](https://graph.microsoft.io/en-us/docs/api-reference/v1.0/resources/user) is represented by the [user class](../src/Microsoft.Graph/Models/Generated/User.cs) in the client library. Each of these model classes contain properties that represent the properties of the resources they represent. + +These classes are used for serializing and deserializing the resources in requests to the service. They do not contain any logic to issue requests. + +The resource modle classes are generated based on the $metadata description of the service. + +## Requests + +To make requests against the service, you'll need to build a request using the request builders off the client. The request builders are responsible for building the request URL while the `Request()` method off a request builder will build the request object. The request builder patterns are intended to mirror the REST API pattern. + +**Note:** Request and request builder classes are generated based on the $metadata description of the service. Interfaces are provided for each of these classes to enable easy unit testing around the logic contained in the classes. Since these interfaces are also generated, their signatures are subject to change without being considered a breaking change in the library. Anybody consuming these interfaces should be prepared for the class names or interface definitions to change between library versions. + +### 1. Request builders + +You get the first request builder from the `GraphServiceClient` object. For example, to get a request builder for the /me navigation you call: + +|Task | SDK | URL | +|:----------|:----------------------:|:-------------------------------| +|Get me | graphServiceClient.Me | GET graph.microsoft.com/v1.0/me| + +The call will return an `IUserRequestBuilder` object. From Me you can continue to chain the request builders. + +The [Microsoft Graph service documentation](https://graph.microsoft.io/en-us/docs) has more details about the full functionality of the API. + + +### 2. Request calls + +After you build the request you call the `Request` method on the request builder. This will construct the request object needed to make calls against the service. + +For /me/calendar you call: + +```csharp +var calendarRequest = graphServiceClient + .Me + .Calendar + .Request(); +``` + +All request builders have a `Request` method that can generate a request object. Request objects may have different methods on them depending on the type of request. To get /me/calendar you call: + +```csharp +var calendar = await graphServiceClient + .Me + .Calendar + .Request() + .GetAsync(); +``` + +Any errors while building or sending a request will bubble up as a `ServiceException`. See [errors](/docs/errors.md) on for more information on errors. + +## Query options + +If you only want to retrieve certain properties of a resource you can select them. Here's how to get only the ID of the me object: + +```csharp +var user = await graphServiceClient + .Me + .Select("id") + .GetAsync(); +``` + +All properties other than `Id` will be null on the returned user object. + +Expand, Skip, Top, OrderBy, and Filter are also supported via the client library when supported by the Microsoft Graph service for the request type. diff --git a/src/Microsoft.Graph/Authentication/DelegateAuthenticationProvider.cs b/src/Microsoft.Graph/Authentication/DelegateAuthenticationProvider.cs index 9fe5b500e01..85ea441dede 100644 --- a/src/Microsoft.Graph/Authentication/DelegateAuthenticationProvider.cs +++ b/src/Microsoft.Graph/Authentication/DelegateAuthenticationProvider.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2016 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph diff --git a/src/Microsoft.Graph/Authentication/IAuthenticationProvider.cs b/src/Microsoft.Graph/Authentication/IAuthenticationProvider.cs index 0d24f4022e2..122d02118e1 100644 --- a/src/Microsoft.Graph/Authentication/IAuthenticationProvider.cs +++ b/src/Microsoft.Graph/Authentication/IAuthenticationProvider.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2016 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph diff --git a/src/Microsoft.Graph/Constants.cs b/src/Microsoft.Graph/Constants.cs index 798ca2c3f30..9273f3cc036 100644 --- a/src/Microsoft.Graph/Constants.cs +++ b/src/Microsoft.Graph/Constants.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2016 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph @@ -28,11 +10,11 @@ public static class Headers { public const string Bearer = "Bearer"; - public const string SdkVersionHeaderName = "X-ClientService-ClientTag"; + public const string SdkVersionHeaderName = "SdkVersion"; public const string FormUrlEncodedContentType = "application/x-www-form-urlencoded"; - public const string SdkVersionHeaderValue = "SDK-Version=CSharp-v{0}"; + public const string SdkVersionHeaderValue = "graph-dotnet-{0}.{1}.{2}"; public const string ThrowSiteHeaderName = "X-ThrowSite"; } diff --git a/src/Microsoft.Graph/Enums/AccountType.cs b/src/Microsoft.Graph/Enums/AccountType.cs index fea6300815f..16cbca99501 100644 --- a/src/Microsoft.Graph/Enums/AccountType.cs +++ b/src/Microsoft.Graph/Enums/AccountType.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2016 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph diff --git a/src/Microsoft.Graph/Enums/ClientType.cs b/src/Microsoft.Graph/Enums/ClientType.cs index f15dae8d956..daf93b626d5 100644 --- a/src/Microsoft.Graph/Enums/ClientType.cs +++ b/src/Microsoft.Graph/Enums/ClientType.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2015 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.OneDrive.Sdk diff --git a/src/Microsoft.Graph/Enums/GraphErrorCode.cs b/src/Microsoft.Graph/Enums/GraphErrorCode.cs index 5e01309871a..c25ae1dfce2 100644 --- a/src/Microsoft.Graph/Enums/GraphErrorCode.cs +++ b/src/Microsoft.Graph/Enums/GraphErrorCode.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2016 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph diff --git a/src/Microsoft.Graph/Exceptions/Error.cs b/src/Microsoft.Graph/Exceptions/Error.cs index 4b85f9326af..3f5826cb34f 100644 --- a/src/Microsoft.Graph/Exceptions/Error.cs +++ b/src/Microsoft.Graph/Exceptions/Error.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2016 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph @@ -43,7 +25,7 @@ public class Error [DataMember(Name = "throwSite", IsRequired = false, EmitDefaultValue = false)] public string ThrowSite { get; set; } - [JsonExtensionData] + [JsonExtensionData(ReadData = true)] public IDictionary AdditionalData { get; set; } public override string ToString() diff --git a/src/Microsoft.Graph/Exceptions/ErrorResponse.cs b/src/Microsoft.Graph/Exceptions/ErrorResponse.cs index 5a5289a94e6..b0c77712850 100644 --- a/src/Microsoft.Graph/Exceptions/ErrorResponse.cs +++ b/src/Microsoft.Graph/Exceptions/ErrorResponse.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2016 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph @@ -32,7 +14,7 @@ public class ErrorResponse [DataMember(Name = "error")] public Error Error { get; set; } - [JsonExtensionData] + [JsonExtensionData(ReadData = true)] public IDictionary AdditionalData { get; set; } } } diff --git a/src/Microsoft.Graph/Exceptions/ServiceException.cs b/src/Microsoft.Graph/Exceptions/ServiceException.cs index e3256d982eb..e6d6db39f66 100644 --- a/src/Microsoft.Graph/Exceptions/ServiceException.cs +++ b/src/Microsoft.Graph/Exceptions/ServiceException.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2016 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph diff --git a/src/Microsoft.Graph/Helpers/StringHelper.cs b/src/Microsoft.Graph/Helpers/StringHelper.cs new file mode 100644 index 00000000000..69b8b88b22c --- /dev/null +++ b/src/Microsoft.Graph/Helpers/StringHelper.cs @@ -0,0 +1,45 @@ +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. +// ------------------------------------------------------------------------------ + +namespace Microsoft.Graph +{ + using System.Linq; + + public static class StringHelper + { + /// + /// Converts the type string to title case. + /// + /// The type string. + /// The converted string. + public static string ConvertTypeToTitleCase(string typeString) + { + if (!string.IsNullOrEmpty(typeString)) + { + var stringSegments = typeString.Split('.').Select( + segment => string.Concat(segment.Substring(0, 1).ToUpperInvariant(), segment.Substring(1))); + return string.Join(".", stringSegments); + } + + return typeString; + } + + /// + /// Converts the type string to lower camel case. + /// + /// The type string. + /// The converted string. + public static string ConvertTypeToLowerCamelCase(string typeString) + { + if (!string.IsNullOrEmpty(typeString)) + { + var stringSegments = typeString.Split('.').Select( + segment => string.Concat(segment.Substring(0, 1).ToLowerInvariant(), segment.Substring(1))); + return string.Join(".", stringSegments); + } + + return typeString; + } + } +} diff --git a/src/Microsoft.Graph/Helpers/UrlHelper.cs b/src/Microsoft.Graph/Helpers/UrlHelper.cs index acd3f53a883..081afbdd085 100644 --- a/src/Microsoft.Graph/Helpers/UrlHelper.cs +++ b/src/Microsoft.Graph/Helpers/UrlHelper.cs @@ -1,23 +1,5 @@ -// ------------------------------------------------------------------------------ -// Copyright (c) 2016 Microsoft Corporation -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. +// ------------------------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. // ------------------------------------------------------------------------------ namespace Microsoft.Graph diff --git a/src/Microsoft.Graph/Microsoft.Graph.csproj b/src/Microsoft.Graph/Microsoft.Graph.csproj index f9ed73c2707..2c189bc0c21 100644 --- a/src/Microsoft.Graph/Microsoft.Graph.csproj +++ b/src/Microsoft.Graph/Microsoft.Graph.csproj @@ -47,765 +47,51 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - ..\..\packages\Newtonsoft.Json.8.0.2\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.6.0.2\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True -