
com.blazebit.query.connector.azure.resourcemanager.BlobServicePropertiesDataFetcher Maven / Gradle / Ivy
The newest version!
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Blazebit
*/
package com.blazebit.query.connector.azure.resourcemanager;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.storage.models.BlobServiceProperties;
import com.blazebit.query.connector.base.DataFormats;
import com.blazebit.query.spi.DataFetchContext;
import com.blazebit.query.spi.DataFetcher;
import com.blazebit.query.spi.DataFetcherException;
import com.blazebit.query.spi.DataFormat;
/**
* @author Christian Beikov
* @since 1.0.0
*/
public class BlobServicePropertiesDataFetcher implements DataFetcher, Serializable {
public static final BlobServicePropertiesDataFetcher INSTANCE = new BlobServicePropertiesDataFetcher();
private BlobServicePropertiesDataFetcher() {
}
@Override
public List fetch(DataFetchContext context) {
try {
List resourceManagers = AzureResourceManagerConnectorConfig.AZURE_RESOURCE_MANAGER.getAll(
context );
List list = new ArrayList<>();
for ( AzureResourceManager resourceManager : resourceManagers ) {
for ( AzureResourceStorageAccount storageAccount : context.getSession()
.getOrFetch( AzureResourceStorageAccount.class ) ) {
if ( resourceManager.subscriptionId().equals( storageAccount.getSubscriptionId() ) ) {
BlobServiceProperties blobServiceProperties = resourceManager.storageBlobServices()
.getServicePropertiesAsync(
storageAccount.getResourceGroupName(),
storageAccount.getResourceName()
).block();
if ( blobServiceProperties != null ) {
list.add( new AzureResourceBlobServiceProperties(
resourceManager.tenantId(),
blobServiceProperties.id(),
blobServiceProperties.innerModel()
) );
}
}
}
}
return list;
}
catch (RuntimeException e) {
throw new DataFetcherException( "Could not fetch blob service properties list", e );
}
}
@Override
public DataFormat getDataFormat() {
return DataFormats.componentMethodConvention( AzureResourceBlobServiceProperties.class,
AzureResourceManagerConventionContext.INSTANCE );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy