public void Can_Populate_Template_WithQuery() { UriTemplate template = new UriTemplate( "api/{controller}/{action}/{id?}/properties?propertyIds={propertyGroupIds}&diddly={dee?}&foo=bar" ); Uri generatedUri = template.Populate( baseUri: new Uri("http://test-host/"), templateParameters: new Dictionary <string, string> { { "controller", "organizations" }, { "action", "distinct" }, { "propertyGroupIds", "System.OrganizationCommercial;EnterpriseMobility.OrganizationAirwatch" } } ); Assert.Equal( "http://test-host/api/organizations/distinct/properties?propertyIds=System.OrganizationCommercial%3BEnterpriseMobility.OrganizationAirwatch&foo=bar", generatedUri.AbsoluteUri ); }
/// <summary> /// Open a WebSocket connection using the <see cref="K8sChannelProtocol.V1"/> sub-protocol. /// </summary> /// <param name="client"> /// The Kubernetes API client. /// </param> /// <param name="targetUri"> /// The template used to generate the target URI. /// </param> /// <param name="templateParameters"> /// A <see cref="Dictionary{TKey, TValue}"/> containing the template parameters. /// </param> /// <param name="cancellationToken"> /// An optional cancellation token that can be used to cancel the request. /// </param> /// <returns> /// The configured <see cref="WebSocket"/>. /// </returns> public static Task <WebSocket> ConnectWebSocket(this KubeApiClient client, UriTemplate targetUri, Dictionary <string, string> templateParameters, CancellationToken cancellationToken = default) { if (client == null) { throw new ArgumentNullException(nameof(client)); } if (targetUri == null) { throw new ArgumentNullException(nameof(targetUri)); } if (templateParameters == null) { throw new ArgumentNullException(nameof(templateParameters)); } return(client.ConnectWebSocket( targetUri.Populate(client.ApiEndPoint, templateParameters), cancellationToken )); }