Search in sources :

Example 1 with Registries

use of com.microsoft.azure.management.containerregistry.Registries in project azure-tools-for-java by Microsoft.

the class ContainerRegistryMvpModel method setAdminUserEnabled.

/**
 * Set AdminUser enabled status of container registry.
 */
public Registry setAdminUserEnabled(String sid, String id, boolean enabled) {
    Azure azure = AuthMethodManager.getInstance().getAzureClient(sid);
    Registries registries = azure.containerRegistries();
    if (registries != null) {
        Registry registry = registries.getById(id);
        if (registry != null) {
            clearTags(registry);
            if (enabled) {
                registry.update().withRegistryNameAsAdminUser().apply();
            } else {
                registry.update().withoutRegistryNameAsAdminUser().apply();
            }
        }
        return registry;
    } else {
        return null;
    }
}
Also used : Azure(com.microsoft.azure.management.Azure) Registries(com.microsoft.azure.management.containerregistry.Registries) Registry(com.microsoft.azure.management.containerregistry.Registry)

Example 2 with Registries

use of com.microsoft.azure.management.containerregistry.Registries in project azure-tools-for-java by Microsoft.

the class ContainerRegistryMvpModel method getContainerRegistry.

/**
 * Get ACR by Id.
 */
@NotNull
public Registry getContainerRegistry(String sid, String id) throws Exception {
    Azure azure = AuthMethodManager.getInstance().getAzureClient(sid);
    Registries registries = azure.containerRegistries();
    if (registries == null) {
        throw new Exception(CANNOT_GET_REGISTRY + id);
    }
    Registry registry = registries.getById(id);
    if (registry == null) {
        throw new Exception(CANNOT_GET_REGISTRY + id);
    }
    return registry;
}
Also used : Azure(com.microsoft.azure.management.Azure) Registries(com.microsoft.azure.management.containerregistry.Registries) Registry(com.microsoft.azure.management.containerregistry.Registry) NotNull(com.microsoft.azuretools.azurecommons.helpers.NotNull)

Aggregations

Azure (com.microsoft.azure.management.Azure)2 Registries (com.microsoft.azure.management.containerregistry.Registries)2 Registry (com.microsoft.azure.management.containerregistry.Registry)2 NotNull (com.microsoft.azuretools.azurecommons.helpers.NotNull)1