Skip to content

Commit a68d603

Browse files
committed
add a singular navigation property as a reference
1 parent 6a4554e commit a68d603

12 files changed

+677
-0
lines changed

test/Typewriter.Test/Metadata/MetadataMultipleNamespaces.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@
193193
<Property Name="failureInfo" Type="microsoft.graph2.callRecords.failureInfo" />
194194
<Property Name="media" Type="Collection(microsoft.graph2.callRecords.media)" />
195195
<NavigationProperty Name="refTypes" Type="Collection(graph.entityType3)" />
196+
<NavigationProperty Name="refType" Type="graph.call" /> <!-- No ContainsTarget -->
196197
</EntityType>
197198
<ComplexType Name="endpoint">
198199
<Property Name="userAgent" Type="microsoft.graph2.callRecords.userAgent" />
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
// **NOTE** This file was generated by a tool and any changes will be overwritten.
6+
// <auto-generated/>
7+
8+
// Template Source: Templates\CSharp\Requests\EntityReferenceRequest.cs.tt
9+
10+
namespace Microsoft.Graph
11+
{
12+
using System.Collections.Generic;
13+
using System.Net.Http;
14+
using System.Threading;
15+
16+
/// <summary>
17+
/// The type CallReferenceRequest.
18+
/// </summary>
19+
public partial class CallReferenceRequest : BaseRequest, ICallReferenceRequest
20+
{
21+
/// <summary>
22+
/// Constructs a new CallReferenceRequest.
23+
/// </summary>
24+
/// <param name="requestUrl">The URL for the built request.</param>
25+
/// <param name="client">The <see cref="IBaseClient"/> for handling requests.</param>
26+
/// <param name="options">Query and header option name value pairs for the request.</param>
27+
public CallReferenceRequest(
28+
string requestUrl,
29+
IBaseClient client,
30+
IEnumerable<Option> options)
31+
: base(requestUrl, client, options)
32+
{
33+
}
34+
35+
/// <summary>
36+
/// Deletes the specified Call reference.
37+
/// </summary>
38+
/// <returns>The task to await.</returns>
39+
public System.Threading.Tasks.Task DeleteAsync()
40+
{
41+
return this.DeleteAsync(CancellationToken.None);
42+
}
43+
44+
/// <summary>
45+
/// Deletes the specified Call reference.
46+
/// </summary>
47+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
48+
/// <returns>The task to await.</returns>
49+
public async System.Threading.Tasks.Task DeleteAsync(CancellationToken cancellationToken)
50+
{
51+
this.Method = "DELETE";
52+
await this.SendAsync<Call>(null, cancellationToken).ConfigureAwait(false);
53+
}
54+
55+
/// <summary>
56+
/// Puts the specified Call reference.
57+
/// </summary>
58+
/// <param name="id">The Call reference to update.</param>
59+
/// <returns>The task to await.</returns>
60+
public System.Threading.Tasks.Task PutAsync(string id)
61+
{
62+
return this.PutAsync(id, CancellationToken.None);
63+
}
64+
65+
/// <summary>
66+
/// Puts the specified Call reference.
67+
/// </summary>
68+
/// <param name="id">The Call reference to update.</param>
69+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
70+
/// <returns>The task to await.</returns>
71+
public async System.Threading.Tasks.Task PutAsync(string id, CancellationToken cancellationToken)
72+
{
73+
var baseUrl = this.Client.BaseUrl;
74+
var objectUri = string.Format(@"{0}/users/{1}", baseUrl, id);
75+
var payload = new Newtonsoft.Json.Linq.JObject(
76+
new Newtonsoft.Json.Linq.JProperty("@odata.id", objectUri));
77+
this.Method = "PUT";
78+
this.ContentType = "application/json";
79+
await this.SendAsync(payload.ToString(), cancellationToken).ConfigureAwait(false);
80+
}
81+
}
82+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
// **NOTE** This file was generated by a tool and any changes will be overwritten.
6+
// <auto-generated/>
7+
8+
// Template Source: Templates\CSharp\Requests\EntityReferenceRequestBuilder.cs.tt
9+
10+
namespace Microsoft.Graph
11+
{
12+
using System;
13+
using System.Collections.Generic;
14+
15+
/// <summary>
16+
/// The type CallReferenceRequestBuilder.
17+
/// </summary>
18+
public partial class CallReferenceRequestBuilder : BaseRequestBuilder, ICallReferenceRequestBuilder
19+
{
20+
/// <summary>
21+
/// Constructs a new CallReferenceRequestBuilder.
22+
/// </summary>
23+
/// <param name="requestUrl">The URL for the built request.</param>
24+
/// <param name="client">The <see cref="IBaseClient"/> for handling requests.</param>
25+
public CallReferenceRequestBuilder(
26+
string requestUrl,
27+
IBaseClient client)
28+
: base(requestUrl, client)
29+
{
30+
}
31+
32+
/// <summary>
33+
/// Builds the request.
34+
/// </summary>
35+
/// <returns>The built request.</returns>
36+
public ICallReferenceRequest Request()
37+
{
38+
return this.Request(null);
39+
}
40+
41+
/// <summary>
42+
/// Builds the request.
43+
/// </summary>
44+
/// <param name="options">The query and header options for the request.</param>
45+
/// <returns>The built request.</returns>
46+
public ICallReferenceRequest Request(IEnumerable<Option> options)
47+
{
48+
return new CallReferenceRequest(this.RequestUrl, this.Client, options);
49+
}
50+
}
51+
}
Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
// **NOTE** This file was generated by a tool and any changes will be overwritten.
6+
// <auto-generated/>
7+
8+
// Template Source: Templates\CSharp\Requests\EntityWithReferenceRequest.cs.tt
9+
10+
namespace Microsoft.Graph
11+
{
12+
using System;
13+
using System.Collections.Generic;
14+
using System.IO;
15+
using System.Net.Http;
16+
using System.Threading;
17+
using System.Linq.Expressions;
18+
19+
/// <summary>
20+
/// The type CallWithReferenceRequest.
21+
/// </summary>
22+
public partial class CallWithReferenceRequest : BaseRequest, ICallWithReferenceRequest
23+
{
24+
/// <summary>
25+
/// Constructs a new CallWithReferenceRequest.
26+
/// </summary>
27+
/// <param name="requestUrl">The URL for the built request.</param>
28+
/// <param name="client">The <see cref="IBaseClient"/> for handling requests.</param>
29+
/// <param name="options">Query and header option name value pairs for the request.</param>
30+
public CallWithReferenceRequest(
31+
string requestUrl,
32+
IBaseClient client,
33+
IEnumerable<Option> options)
34+
: base(requestUrl, client, options)
35+
{
36+
}
37+
38+
/// <summary>
39+
/// Gets the specified Call.
40+
/// </summary>
41+
/// <returns>The Call.</returns>
42+
public System.Threading.Tasks.Task<Call> GetAsync()
43+
{
44+
return this.GetAsync(CancellationToken.None);
45+
}
46+
47+
/// <summary>
48+
/// Gets the specified Call.
49+
/// </summary>
50+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
51+
/// <returns>The Call.</returns>
52+
public async System.Threading.Tasks.Task<Call> GetAsync(CancellationToken cancellationToken)
53+
{
54+
this.Method = "GET";
55+
var retrievedEntity = await this.SendAsync<Call>(null, cancellationToken).ConfigureAwait(false);
56+
return retrievedEntity;
57+
}
58+
59+
/// <summary>
60+
/// Creates the specified Call using POST.
61+
/// </summary>
62+
/// <param name="callToCreate">The Call to create.</param>
63+
/// <returns>The created Call.</returns>
64+
public System.Threading.Tasks.Task<Call> CreateAsync(Call callToCreate)
65+
{
66+
return this.CreateAsync(callToCreate, CancellationToken.None);
67+
}
68+
69+
/// <summary>
70+
/// Creates the specified Call using POST.
71+
/// </summary>
72+
/// <param name="callToCreate">The Call to create.</param>
73+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
74+
/// <returns>The created Call.</returns>
75+
public async System.Threading.Tasks.Task<Call> CreateAsync(Call callToCreate, CancellationToken cancellationToken)
76+
{
77+
this.ContentType = "application/json";
78+
this.Method = "POST";
79+
var newEntity = await this.SendAsync<Call>(callToCreate, cancellationToken).ConfigureAwait(false);
80+
return newEntity;
81+
}
82+
83+
/// <summary>
84+
/// Updates the specified Call using PATCH.
85+
/// </summary>
86+
/// <param name="callToUpdate">The Call to update.</param>
87+
/// <returns>The updated Call.</returns>
88+
public System.Threading.Tasks.Task<Call> UpdateAsync(Call callToUpdate)
89+
{
90+
return this.UpdateAsync(callToUpdate, CancellationToken.None);
91+
}
92+
93+
/// <summary>
94+
/// Updates the specified Call using PATCH.
95+
/// </summary>
96+
/// <param name="callToUpdate">The Call to update.</param>
97+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
98+
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
99+
/// <returns>The updated Call.</returns>
100+
public async System.Threading.Tasks.Task<Call> UpdateAsync(Call callToUpdate, CancellationToken cancellationToken)
101+
{
102+
if (callToUpdate.AdditionalData != null)
103+
{
104+
if (callToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
105+
callToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
106+
{
107+
throw new ClientException(
108+
new Error
109+
{
110+
Code = GeneratedErrorConstants.Codes.NotAllowed,
111+
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, callToUpdate.GetType().Name)
112+
});
113+
}
114+
}
115+
if (callToUpdate.AdditionalData != null)
116+
{
117+
if (callToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
118+
callToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
119+
{
120+
throw new ClientException(
121+
new Error
122+
{
123+
Code = GeneratedErrorConstants.Codes.NotAllowed,
124+
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, callToUpdate.GetType().Name)
125+
});
126+
}
127+
}
128+
this.ContentType = "application/json";
129+
this.Method = "PATCH";
130+
var updatedEntity = await this.SendAsync<Call>(callToUpdate, cancellationToken).ConfigureAwait(false);
131+
return updatedEntity;
132+
}
133+
134+
/// <summary>
135+
/// Deletes the specified Call.
136+
/// </summary>
137+
/// <returns>The task to await.</returns>
138+
public System.Threading.Tasks.Task DeleteAsync()
139+
{
140+
return this.DeleteAsync(CancellationToken.None);
141+
}
142+
143+
/// <summary>
144+
/// Deletes the specified Call.
145+
/// </summary>
146+
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
147+
/// <returns>The task to await.</returns>
148+
public async System.Threading.Tasks.Task DeleteAsync(CancellationToken cancellationToken)
149+
{
150+
this.Method = "DELETE";
151+
await this.SendAsync<Call>(null, cancellationToken).ConfigureAwait(false);
152+
}
153+
154+
/// <summary>
155+
/// Adds the specified expand value to the request.
156+
/// </summary>
157+
/// <param name="value">The expand value.</param>
158+
/// <returns>The request object to send.</returns>
159+
public ICallWithReferenceRequest Expand(string value)
160+
{
161+
this.QueryOptions.Add(new QueryOption("$expand", value));
162+
return this;
163+
}
164+
165+
/// <summary>
166+
/// Adds the specified expand value to the request.
167+
/// </summary>
168+
/// <param name="expandExpression">The expression from which to calculate the expand value.</param>
169+
/// <returns>The request object to send.</returns>
170+
public ICallWithReferenceRequest Expand(Expression<Func<Call, object>> expandExpression)
171+
{
172+
if (expandExpression == null)
173+
{
174+
throw new ArgumentNullException(nameof(expandExpression));
175+
}
176+
string error;
177+
string value = ExpressionExtractHelper.ExtractMembers(expandExpression, out error);
178+
if (value == null)
179+
{
180+
throw new ArgumentException(error, nameof(expandExpression));
181+
}
182+
else
183+
{
184+
this.QueryOptions.Add(new QueryOption("$expand", value));
185+
}
186+
return this;
187+
}
188+
189+
/// <summary>
190+
/// Adds the specified select value to the request.
191+
/// </summary>
192+
/// <param name="value">The select value.</param>
193+
/// <returns>The request object to send.</returns>
194+
public ICallWithReferenceRequest Select(string value)
195+
{
196+
this.QueryOptions.Add(new QueryOption("$select", value));
197+
return this;
198+
}
199+
200+
/// <summary>
201+
/// Adds the specified select value to the request.
202+
/// </summary>
203+
/// <param name="selectExpression">The expression from which to calculate the select value.</param>
204+
/// <returns>The request object to send.</returns>
205+
public ICallWithReferenceRequest Select(Expression<Func<Call, object>> selectExpression)
206+
{
207+
if (selectExpression == null)
208+
{
209+
throw new ArgumentNullException(nameof(selectExpression));
210+
}
211+
string error;
212+
string value = ExpressionExtractHelper.ExtractMembers(selectExpression, out error);
213+
if (value == null)
214+
{
215+
throw new ArgumentException(error, nameof(selectExpression));
216+
}
217+
else
218+
{
219+
this.QueryOptions.Add(new QueryOption("$select", value));
220+
}
221+
return this;
222+
}
223+
224+
}
225+
}

0 commit comments

Comments
 (0)