예제 #1
0
        /// <summary>
        /// Deletes the router and any attached interfaces.
        /// </summary>
        /// <inheritdoc cref="NetworkingApiBuilder.DeleteRouterAsync"/>
        /// <exception cref="InvalidOperationException">Thrown when a resource as not constructed by the SDK.</exception>
        public async Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            var networking = this.GetOwnerOrThrow<NetworkingApiBuilder>();

            // Remove attached interfaces, these aren't really tracked by the end-user but will prevent deleting the router
            var filterByRouter = new PortListOptions {DeviceId = Id};
            var attachedPorts = await networking.ListPortsAsync<PortCollection>(filterByRouter, cancellationToken);
            Task.WaitAll(attachedPorts.Select(port => DetachPortAsync(port.Id, cancellationToken)).ToArray());

            await networking.DeleteRouterAsync(Id, cancellationToken).ConfigureAwait(false);
        }
예제 #2
0

        
        /// <summary>
        /// Lists all ip address list.
        /// </summary>
        /// <param name="networkDomainId">The Network domain id.</param>
        /// <param name="options">The filter options.</param>
        /// <param name="pagingOptions">The paging options.</param>
        /// <returns>The async task of <see cref="PagedResponse{PortListType}"/></returns>
        public async Task <PagedResponse <PortListType> > GetPortListsPaginated(Guid networkDomainId, PortListOptions options = null, PageableRequest pagingOptions = null)
        {
            var response = await _api.GetAsync <portLists>(ApiUris.ListPortList(_api.OrganizationId, networkDomainId), pagingOptions, options);

            return(new PagedResponse <PortListType>
            {
                items = response.portList,
                totalCount = response.totalCountSpecified ? response.totalCount : (int?)null,
                pageCount = response.pageCountSpecified ? response.pageCount : (int?)null,
                pageNumber = response.pageNumberSpecified ? response.pageNumber : (int?)null,
                pageSize = response.pageSizeSpecified ? response.pageSize : (int?)null
            });
        }
        /// <summary>
        /// Lists all ip address list.
        /// </summary>
        /// <param name="networkDomainId">The network domain id.</param>
        /// <param name="options">The filter options.</param>
        /// <returns>The collection of matching ip address list.</returns>
        public async Task <IEnumerable <PortListType> > GetPortLists(Guid networkDomainId, PortListOptions options = null)
        {
            var response = await GetPortListsPaginated(networkDomainId, options, null);

            return(response.items);
        }
 /// <summary>
 /// Lists all ports associated with the account.
 /// </summary>
 /// <returns>
 /// A collection of port resources associated with the account.
 /// </returns>
 public static IEnumerable <Port> ListPorts(this NetworkingService networkingService, PortListOptions options = null)
 {
     return(networkingService.ListPortsAsync(options).ForceSynchronous());
 }