Skip to content

Commit 66eed91

Browse files
Alan Quillinsharwell
authored andcommitted
Added method to allow for adding a url to the service catalog
1 parent 92369f3 commit 66eed91

7 files changed

Lines changed: 207 additions & 1 deletion

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace net.openstack.Core.Domain
2+
{
3+
using System;
4+
using System.Diagnostics;
5+
using Newtonsoft.Json;
6+
7+
/// <summary>
8+
/// A personality that a user assumes when performing a specific set of operations. A role
9+
/// includes a set of right and privileges. A user assuming that role inherits those rights
10+
/// and privileges.
11+
/// </summary>
12+
/// <remarks>
13+
/// In OpenStack Identity Service, a token that is issued to a user includes the list of
14+
/// roles that user can assume. Services that are being called by that user determine how
15+
/// they interpret the set of roles a user has and to which operations or resources each
16+
/// role grants access.
17+
/// </remarks>
18+
/// <threadsafety static="true" instance="false"/>
19+
[JsonObject(MemberSerialization.OptIn)]
20+
[DebuggerDisplay("{Id, nq}")]
21+
public class EndpointTemplate
22+
{
23+
/// <summary>
24+
/// Gets the unique identifier for the Endpoint Template.
25+
/// </summary>
26+
[JsonProperty("id")]
27+
public string Id { get; private set; }
28+
29+
public EndpointTemplate(string id)
30+
{
31+
if (id == null)
32+
throw new ArgumentNullException("id");
33+
34+
Id = id;
35+
}
36+
}
37+
}
38+

src/corelib/Providers/Rackspace/CloudIdentityProvider.cs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,111 @@ public virtual IEnumerable<Tenant> ListTenants(CloudIdentity identity)
689689
return response.Data.Tenants;
690690
}
691691

692+
/// <summary>
693+
/// Lists the endpoints in a tenant's service catalog.
694+
/// </summary>
695+
/// <param name="tenantId">The tenant Id. This is obtained from <see cref="Tenant.Id"/></param>
696+
/// <param name="identity">The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.</param>
697+
/// <returns>A collection of <see cref="ExtendedEndpoint"/> objects containing endpoint details.</returns>
698+
/// <exception cref="ArgumentNullException">If <paramref name="tenantId"/> is <see langword="null"/>.</exception>
699+
/// <exception cref="ArgumentException">If <paramref name="tenantId"/> is empty.</exception>
700+
/// <exception cref="NotSupportedException">If the provider does not support the given <paramref name="identity"/> type.</exception>
701+
/// <exception cref="InvalidOperationException">If <paramref name="identity"/> is <see langword="null"/> and no default identity is available for the provider.</exception>
702+
/// <exception cref="ResponseException">If the authentication request failed or the token does not exist.</exception>
703+
/// <seealso href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_listEndpoints__v2.0_tenants__tenantId__OS-KSCATALOG_endpoints_Endpoint_Operations_OS-KSCATALOG.html">List Service Catalog Endpoints (OpenStack Identity Service API v2.0 Reference)</seealso>
704+
public virtual IEnumerable<ExtendedEndpoint> ListServiceCatalogEndpoints(string tenantId, CloudIdentity identity)
705+
{
706+
CheckIdentity(identity);
707+
708+
var response = ExecuteRESTRequest<ListEndpointsResponse>(identity, new Uri(UrlBase, string.Format("/v2.0/tenants/{0}/OS-KSCATALOG/endpoints", tenantId)), HttpMethod.GET);
709+
710+
if (response == null || response.Data == null)
711+
return null;
712+
713+
return response.Data.Endpoints;
714+
}
715+
716+
/// <summary>
717+
/// Lists the endpoints in a tenant's service catalog.
718+
/// </summary>
719+
/// <param name="tenantId">The tenant Id. This is obtained from <see cref="Tenant.Id"/></param>
720+
/// <param name="endpointId">The endpoint Id. This is obtained from <see cref="ExtendedEndpoint.Id"/></param>
721+
/// <param name="identity">The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.</param>
722+
/// <returns>A collection of <see cref="ExtendedEndpoint"/> objects containing endpoint details.</returns>
723+
/// <exception cref="ArgumentNullException">If <paramref name="tenantId"/> is <see langword="null"/>.</exception>
724+
/// <exception cref="ArgumentException">If <paramref name="tenantId"/> is empty.</exception>
725+
/// <exception cref="ArgumentNullException">If <paramref name="endpointId"/> is <see langword="null"/>.</exception>
726+
/// <exception cref="ArgumentException">If <paramref name="endpointId"/> is empty.</exception>
727+
/// <exception cref="NotSupportedException">If the provider does not support the given <paramref name="identity"/> type.</exception>
728+
/// <exception cref="InvalidOperationException">If <paramref name="identity"/> is <see langword="null"/> and no default identity is available for the provider.</exception>
729+
/// <exception cref="ResponseException">If the authentication request failed or the token does not exist.</exception>
730+
/// <seealso href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_getEndpoint__v2.0_tenants__tenantId__OS-KSCATALOG_endpoints__endpointId__Endpoint_Operations_OS-KSCATALOG.html">List Service Catalog Endpoint (OpenStack Identity Service API v2.0 Reference)</seealso>
731+
public virtual ExtendedEndpoint GetServiceCatalogEndpoint(string tenantId, string endpointId, CloudIdentity identity)
732+
{
733+
CheckIdentity(identity);
734+
735+
var response = ExecuteRESTRequest<GetEndpointResponse>(identity, new Uri(UrlBase, string.Format("/v2.0/tenants/{0}/OS-KSCATALOG/endpoints/{1}", tenantId, endpointId)), HttpMethod.GET);
736+
737+
if (response == null || response.Data == null)
738+
return null;
739+
740+
return response.Data.Endpoint;
741+
}
742+
743+
/// <summary>
744+
/// Lists the endpoints in a tenant's service catalog.
745+
/// </summary>
746+
/// <param name="tenantId">The tenant Id. This is obtained from <see cref="Tenant.Id"/></param>
747+
/// <param name="endpointTemplateId">The endpoint template Id. This is obtained from <see cref="EndpointTemplate.Id"/></param>
748+
/// <param name="identity">The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.</param>
749+
/// <returns>A collection of <see cref="ExtendedEndpoint"/> objects containing endpoint details.</returns>
750+
/// <exception cref="ArgumentNullException">If <paramref name="tenantId"/> is <see langword="null"/>.</exception>
751+
/// <exception cref="ArgumentException">If <paramref name="tenantId"/> is empty.</exception>
752+
/// <exception cref="ArgumentNullException">If <paramref name="endpointTemplateId"/> is <see langword="null"/>.</exception>
753+
/// <exception cref="ArgumentException">If <paramref name="endpointTemplateId"/> is empty.</exception>
754+
/// <exception cref="NotSupportedException">If the provider does not support the given <paramref name="identity"/> type.</exception>
755+
/// <exception cref="InvalidOperationException">If <paramref name="identity"/> is <see langword="null"/> and no default identity is available for the provider.</exception>
756+
/// <exception cref="ResponseException">If the authentication request failed or the token does not exist.</exception>
757+
/// <seealso href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_listEndpoints__v2.0_tenants__tenantId__OS-KSCATALOG_endpoints_Endpoint_Operations_OS-KSCATALOG.html">List Service Catalog Endpoints (OpenStack Identity Service API v2.0 Reference)</seealso>
758+
public virtual ExtendedEndpoint AddServiceCatalogEndpoint(string tenantId, string endpointTemplateId, CloudIdentity identity)
759+
{
760+
CheckIdentity(identity);
761+
762+
var response = ExecuteRESTRequest<GetEndpointResponse>(identity, new Uri(UrlBase, string.Format("/v2.0/tenants/{0}/OS-KSCATALOG/endpoints", tenantId)), HttpMethod.POST, new AddServiceCatalogEndpointRequest(new EndpointTemplate(endpointTemplateId)));
763+
764+
if (response == null || response.Data == null)
765+
return null;
766+
767+
return response.Data.Endpoint;
768+
}
769+
770+
/// <summary>
771+
/// Lists the endpoints in a tenant's service catalog.
772+
/// </summary>
773+
/// <param name="tenantId">The tenant Id. This is obtained from <see cref="Tenant.Id"/></param>
774+
/// <param name="endpointId">The endpoint Id. This is obtained from <see cref="ExtendedEndpoint.Id"/></param>
775+
/// <param name="identity">The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.</param>
776+
/// <returns><see langword="true"/> if the endpoint was successfully deleted; otherwise, <see langword="false"/>.</returns>
777+
/// <exception cref="ArgumentNullException">If <paramref name="tenantId"/> is <see langword="null"/>.</exception>
778+
/// <exception cref="ArgumentException">If <paramref name="tenantId"/> is empty.</exception>
779+
/// <exception cref="ArgumentNullException">If <paramref name="endpointId"/> is <see langword="null"/>.</exception>
780+
/// <exception cref="ArgumentException">If <paramref name="endpointId"/> is empty.</exception>
781+
/// <exception cref="NotSupportedException">If the provider does not support the given <paramref name="identity"/> type.</exception>
782+
/// <exception cref="InvalidOperationException">If <paramref name="identity"/> is <see langword="null"/> and no default identity is available for the provider.</exception>
783+
/// <exception cref="ResponseException">If the authentication request failed or the token does not exist.</exception>
784+
/// <seealso href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_getEndpoint__v2.0_tenants__tenantId__OS-KSCATALOG_endpoints__endpointId__Endpoint_Operations_OS-KSCATALOG.html">List Service Catalog Endpoint (OpenStack Identity Service API v2.0 Reference)</seealso>
785+
public virtual bool DeleteServiceCatalogEndpoint(string tenantId, string endpointId, CloudIdentity identity)
786+
{
787+
CheckIdentity(identity);
788+
789+
var response = ExecuteRESTRequest(identity, new Uri(UrlBase, string.Format("/v2.0/tenants/{0}/OS-KSCATALOG/endpoints/{1}", tenantId, endpointId)), HttpMethod.DELETE);
790+
791+
if (response == null && response.StatusCode != HttpStatusCode.NoContent)
792+
return false;
793+
794+
return true;
795+
}
796+
692797
#endregion
693798

694799
#region Token and Authentication
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace net.openstack.Providers.Rackspace.Objects.Request
2+
{
3+
using System;
4+
using net.openstack.Core.Domain;
5+
using Newtonsoft.Json;
6+
7+
/// <summary>
8+
/// This models the JSON request used for the Add Endpoint request.
9+
/// </summary>
10+
/// <seealso href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/POST_addEndpoint__v2.0_tenants__tenantId__OS-KSCATALOG_endpoints_Endpoint_Operations_OS-KSCATALOG.html">Add Service Catalog Endpoint (OpenStack Identity Service API v2.0 Reference)</seealso>
11+
/// <threadsafety static="true" instance="false"/>
12+
[JsonObject(MemberSerialization.OptIn)]
13+
internal class AddServiceCatalogEndpointRequest
14+
{
15+
/// <summary>
16+
/// Gets additional information about the endpoint template to add.
17+
/// </summary>
18+
[JsonProperty("OS-KSCATALOG:endpointTemplate")]
19+
public EndpointTemplate EndpointTemplate { get; private set; }
20+
21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="AddServiceCatalogEndpointRequest"/> class for the
23+
/// specified <paramref name="endpointTemplate"/>.
24+
/// </summary>
25+
/// <param name="endpointTemplate">The endpoint template.</param>
26+
/// <exception cref="ArgumentNullException">If <paramref name="endpointTemplate"/> is <see langword="null"/>.</exception>
27+
public AddServiceCatalogEndpointRequest(EndpointTemplate endpointTemplate)
28+
{
29+
if (endpointTemplate == null)
30+
throw new ArgumentNullException("endpointTemplate");
31+
32+
EndpointTemplate = endpointTemplate;
33+
}
34+
}
35+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Newtonsoft.Json;
2+
using net.openstack.Core.Domain;
3+
4+
namespace net.openstack.Providers.Rackspace.Objects.Response
5+
{
6+
/// <summary>
7+
/// This models the JSON response used for the Get Endpoint request.
8+
/// </summary>
9+
/// <seealso href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_getEndpoint__v2.0_tenants__tenantId__OS-KSCATALOG_endpoints__endpointId__Endpoint_Operations_OS-KSCATALOG.html">List Service Catalog Endpoints (OpenStack Identity Service API v2.0 Reference)</seealso>
10+
/// <threadsafety static="true" instance="false"/>
11+
[JsonObject(MemberSerialization.OptIn)]
12+
internal class GetEndpointResponse
13+
{
14+
/// <summary>
15+
/// Gets additional information about the endpoint.
16+
/// </summary>
17+
/// <seealso cref="UserAccess"/>
18+
[JsonProperty("endpoint")]
19+
public ExtendedEndpoint Endpoint { get; private set; }
20+
}
21+
}

src/corelib/Providers/Rackspace/Objects/Response/ListEndpointsResponse.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ namespace net.openstack.Providers.Rackspace.Objects.Response
66
/// <summary>
77
/// This models the JSON response used for the List Endpoints request.
88
/// </summary>
9-
/// <seealso href="hhttp://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_listEndpointsForToken_v2.0_tokens__tokenId__endpoints_Token_Operations.html">List Token Endpoints (OpenStack Identity Service API v2.0 Reference)</seealso>
9+
/// <seealso href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_listEndpointsForToken_v2.0_tokens__tokenId__endpoints_Token_Operations.html">List Token Endpoints (OpenStack Identity Service API v2.0 Reference)</seealso>
10+
/// <seealso href="http://docs.openstack.org/api/openstack-identity-service/2.0/content/GET_listEndpoints__v2.0_tenants__tenantId__OS-KSCATALOG_endpoints_Endpoint_Operations_OS-KSCATALOG.html">List Service Catalog Endpoints (OpenStack Identity Service API v2.0 Reference)</seealso>
1011
/// <threadsafety static="true" instance="false"/>
1112
[JsonObject(MemberSerialization.OptIn)]
1213
internal class ListEndpointsResponse

src/corelib/corelib.v3.5.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<Compile Include="Core\Domain\Converters\SimpleStringJsonConverter`1.cs" />
8383
<Compile Include="Core\Domain\Converters\IPAddressSimpleConverter.cs" />
8484
<Compile Include="Core\Domain\DiskConfiguration.cs" />
85+
<Compile Include="Core\Domain\EndpointTemplate.cs" />
8586
<Compile Include="Core\Domain\ExtendedEndpoint.cs" />
8687
<Compile Include="Core\Domain\ExtensibleJsonObject.cs" />
8788
<Compile Include="Core\Domain\FlavorId.cs" />
@@ -521,12 +522,14 @@
521522
<Compile Include="Providers\Rackspace\Objects\Mapping\BulkDeletionResultMapper.cs" />
522523
<Compile Include="Providers\Rackspace\Objects\Mapping\NamespaceDoc.cs" />
523524
<Compile Include="Providers\Rackspace\Objects\NamespaceDoc.cs" />
525+
<Compile Include="Providers\Rackspace\Objects\Request\AddServiceCatalogEndpointRequest.cs" />
524526
<Compile Include="Providers\Rackspace\Objects\Request\CreateVirtualInterfaceRequest.cs" />
525527
<Compile Include="Providers\Rackspace\Objects\Request\NamespaceDoc.cs" />
526528
<Compile Include="Providers\Rackspace\Objects\Request\PasswordCredential.cs" />
527529
<Compile Include="Providers\Rackspace\Objects\Response\BulkDeleteResponse.cs" />
528530
<Compile Include="Providers\Rackspace\Objects\Response\ExtractArchiveError.cs" />
529531
<Compile Include="Providers\Rackspace\Objects\Response\ExtractArchiveResponse.cs" />
532+
<Compile Include="Providers\Rackspace\Objects\Response\GetEndpointResponse.cs" />
530533
<Compile Include="Providers\Rackspace\Objects\Response\ListEndpointsResponse.cs" />
531534
<Compile Include="Providers\Rackspace\Objects\Response\ListVirtualInterfacesResponse.cs" />
532535
<Compile Include="Providers\Rackspace\Objects\Response\MetadataItemResponse.cs" />

src/corelib/corelib.v4.0.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<Compile Include="Core\Domain\Converters\SimpleStringJsonConverter`1.cs" />
7474
<Compile Include="Core\Domain\Converters\IPAddressSimpleConverter.cs" />
7575
<Compile Include="Core\Domain\DiskConfiguration.cs" />
76+
<Compile Include="Core\Domain\EndpointTemplate.cs" />
7677
<Compile Include="Core\Domain\ExtendedEndpoint.cs" />
7778
<Compile Include="Core\Domain\ExtensibleJsonObject.cs" />
7879
<Compile Include="Core\Domain\FlavorId.cs" />
@@ -511,12 +512,14 @@
511512
<Compile Include="Providers\Rackspace\Objects\Queues\Response\ListCloudQueueMessagesResponse.cs" />
512513
<Compile Include="Providers\Rackspace\Objects\Queues\Response\ListCloudQueuesResponse.cs" />
513514
<Compile Include="Providers\Rackspace\Objects\Queues\Response\NamespaceDoc.cs" />
515+
<Compile Include="Providers\Rackspace\Objects\Request\AddServiceCatalogEndpointRequest.cs" />
514516
<Compile Include="Providers\Rackspace\Objects\Request\CreateVirtualInterfaceRequest.cs" />
515517
<Compile Include="Providers\Rackspace\Objects\Request\NamespaceDoc.cs" />
516518
<Compile Include="Providers\Rackspace\Objects\Request\PasswordCredential.cs" />
517519
<Compile Include="Providers\Rackspace\Objects\Response\BulkDeleteResponse.cs" />
518520
<Compile Include="Providers\Rackspace\Objects\Response\ExtractArchiveError.cs" />
519521
<Compile Include="Providers\Rackspace\Objects\Response\ExtractArchiveResponse.cs" />
522+
<Compile Include="Providers\Rackspace\Objects\Response\GetEndpointResponse.cs" />
520523
<Compile Include="Providers\Rackspace\Objects\Response\ListEndpointsResponse.cs" />
521524
<Compile Include="Providers\Rackspace\Objects\Response\MetadataItemResponse.cs" />
522525
<Compile Include="Providers\Rackspace\Objects\Response\ListVirtualInterfacesResponse.cs" />

0 commit comments

Comments
 (0)