Skip to content

- adds missing navigation properties on composable functions in java #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,37 @@ import com.google.gson.JsonElement;
<# } #>
return request;
}
<#
var m = c as OdcmMethod;
if(m != null && m.IsComposable && m.ReturnType != null && m.ReturnType is OdcmClass) {
foreach(var prop in m.ReturnType.AsOdcmClass().NavigationProperties(true))
{
var propName = prop.Name.ToUpperFirstChar();
var sanitizedProperty = propName.SanitizePropertyName().ToLowerFirstChar();
var propRequestBuilder = prop.TypeRequestBuilder();
if (prop.IsCollection()) {
#>
public <#=prop.ITypeCollectionRequestBuilder()#> <#=sanitizedProperty#>() {
return new <#=prop.TypeCollectionRequestBuilder()#>(getRequestUrlWithAdditionalSegment("<#=prop.Name#>"), getClient(), null);
}

public <#=prop.ITypeRequestBuilder()#> <#=sanitizedProperty#>(final String id) {
return new <#=prop.TypeRequestBuilder()#>(getRequestUrlWithAdditionalSegment("<#=prop.Name#>") + "/" + id, getClient(), null);
}
<#
} else {
#>

/**
* Gets the request builder for <#=prop.TypeName()#>
*
* @return the <#=prop.ITypeRequestBuilder()#> instance
*/
public <#=prop.ITypeRequestBuilder()#> <#=sanitizedProperty#>() {
return new <#=prop.TypeRequestBuilder()#>(getRequestUrlWithAdditionalSegment("<#=prop.Name#>"), getClient(), null);
}
<#
}
}
} #>
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,32 @@ import <#=importNamespace#>.http.IRequestBuilder;
* @return the <#=c.ITypeRequest()#> instance
*/
<#=c.ITypeRequest()#> buildRequest(final java.util.List<? extends <#=importNamespace#>.options.Option> requestOptions);
<#
var m = c as OdcmMethod;
if(m != null && m.IsComposable && m.ReturnType != null && m.ReturnType is OdcmClass) {
foreach(var prop in m.ReturnType.AsOdcmClass().NavigationProperties(true))
{
var propName = prop.Name.ToUpperFirstChar();
var sanitizedName = prop.Name.SanitizePropertyName();
var propRequestBuilder = prop.TypeRequestBuilder();
if (prop.IsCollection()) {
#>

<#=prop.ITypeCollectionRequestBuilder()#> <#=sanitizedName.ToLowerFirstChar()#>();

<#=prop.ITypeRequestBuilder()#> <#=prop.Name#>(final String id);
<#
} else {
#>

/**
* Gets the request builder for <#=prop.TypeName()#>
*
* @return the <#=prop.ITypeRequestBuilder()#> instance
*/
<#=prop.ITypeRequestBuilder()#> <#=sanitizedName.ToLowerFirstChar()#>();
<#
}
}
} #>
}
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@
<Parameter Name="value" Type="graph.identitySet" />
<ReturnType Type="Collection(microsoft.graph2.callRecords.session)" />
</Action>
<Function Name="item" IsBound="true" IsComposable="true">
<Parameter Name="bindparameter" Type="Collection(microsoft.graph2.callRecords.callRecord)" />
<Parameter Name="name" Type="Edm.String" Unicode="false" />
<ReturnType Type="microsoft.graph2.callRecords.callRecord" />
</Function>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
5 changes: 5 additions & 0 deletions test/Typewriter.Test/Metadata/MetadataWithSubNamespaces.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@
<Parameter Name="value" Type="graph.identitySet" />
<ReturnType Type="Collection(microsoft.graph.callRecords.session)" />
</Action>
<Function Name="item" IsBound="true" IsComposable="true">
<Parameter Name="bindparameter" Type="Collection(microsoft.graph.callRecords.callRecord)" />
<Parameter Name="name" Type="Edm.String" Unicode="false" />
<ReturnType Type="microsoft.graph.callRecords.callRecord" />
</Function>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public ICloudCommunicationsCallRecordsCollectionRequest Request(IEnumerable<Opti
/// </summary>
/// <param name="id">The ID for the CloudCommunicationsMicrosoft.Graph2.CallRecords.CallRecord.</param>
/// <returns>The <see cref="Microsoft.Graph2.CallRecords.ICallRecordRequestBuilder"/>.</returns>
[System.Runtime.CompilerServices.IndexerName("ThisItem")]
public Microsoft.Graph2.CallRecords.ICallRecordRequestBuilder this[string id]
{
get
Expand All @@ -60,6 +61,17 @@ public Microsoft.Graph2.CallRecords.ICallRecordRequestBuilder this[string id]
}
}


/// <summary>
/// Gets the request builder for CallRecordItem.
/// </summary>
/// <returns>The <see cref="ICallRecordItemRequestBuilder"/>.</returns>
public ICallRecordItemRequestBuilder Item(
string name = null)
{
return new CallRecordItemRequestBuilder(
this.AppendSegmentToRequestUrl("microsoft.graph2.callRecords.item"),
this.Client,
name);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ public partial interface ICloudCommunicationsCallRecordsCollectionRequestBuilder
/// </summary>
/// <param name="id">The ID for the Microsoft.Graph2.CallRecords.CallRecord.</param>
/// <returns>The <see cref="Microsoft.Graph2.CallRecords.ICallRecordRequestBuilder"/>.</returns>
[System.Runtime.CompilerServices.IndexerName("ThisItem")]
Microsoft.Graph2.CallRecords.ICallRecordRequestBuilder this[string id] { get; }


/// <summary>
/// Gets the request builder for CallRecordItem.
/// </summary>
/// <returns>The <see cref="ICallRecordItemRequestBuilder"/>.</returns>
ICallRecordItemRequestBuilder Item(
string name = null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------

// **NOTE** This file was generated by a tool and any changes will be overwritten.
// <auto-generated/>

// Template Source: Templates\CSharp\Requests\MethodRequest.cs.tt

namespace Microsoft.Graph2.CallRecords
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Threading;

/// <summary>
/// The type CallRecordItemRequest.
/// </summary>
public partial class CallRecordItemRequest : Microsoft.Graph.BaseRequest, ICallRecordItemRequest
{
/// <summary>
/// Constructs a new CallRecordItemRequest.
/// </summary>
public CallRecordItemRequest(
string requestUrl,
Microsoft.Graph.IBaseClient client,
IEnumerable<Microsoft.Graph.Option> options)
: base(requestUrl, client, options)
{
}

/// <summary>
/// Issues the GET request.
/// </summary>
public System.Threading.Tasks.Task<CallRecord> GetAsync()
{
return this.GetAsync(CancellationToken.None);
}

/// <summary>
/// Issues the GET request.
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <returns>The task to await for async call.</returns>
public System.Threading.Tasks.Task<CallRecord> GetAsync(
CancellationToken cancellationToken)
{
this.Method = "GET";
return this.SendAsync<CallRecord>(null, cancellationToken);
}


/// <summary>
/// Issues the PATCH request.
/// </summary>
/// <param name="callrecord">The CallRecord object set with the properties to update.</param>
/// <returns>The task to await for async call.</returns>
public System.Threading.Tasks.Task<CallRecord> PatchAsync(CallRecord callrecord)
{
return this.PatchAsync(callrecord, CancellationToken.None);
}

/// <summary>
/// Issues the PATCH request.
/// </summary>
/// <param name="callrecord">The CallRecord object set with the properties to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <returns>The task to await for async call.</returns>
public System.Threading.Tasks.Task<CallRecord> PatchAsync(CallRecord callrecord,
CancellationToken cancellationToken)
{
this.Method = "PATCH";
return this.SendAsync<CallRecord>(callrecord, cancellationToken);
}

/// <summary>
/// Issues the PUT request.
/// </summary>
/// <param name="callrecord">The CallRecord object to update.</param>
/// <returns>The task to await for async call.</returns>
public System.Threading.Tasks.Task<CallRecord> PutAsync(CallRecord callrecord)
{
return this.PutAsync(callrecord, CancellationToken.None);
}

/// <summary>
/// Issues the PUT request.
/// </summary>
/// <param name="callrecord">The CallRecord object to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <returns>The task to await for async call.</returns>
public System.Threading.Tasks.Task<CallRecord> PutAsync(CallRecord callrecord,
CancellationToken cancellationToken)
{
this.Method = "PUT";
return this.SendAsync<CallRecord>(callrecord, cancellationToken);
}

/// <summary>
/// Adds the specified expand value to the request.
/// </summary>
/// <param name="value">The expand value.</param>
/// <returns>The request object to send.</returns>
public ICallRecordItemRequest Expand(string value)
{
this.QueryOptions.Add(new Microsoft.Graph.QueryOption("$expand", value));
return this;
}

/// <summary>
/// Adds the specified select value to the request.
/// </summary>
/// <param name="value">The select value.</param>
/// <returns>The request object to send.</returns>
public ICallRecordItemRequest Select(string value)
{
this.QueryOptions.Add(new Microsoft.Graph.QueryOption("$select", value));
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------

// **NOTE** This file was generated by a tool and any changes will be overwritten.
// <auto-generated/>

// Template Source: Templates\CSharp\Requests\MethodRequestBuilder.cs.tt

namespace Microsoft.Graph2.CallRecords
{
using System;
using System.Collections.Generic;
using System.IO;

/// <summary>
/// The type CallRecordItemRequestBuilder.
/// </summary>
public partial class CallRecordItemRequestBuilder : Microsoft.Graph.BaseFunctionMethodRequestBuilder<ICallRecordItemRequest>, ICallRecordItemRequestBuilder
{
/// <summary>
/// Constructs a new <see cref="CallRecordItemRequestBuilder"/>.
/// </summary>
/// <param name="requestUrl">The URL for the request.</param>
/// <param name="client">The <see cref="Microsoft.Graph.IBaseClient"/> for handling requests.</param>
/// <param name="name">A name parameter for the OData method call.</param>
public CallRecordItemRequestBuilder(
string requestUrl,
Microsoft.Graph.IBaseClient client,
string name)
: base(requestUrl, client)
{
this.SetParameter("name", name, true);
}

/// <summary>
/// A method used by the base class to construct a request class instance.
/// </summary>
/// <param name="functionUrl">The request URL to </param>
/// <param name="options">The query and header options for the request.</param>
/// <returns>An instance of a specific request class.</returns>
protected override ICallRecordItemRequest CreateRequest(string functionUrl, IEnumerable<Microsoft.Graph.Option> options)
{
var request = new CallRecordItemRequest(functionUrl, this.Client, options);

return request;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,7 @@ public ICallRecordRecipientsCollectionRequestBuilder Recipients
}
}



}
}
Loading