Skip to content
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

Hub sites #63

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,10 @@ Interested in [SharePoint User Profile REST reference](https://docs.microsoft.co

### Hub Sites

Interested in [Hub Sites REST API](https://docs.microsoft.com/en-us/sharepoint/dev/features/hub-site/hub-site-rest-api)? [Open an issue](https://github.com/microsoftgraph/msgraph-sdk-dotnet-contrib/issues/new)
The following operations allow for retrieving HubSites.

| Operation | Request Builder | Method | Released version |
|------------------|-----------------|--------------------------|------------------|
| GetHubSites | `.Hubs` | GetAsync | 4.54.5 |


50 changes: 50 additions & 0 deletions src/Models/Hub.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace Graph.Community
{
public class Hub
{
/// <summary>
/// Identifies the hub site.
/// </summary>
public string Id { get; set; }

/// <summary>
/// The display name of the hub site.
/// </summary>
public string Title { get; set; }

/// <summary>
/// ID of the hub parent site.
/// </summary>
public string SiteId { get; set; }

/// <summary>
/// The tenant instance ID in which the hub site is located. Use empty GUID for the default tenant instance.
/// </summary>
public string TenantInstanceId { get; set; }

/// <summary>
/// URL of the hub parent site.
/// </summary>
public string SiteUrl { get; set; }

/// <summary>
/// The URL of a logo to use in the hub site navigation.
/// </summary>
public string LogoUrl { get; set; }

/// <summary>
/// A description of the hub site.
/// </summary>
public string Description { get; set; }

/// <summary>
/// List of security groups with access to join the hub site. Null if everyone has permission.
/// </summary>
public string Targets { get; set; }

public bool HideNameInNavigation { get; set; }
public string ParentHubSiteId { get; set; }
public bool RequiresJoinApproval { get; set; }
public string SiteDesignId { get; set; }
}
}
7 changes: 1 addition & 6 deletions src/Models/RegionalSettings.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Graph;

namespace Graph.Community.Models
namespace Graph.Community.Models
{
public class RegionalSettings
{
Expand Down
8 changes: 8 additions & 0 deletions src/Requests/Hubs/HubCollectionPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Microsoft.Graph;

namespace Graph.Community
{
public class HubCollectionPage: CollectionPage<Hub>, IHubCollectionPage
{
}
}
38 changes: 38 additions & 0 deletions src/Requests/Hubs/HubCollectionRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Graph;

namespace Graph.Community
{
public class HubCollectionRequest : BaseSharePointAPIRequest, IHubCollectionRequest
{
public HubCollectionRequest(
string requestUrl,
IBaseClient client,
IEnumerable<Option> options)
: base("SitePages", requestUrl, client, options)
{
this.Headers.Add(new HeaderOption(SharePointAPIRequestConstants.Headers.AcceptHeaderName, SharePointAPIRequestConstants.Headers.AcceptHeaderValue));
this.Headers.Add(new HeaderOption(SharePointAPIRequestConstants.Headers.ODataVersionHeaderName, SharePointAPIRequestConstants.Headers.ODataVersionHeaderValue));
}

public Task<IHubCollectionPage> GetAsync()
{
return this.GetAsync(CancellationToken.None);
}

public async Task<IHubCollectionPage> GetAsync(CancellationToken cancellationToken)
{
this.ContentType = "application/json";
var response = await this.SendAsync<SharePointAPICollectionResponse<IHubCollectionPage>>(null, cancellationToken).ConfigureAwait(false);

if (response?.Value?.CurrentPage != null)
{
return response.Value;
}

return null;
}
}
}
58 changes: 58 additions & 0 deletions src/Requests/Hubs/HubCollectionRequestBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using Microsoft.Graph;

namespace Graph.Community
{
public class HubCollectionRequestBuilder : BaseRequestBuilder, IHubCollectionRequestBuilder
{
private readonly IEnumerable<Option> options;

public HubCollectionRequestBuilder(
string requestUrl,
IBaseClient client,
IEnumerable<Option> options = null)
: base(requestUrl, client)
{
this.options = options;
}

/// <summary>
/// Builds the request.
/// </summary>
/// <returns>The built request.</returns>
public IHubCollectionRequest Request()
{
return this.Request(options);
}

/// <summary>
/// Builds the request.
/// </summary>
/// <param name="options">The query and header options for the request.</param>
/// <returns>The built request.</returns>
public IHubCollectionRequest Request(IEnumerable<Option> options)
{
return new HubCollectionRequest(this.AppendSegmentToRequestUrl("HubSites"), this.Client, options);
}

/// <summary>
/// Gets an <see cref="IHubRequestBuilder"/> for the specified Hub
/// </summary>
/// <param name="id">The ID for the Hub</param>
/// <returns>The <see cref="IHubRequestBuilder"/>.</returns>
public IHubRequestBuilder this[string id]
{
get
{
if (string.IsNullOrEmpty(id))
{
throw new ArgumentNullException(nameof(id));
}

List<QueryOption> options = [new("hubSiteId", $"'{id}'")];
return new HubRequestBuilder(this.AppendSegmentToRequestUrl("HubSites/GetById"), this.Client, options);
}
}
}
}
32 changes: 32 additions & 0 deletions src/Requests/Hubs/HubRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Graph;

namespace Graph.Community
{
public class HubRequest:BaseSharePointAPIRequest, IHubRequest
{
public HubRequest(
string requestUrl,
IBaseClient client,
IEnumerable<Option> options)
: base("Hub", requestUrl, client, options)
{
this.Headers.Add(new HeaderOption(SharePointAPIRequestConstants.Headers.AcceptHeaderName, SharePointAPIRequestConstants.Headers.AcceptHeaderValue));
this.Headers.Add(new HeaderOption(SharePointAPIRequestConstants.Headers.ODataVersionHeaderName, SharePointAPIRequestConstants.Headers.ODataVersionHeaderValue));
}

public Task<Hub> GetAsync()
{
return this.GetAsync(CancellationToken.None);
}

public async Task<Hub> GetAsync(CancellationToken cancellationToken)
{
this.ContentType = "application/json";
var entity = await this.SendAsync<Hub>(null, cancellationToken).ConfigureAwait(false);
return entity;
}
}
}
38 changes: 38 additions & 0 deletions src/Requests/Hubs/HubRequestBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using Microsoft.Graph;

namespace Graph.Community
{
public class HubRequestBuilder : BaseRequestBuilder,IHubRequestBuilder
{
private readonly IEnumerable<Option> options;

public HubRequestBuilder(
string requestUrl,
IBaseClient client,
IEnumerable<Option> options = null)
: base(requestUrl, client)
{
this.options = options;
}

/// <summary>
/// Builds the request.
/// </summary>
/// <returns>The built request.</returns>
public IHubRequest Request()
{
return this.Request(this.options);
}

/// <summary>
/// Builds the request.
/// </summary>
/// <param name="options">The query and header options for the request.</param>
/// <returns>The built request.</returns>
public IHubRequest Request(IEnumerable<Option> options)
{
return new HubRequest(this.RequestUrl, this.Client, options);
}
}
}
9 changes: 9 additions & 0 deletions src/Requests/Hubs/IHubCollectionPage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Microsoft.Graph;

namespace Graph.Community
{
[InterfaceConverter(typeof(InterfaceConverter<HubCollectionPage>))]
public interface IHubCollectionPage : ICollectionPage<Hub>
{
}
}
12 changes: 12 additions & 0 deletions src/Requests/Hubs/IHubCollectionRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Graph;

namespace Graph.Community
{
public interface IHubCollectionRequest : IBaseRequest
{
Task<IHubCollectionPage> GetAsync();
Task<IHubCollectionPage> GetAsync(CancellationToken cancellationToken);
}
}
28 changes: 28 additions & 0 deletions src/Requests/Hubs/IHubCollectionRequestBuilder .cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;
using Microsoft.Graph;

namespace Graph.Community
{
public interface IHubCollectionRequestBuilder : IBaseRequestBuilder
{
/// <summary>
/// Builds the request.
/// </summary>
/// <returns>The built request.</returns>
IHubCollectionRequest Request();

/// <summary>
/// Builds the request.
/// </summary>
/// <param name="options">The query and header options for the request.</param>
/// <returns>The built request.</returns>
IHubCollectionRequest Request(IEnumerable<Option> options);

/// <summary>
/// Gets a <see cref="IHubRequestBuilder"/> for the specified Hub.
/// </summary>
/// <param name="id">The ID for the Hub.</param>
/// <returns>The <see cref="IHubRequestBuilder"/>.</returns>
IHubRequestBuilder this[string id] { get; }
}
}
12 changes: 12 additions & 0 deletions src/Requests/Hubs/IHubRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Threading.Tasks;
using System.Threading;
using Microsoft.Graph;

namespace Graph.Community
{
public interface IHubRequest : IBaseRequest
{
Task<Hub> GetAsync();
Task<Hub> GetAsync(CancellationToken cancellationToken);
}
}
21 changes: 21 additions & 0 deletions src/Requests/Hubs/IHubRequestBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;
using Microsoft.Graph;

namespace Graph.Community
{
public interface IHubRequestBuilder : IBaseRequestBuilder
{
/// <summary>
/// Builds the request.
/// </summary>
/// <returns>The built request.</returns>
IHubRequest Request();

/// <summary>
/// Builds the request.
/// </summary>
/// <param name="options">The query and header options for the request.</param>
/// <returns>The built request.</returns>
IHubRequest Request(IEnumerable<Option> options);
}
}
2 changes: 2 additions & 0 deletions src/Requests/ISharePointAPIRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ public interface ISharePointAPIRequestBuilder : IBaseRequestBuilder
ISearchRequestBuilder Search { get; }

ITenantRequestBuilder Tenant { get; }

IHubCollectionRequestBuilder Hubs { get; }
}
}
8 changes: 8 additions & 0 deletions src/Requests/SharePointAPIRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,13 @@ public Graph.Community.ITenantRequestBuilder Tenant
return new Graph.Community.TenantRequestBuilder(this.AppendSegmentToRequestUrl("_api"), this.Client);
}
}

public IHubCollectionRequestBuilder Hubs
{
get
{
return new Graph.Community.HubCollectionRequestBuilder(this.AppendSegmentToRequestUrl("_api"), this.Client);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public interface ISiteDesignCollectionRequestBuilder : IBaseRequestBuilder
/// Gets a <see cref="ISiteDesignCollectionRequestBuilder"/> for the specified Site Design.
/// </summary>
/// <param name="id">The ID for the Site Design.</param>
/// <returns>The <see cref="ISiteDesignCollectionRequestBuilder"/>.</returns>
/// <returns>The <see cref="ISiteDesignRequestBuilder"/>.</returns>
ISiteDesignRequestBuilder this[string id] { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Microsoft.Graph;

Expand Down Expand Up @@ -38,10 +38,10 @@ public ISiteDesignCollectionRequest Request(IEnumerable<Option> options)
}

/// <summary>
/// Gets an <see cref="ISiteDesignCollectionRequestBuilder"/> for the specified SiteDesign.
/// Gets an <see cref="ISiteDesignRequestBuilder"/> for the specified SiteDesign.
/// </summary>
/// <param name="id">The ID for the SiteDesign.</param>
/// <returns>The <see cref="ISiteDesignCollectionRequestBuilder"/>.</returns>
/// <returns>The <see cref="ISiteDesignRequestBuilder"/>.</returns>
public ISiteDesignRequestBuilder this[string id]
{
get
Expand Down
Loading
Loading