com.microsoft.azure.PagedList Java Examples

The following examples show how to use com.microsoft.azure.PagedList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZipDeployTests.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
@Test
public void canZipDeployFunction() {
    // Create function app
    FunctionApp functionApp = appServiceManager.functionApps().define(WEBAPP_NAME_4)
            .withRegion(Region.US_WEST)
            .withNewResourceGroup(RG_NAME)
            .create();
    Assert.assertNotNull(functionApp);
    SdkContext.sleep(5000);
    functionApp.zipDeploy(new File(FunctionAppsTests.class.getResource("/square-function-app.zip").getPath()));
    SdkContext.sleep(5000);
    String response = post("http://" + WEBAPP_NAME_4 + ".azurewebsites.net" + "/api/square", "25");
    Assert.assertNotNull(response);
    Assert.assertEquals("625", response);

    PagedList<FunctionEnvelope> envelopes = appServiceManager.functionApps().listFunctions(RG_NAME, functionApp.name());
    Assert.assertNotNull(envelopes);
    Assert.assertEquals(1, envelopes.size());
    Assert.assertEquals(envelopes.get(0).href(), "https://" + WEBAPP_NAME_4 +".scm.azurewebsites.net/api/functions/square");
}
 
Example #2
Source File: AzureVolumeResourceBuilder.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
private ResourceStatus getResourceStatus(PagedList<Disk> existingDisks, List<CloudResource> volumeResources) {

        List<String> expectedIdList = volumeResources.stream()
                .map(this::getVolumeSetAttributes)
                .map(VolumeSetAttributes::getVolumes)
                .flatMap(List::stream)
                .map(VolumeSetAttributes.Volume::getId)
                .collect(Collectors.toList());
        List<String> actualIdList = existingDisks.stream()
                .map(Disk::id)
                .collect(Collectors.toList());
        if (!actualIdList.containsAll(expectedIdList)) {
            return ResourceStatus.DELETED;
        }
        List<String> actualAttachedIdList = existingDisks.stream().
                filter(Disk::isAttachedToVirtualMachine).map(Disk::id)
                .collect(Collectors.toList());
        if (actualAttachedIdList.containsAll(expectedIdList)) {
            return ResourceStatus.ATTACHED;
        }
        return ResourceStatus.CREATED;
    }
 
Example #3
Source File: AzureFetchOrchestrator.java    From pacbot with Apache License 2.0 6 votes vote down vote up
private List<SubscriptionVH> fetchSubscriptions() {

		List<SubscriptionVH> subscriptionList  = new ArrayList<>();
		
		if(tenants != null && !"".equals(tenants)){
			String[] tenantList = tenants.split(",");
			for(String tenant : tenantList){
				Authenticated azure = azureCredentialProvider.authenticate(tenant);
				PagedList<Subscription> subscriptions = azure.subscriptions().list();
				for(Subscription subscription : subscriptions) {
					SubscriptionVH subscriptionVH= new SubscriptionVH();
					subscriptionVH.setTenant(tenant);
					subscriptionVH.setSubscriptionId(subscription.subscriptionId());
					subscriptionVH.setSubscriptionName(subscription.displayName());
					subscriptionList.add(subscriptionVH);
				}
			}
		}
		log.info("Total Subscription in Scope : {}",subscriptionList.size());
		log.info("Subscriptions : {}",subscriptionList);
		return subscriptionList;
	}
 
Example #4
Source File: SnapshotInventoryCollector.java    From pacbot with Apache License 2.0 6 votes vote down vote up
public List<SnapshotVH> fetchSnapshotDetails(SubscriptionVH subscription, Map<String, Map<String, String>> tagMap) {
	List<SnapshotVH> snapshotList = new ArrayList<SnapshotVH>();

	Azure azure = azureCredentialProvider.getClient(subscription.getTenant(),subscription.getSubscriptionId());
	PagedList<Snapshot> snapshots = azure.snapshots().list();
	for (Snapshot snapshot : snapshots) {
		SnapshotVH snapshotVH = new SnapshotVH();
		snapshotVH.setId(snapshot.id());
		snapshotVH.setName(snapshot.name());
		snapshotVH.setResourceGroupName(snapshot.resourceGroupName());
		snapshotVH.setType(snapshot.type());
		snapshotVH.setTags(Util.tagsList(tagMap, snapshot.resourceGroupName(), snapshot.tags()));
		snapshotVH.setSubscription(subscription.getSubscriptionId());
		snapshotVH.setSubscriptionName(subscription.getSubscriptionName());
		snapshotVH.setKey(snapshot.key());
		snapshotVH.setRegionName(snapshot.regionName());
		snapshotVH.setSizeInGB(snapshot.sizeInGB());
		snapshotList.add(snapshotVH);

	}
	log.info("Target Type : {}  Total: {} ","Snapshot {}",snapshots.size());

	return snapshotList;
}
 
Example #5
Source File: AzureCloudResourceService.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
public List<CloudResource> getAttachedOsDiskResources(AuthenticatedContext authenticatedContext, List<CloudResource> instanceList,
        String resourceGroupName) {

    List<CloudResource> osDiskList = new ArrayList<>();
    AzureClient client = authenticatedContext.getParameter(AzureClient.class);
    PagedList<VirtualMachine> virtualMachines = client.getVirtualMachines(resourceGroupName);
    virtualMachines.loadAll();

    instanceList.forEach(vm -> {
        Optional<VirtualMachine> matchingAzureVmOptional = virtualMachines
                .stream()
                .filter(azureVirtualMachine -> vm.getName().equals(azureVirtualMachine.name()))
                .findFirst();
        matchingAzureVmOptional.ifPresentOrElse(
                matchingAzureVm ->
                        osDiskList.add(collectOsDisk(vm.getInstanceId(), matchingAzureVm)),
                () -> LOGGER.warn("No Azure VM metadata found for the VM: " + vm.getInstanceId()));
            }
    );

    return osDiskList;
}
 
Example #6
Source File: CosmosDBInventoryCollector.java    From pacbot with Apache License 2.0 6 votes vote down vote up
public List<CosmosDBVH> fetchCosmosDBDetails(SubscriptionVH subscription, Map<String, Map<String, String>> tagMap) {
	List<CosmosDBVH> cosmosDBList = new ArrayList<>();
	Azure azure = azureCredentialProvider.getClient(subscription.getTenant(),subscription.getSubscriptionId());
	PagedList<CosmosDBAccount> CosmosDB = azure.cosmosDBAccounts().list();
	for (CosmosDBAccount cosmosDB : CosmosDB) {
		CosmosDBVH cosmosDBVH = new CosmosDBVH();
		cosmosDBVH.setSubscription(subscription.getSubscriptionId());
		cosmosDBVH.setSubscriptionName(subscription.getSubscriptionName());
		cosmosDBVH.setId(cosmosDB.id());
		cosmosDBVH.setKey(cosmosDB.key());
		cosmosDBVH.setName(cosmosDB.name());
		cosmosDBVH.setResourceGroupName(cosmosDB.resourceGroupName());
		cosmosDBVH.setRegion(cosmosDB.regionName());
		cosmosDBVH.setTags(Util.tagsList(tagMap, cosmosDB.resourceGroupName(), cosmosDB.tags()));
		cosmosDBVH.setType(cosmosDB.type());
		cosmosDBVH.setIpRangeFilter(cosmosDB.ipRangeFilter());
		cosmosDBVH.setMultipleWriteLocationsEnabled(cosmosDB.multipleWriteLocationsEnabled());
		cosmosDBVH.setVirtualNetworkRuleList(getVirtualNetworkRule(cosmosDB.virtualNetworkRules()));
		cosmosDBList.add(cosmosDBVH);
	}
	log.info("Target Type : {}  Total: {} ","Cosom DB",cosmosDBList.size());
	return cosmosDBList;
}
 
Example #7
Source File: AzureVolumeResourceBuilder.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Override
protected List<CloudResourceStatus> checkResources(ResourceType type, AzureContext context, AuthenticatedContext auth, Iterable<CloudResource> resources) {
    AzureClient client = getAzureClient(auth);
    List<CloudResource> volumeResources = StreamSupport.stream(resources.spliterator(), false)
            .filter(r -> r.getType().equals(resourceType()))
            .collect(Collectors.toList());
    CloudResource resourceGroup = context.getNetworkResources().stream()
            .filter(r -> r.getType().equals(ResourceType.AZURE_RESOURCE_GROUP))
            .findFirst()
            .orElseThrow(() -> new AzureResourceException("Resource group resource not found"));
    String resourceGroupName = resourceGroup.getName();

    PagedList<Disk> existingDisks = client.listDisksByResourceGroup(resourceGroupName);
    ResourceStatus volumeSetStatus = getResourceStatus(existingDisks, volumeResources);
    return volumeResources.stream()
            .map(resource -> new CloudResourceStatus(resource, volumeSetStatus))
            .collect(Collectors.toList());
}
 
Example #8
Source File: KeyImpl.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
@Override
public PagedList<Key> listVersions() {
    return new PagedListConverter<KeyItem, Key>() {

        @Override
        public Observable<Key> typeConvertAsync(final KeyItem keyItem) {
            return new KeyVaultFutures.ServiceFutureConverter<KeyBundle, Key>() {

                @Override
                protected ServiceFuture<KeyBundle> callAsync() {
                    return vault.client().getKeyAsync(keyItem.identifier().identifier(), null);
                }

                @Override
                protected Key wrapModel(KeyBundle keyBundle) {
                    return new KeyImpl(keyBundle.keyIdentifier().name(), keyBundle, vault);
                }
            }.toObservable();
        }
    }.convert(vault.client().listKeyVersions(vault.vaultUri(), name()));
}
 
Example #9
Source File: AzureCloudResourceServiceTest.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
@Test
public void getListWithKnownFailedCloudResource() {
    TargetResource t = new TargetResource();
    t.withResourceType(MICROSOFT_COMPUTE_VIRTUAL_MACHINES);
    t.withResourceName(VM_NAME);
    PagedList<DeploymentOperation> operationList = Mockito.spy(PagedList.class);
    DeploymentOperations operations = Mockito.mock(DeploymentOperations.class);
    DeploymentOperation operation = Mockito.mock(DeploymentOperation.class);
    operationList.add(operation);

    when(deployment.deploymentOperations()).thenReturn(operations);
    when(deployment.deploymentOperations().list()).thenReturn(operationList);
    when(operation.targetResource()).thenReturn(t);
    when(operation.provisioningState()).thenReturn("failed");

    List<CloudResource> cloudResourceList = underTest.getDeploymentCloudResources(deployment);

    assertEquals(1, cloudResourceList.size());
    CloudResource cloudResource = cloudResourceList.get(0);
    assertEquals(VM_NAME, cloudResource.getName());
    assertEquals(CommonStatus.FAILED, cloudResource.getStatus());
}
 
Example #10
Source File: TestAvailabilitySet.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
@Override
public AvailabilitySet createResource(AvailabilitySets availabilitySets) throws Exception {
    final String newName = "as" + this.testId;
    AvailabilitySet aset = availabilitySets.define(newName)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup()
            .withFaultDomainCount(2)
            .withUpdateDomainCount(4)
            .withTag("tag1", "value1")
            .create();
    PagedList<VirtualMachineSize> vmSizes = aset.listVirtualMachineSizes();
    Assert.assertTrue(vmSizes.size() > 0);
    for (VirtualMachineSize vmSize : vmSizes) {
        Assert.assertNotNull(vmSize.name());
    }
    return aset;
}
 
Example #11
Source File: ExpressRouteCrossConnectionsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Retrieves all the ExpressRouteCrossConnections in a resource group.
 *
 * @param resourceGroupName The name of the resource group.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;ExpressRouteCrossConnectionInner&gt; object if successful.
 */
public PagedList<ExpressRouteCrossConnectionInner> listByResourceGroup(final String resourceGroupName) {
    ServiceResponse<Page<ExpressRouteCrossConnectionInner>> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single();
    return new PagedList<ExpressRouteCrossConnectionInner>(response.body()) {
        @Override
        public Page<ExpressRouteCrossConnectionInner> nextPage(String nextPageLink) {
            return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #12
Source File: ContainerGroupsImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public PagedList<ContainerGroup> listByResourceGroup(String resourceGroupName) {
    final PagedListConverter<ContainerGroupInner, ContainerGroup> converter = new PagedListConverter<ContainerGroupInner, ContainerGroup>() {
        @Override
        public Observable<ContainerGroup> typeConvertAsync(ContainerGroupInner inner) {
            return wrapModel(inner).refreshAsync();
        }
    };
    return converter.convert(this.inner().listByResourceGroup(resourceGroupName));
}
 
Example #13
Source File: ObjectsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Gets AD group membership for the specified AD object IDs.
 *
 * @param parameters Objects filtering parameters.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;AADObjectInner&gt; object if successful.
 */
public PagedList<AADObjectInner> getObjectsByObjectIds(final GetObjectsParametersInner parameters) {
    ServiceResponse<Page<AADObjectInner>> response = getObjectsByObjectIdsSinglePageAsync(parameters).toBlocking().single();
    return new PagedList<AADObjectInner>(response.body()) {
        @Override
        public Page<AADObjectInner> nextPage(String nextLink) {
            return getObjectsByObjectIdsNextSinglePageAsync(nextLink).toBlocking().single().body();
        }
    };
}
 
Example #14
Source File: SqlSyncGroupOperationsImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public PagedList<String> listSyncDatabaseIds(String locationName) {
    final SqlSyncGroupOperationsImpl self = this;
    final PagedListConverter<SyncDatabaseIdPropertiesInner, String> converter = new PagedListConverter<SyncDatabaseIdPropertiesInner, String>() {
        @Override
        public Observable<String> typeConvertAsync(SyncDatabaseIdPropertiesInner inner) {
            return Observable.just(inner.id());
        }
    };
    return converter.convert(this.sqlServerManager.inner().syncGroups()
        .listSyncDatabaseIds(locationName));
}
 
Example #15
Source File: QueueAuthorizationRulesImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public PagedList<QueueAuthorizationRule> listByParent(String resourceGroupName, String parentName) {
    // 'IndependentChildResourcesImpl' will be refactoring to remove all 'ByParent' methods
    // This method is not exposed to end user from any of the derived types of IndependentChildResourcesImpl
    //
    throw new UnsupportedOperationException();
}
 
Example #16
Source File: ContainerServicesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Gets a list of container services in the specified subscription.
 * Gets a list of container services in the specified subscription. The operation returns properties of each container service including state, orchestrator, number of masters and agents, and FQDNs of masters and agents.
 *
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;ContainerServiceInner&gt; object if successful.
 */
public PagedList<ContainerServiceInner> list() {
    ServiceResponse<Page<ContainerServiceInner>> response = listSinglePageAsync().toBlocking().single();
    return new PagedList<ContainerServiceInner>(response.body()) {
        @Override
        public Page<ContainerServiceInner> nextPage(String nextPageLink) {
            return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #17
Source File: VpnGatewaysInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Lists all the VpnGateways in a resource group.
 *
 * @param resourceGroupName The resource group name of the VpnGateway.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;VpnGatewayInner&gt; object if successful.
 */
public PagedList<VpnGatewayInner> listByResourceGroup(final String resourceGroupName) {
    ServiceResponse<Page<VpnGatewayInner>> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single();
    return new PagedList<VpnGatewayInner>(response.body()) {
        @Override
        public Page<VpnGatewayInner> nextPage(String nextPageLink) {
            return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #18
Source File: AccountsImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Gets the first page of Data Lake Analytics accounts, if any, within a specific resource group. This includes a link to the next page, if any.
 *
 * @param resourceGroupName The name of the Azure resource group.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;DataLakeAnalyticsAccountBasic&gt; object if successful.
 */
public PagedList<DataLakeAnalyticsAccountBasic> listByResourceGroup(final String resourceGroupName) {
    ServiceResponse<Page<DataLakeAnalyticsAccountBasic>> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single();
    return new PagedList<DataLakeAnalyticsAccountBasic>(response.body()) {
        @Override
        public Page<DataLakeAnalyticsAccountBasic> nextPage(String nextPageLink) {
            return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #19
Source File: NatGatewaysInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Gets all nat gateways in a resource group.
 *
 * @param resourceGroupName The name of the resource group.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;NatGatewayInner&gt; object if successful.
 */
public PagedList<NatGatewayInner> listByResourceGroup(final String resourceGroupName) {
    ServiceResponse<Page<NatGatewayInner>> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single();
    return new PagedList<NatGatewayInner>(response.body()) {
        @Override
        public Page<NatGatewayInner> nextPage(String nextPageLink) {
            return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #20
Source File: SubscriptionsImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public PagedList<Subscription> list() {
    PagedListConverter<SubscriptionInner, Subscription> converter = new PagedListConverter<SubscriptionInner, Subscription>() {
        @Override
        public Observable<Subscription> typeConvertAsync(SubscriptionInner subscriptionInner) {
            return Observable.just((Subscription) wrapModel(subscriptionInner));
        }
    };
    return converter.convert(client.list());
}
 
Example #21
Source File: SubscriptionUsagesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Gets all subscription usage metrics in a given location.
 *
 * @param locationName The name of the region where the resource is located.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;SubscriptionUsageInner&gt; object if successful.
 */
public PagedList<SubscriptionUsageInner> listByLocation(final String locationName) {
    ServiceResponse<Page<SubscriptionUsageInner>> response = listByLocationSinglePageAsync(locationName).toBlocking().single();
    return new PagedList<SubscriptionUsageInner>(response.body()) {
        @Override
        public Page<SubscriptionUsageInner> nextPage(String nextPageLink) {
            return listByLocationNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #22
Source File: PolicyDefinitionsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Gets all the policy definitions for a subscription.
 *
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;PolicyDefinitionInner&gt; object if successful.
 */
public PagedList<PolicyDefinitionInner> list() {
    ServiceResponse<Page<PolicyDefinitionInner>> response = listSinglePageAsync().toBlocking().single();
    return new PagedList<PolicyDefinitionInner>(response.body()) {
        @Override
        public Page<PolicyDefinitionInner> nextPage(String nextPageLink) {
            return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #23
Source File: InstancePoolsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Gets a list of all instance pools in the subscription.
 *
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;InstancePoolInner&gt; object if successful.
 */
public PagedList<InstancePoolInner> list() {
    ServiceResponse<Page<InstancePoolInner>> response = listSinglePageAsync().toBlocking().single();
    return new PagedList<InstancePoolInner>(response.body()) {
        @Override
        public Page<InstancePoolInner> nextPage(String nextPageLink) {
            return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #24
Source File: UsagesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription.
 *
 * @param location The location for which resource usage is queried.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;UsageInner&gt; object if successful.
 */
public PagedList<UsageInner> list(final String location) {
    ServiceResponse<Page<UsageInner>> response = listSinglePageAsync(location).toBlocking().single();
    return new PagedList<UsageInner>(response.body()) {
        @Override
        public Page<UsageInner> nextPage(String nextPageLink) {
            return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #25
Source File: BastionHostsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Lists all Bastion Hosts in a resource group.
 *
 * @param resourceGroupName The name of the resource group.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;BastionHostInner&gt; object if successful.
 */
public PagedList<BastionHostInner> listByResourceGroup(final String resourceGroupName) {
    ServiceResponse<Page<BastionHostInner>> response = listByResourceGroupSinglePageAsync(resourceGroupName).toBlocking().single();
    return new PagedList<BastionHostInner>(response.body()) {
        @Override
        public Page<BastionHostInner> nextPage(String nextPageLink) {
            return listByResourceGroupNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #26
Source File: ProfilesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Lists all Traffic Manager profiles within a resource group.
 *
 * @param resourceGroupName The name of the resource group containing the Traffic Manager profiles to be listed.
 * @return the PagedList<ProfileInner> object if successful.
 */
public PagedList<ProfileInner> listByResourceGroup(String resourceGroupName) {
    PageImpl<ProfileInner> page = new PageImpl<>();
    page.setItems(listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().body());
    page.setNextPageLink(null);
    return new PagedList<ProfileInner>(page) {
        @Override
        public Page<ProfileInner> nextPage(String nextPageLink) {
            return null;
        }
    };
}
 
Example #27
Source File: ResourcesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Get all the resources in a subscription.
 *
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @throws CloudException thrown if the request is rejected by server
 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
 * @return the PagedList&lt;GenericResourceInner&gt; object if successful.
 */
public PagedList<GenericResourceInner> list() {
    ServiceResponse<Page<GenericResourceInner>> response = listSinglePageAsync().toBlocking().single();
    return new PagedList<GenericResourceInner>(response.body()) {
        @Override
        public Page<GenericResourceInner> nextPage(String nextPageLink) {
            return listNextSinglePageAsync(nextPageLink).toBlocking().single().body();
        }
    };
}
 
Example #28
Source File: ActivityLogAlertsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Get a list of all activity log alerts in a resource group.
 *
 * @param resourceGroupName The name of the resource group.
 * @return the PagedList<ActivityLogAlertResourceInner> object if successful.
 */
public PagedList<ActivityLogAlertResourceInner> listByResourceGroup(String resourceGroupName) {
    PageImpl1<ActivityLogAlertResourceInner> page = new PageImpl1<>();
    page.setItems(listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().body());
    page.setNextPageLink(null);
    return new PagedList<ActivityLogAlertResourceInner>(page) {
        @Override
        public Page<ActivityLogAlertResourceInner> nextPage(String nextPageLink) {
            return null;
        }
    };
}
 
Example #29
Source File: ComputeSkuTetsts.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Test
public void canListSkusByResourceType() throws Exception {
    PagedList<ComputeSku> skus = this.computeManager.computeSkus().listByResourceType(ComputeResourceType.VIRTUALMACHINES);
    for (ComputeSku sku : skus) {
        Assert.assertTrue(sku.resourceType().equals(ComputeResourceType.VIRTUALMACHINES));
    }

    skus = this.computeManager.computeSkus().listByResourceType(ComputeResourceType.fromString("Unknown"));
    Assert.assertNotNull(skus);
    Assert.assertEquals(0, skus.size());
}
 
Example #30
Source File: RegistriesImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public PagedList<Registry> list() {
    final RegistriesImpl self = this;
    return new GroupPagedList<Registry>(this.manager().resourceManager().resourceGroups().list()) {
        @Override
        public List<Registry> listNextGroup(String resourceGroupName) {
            return wrapList(self.inner().listByResourceGroup(resourceGroupName));

        }
    };
}