com.microsoft.azure.CloudException Java Examples

The following examples show how to use com.microsoft.azure.CloudException. 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: DnsZoneRecordSetETagTests.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Runs the action and assert that action throws CloudException with CloudError.Code
 * property set to 'PreconditionFailed'.
 *
 * @param action action to run
 */
private void ensureETagExceptionIsThrown(final Action0 action) {
    boolean isCloudExceptionThrown = false;
    boolean isCloudErrorSet = false;
    boolean isPreconditionFailedCodeSet = false;
    try {
        action.call();
    } catch (CloudException exception) {
        isCloudExceptionThrown = true;
        CloudError cloudError = exception.body();
        if (cloudError != null) {
            isCloudErrorSet = true;
            isPreconditionFailedCodeSet = cloudError.code().contains("PreconditionFailed");
        }
    }
    Assert.assertTrue("Expected CloudException is not thrown", isCloudExceptionThrown);
    Assert.assertTrue("Expected CloudError property is not set in CloudException", isCloudErrorSet);
    Assert.assertTrue("Expected PreconditionFailed code is not set indicating ETag concurrency check failure", isPreconditionFailedCodeSet);
}
 
Example #2
Source File: AzureUtils.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
private <T> Optional<String> handleDeleteErrors(Consumer<String> deleteConsumer, String resourceType, String resourceId, boolean cancelException) {
    try {
        LOGGER.debug("Deleteing {} {}", resourceType, resourceId);
        deleteConsumer.accept(resourceId);
        return Optional.empty();
    } catch (CloudException e) {
        LOGGER.warn("Exception during resource delete", e);
        Optional<String> errorMessageOptional = getErrorMessage(resourceType, resourceId, e);
        if (errorMessageOptional.isEmpty()) {
            return Optional.empty();
        }
        if (cancelException) {
            LOGGER.warn(errorMessageOptional.get());
            LOGGER.warn("{} {} deletion failed, continuing because termination is forced", resourceType, resourceId);
            return errorMessageOptional;
        } else {
            LOGGER.warn(errorMessageOptional.get());
            throw new CloudConnectorException(errorMessageOptional.get(), e);
        }
    }
}
 
Example #3
Source File: AzureBaseImageValidator.java    From halyard with Apache License 2.0 6 votes vote down vote up
@Override
public void validate(ConfigProblemSetBuilder p, AzureBaseImage n) {

  AzureCredentials credentials =
      credentialsList.get(
          0); // The first credentials should be fine since we're validating against public images
  AzureComputeClient computeClient = credentials.getComputeClient();
  AzureBaseImage.AzureOperatingSystemSettings osSettings = n.getBaseImage();
  String version = osSettings.getVersion();

  try {
    computeClient.getVMImage(
        "westus", osSettings.getPublisher(), osSettings.getOffer(), osSettings.getSku(), version);
  } catch (Exception e) {
    String message =
        e instanceof CloudException
            ? CloudException.class.cast(e).body().message()
            : e.getMessage();
    p.addProblem(
            Problem.Severity.WARNING,
            "Error getting image '" + n.getNodeName() + "' in region 'westus': " + message)
        .setRemediation(
            "If you are not targeting 'westus' and know the image is available in other regions, you can ignore this warning and select a different region when baking images. See available images here: https://aka.ms/azspinimage");
  }
}
 
Example #4
Source File: VirtualMachineScaleSetVMsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<Void> beginPowerOffDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<Void>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #5
Source File: InboundNatRulesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<Void> beginDeleteDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<Void>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .register(204, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #6
Source File: VaultsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<VaultInner> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<VaultInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<VaultInner>() { }.getType())
            .register(201, new TypeToken<VaultInner>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #7
Source File: UserAssignedIdentitiesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<Void> deleteDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<Void>() { }.getType())
            .register(204, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #8
Source File: NetworkInterfacesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<EffectiveNetworkSecurityGroupListResultInner> beginListEffectiveNetworkSecurityGroupsDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<EffectiveNetworkSecurityGroupListResultInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<EffectiveNetworkSecurityGroupListResultInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #9
Source File: FailoverGroupsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<FailoverGroupInner> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<FailoverGroupInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<FailoverGroupInner>() { }.getType())
            .register(201, new TypeToken<FailoverGroupInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #10
Source File: RestorePointsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<RestorePointInner> beginCreateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<RestorePointInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<RestorePointInner>() { }.getType())
            .register(201, new TypeToken<RestorePointInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #11
Source File: RegistriesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<RegistryInner> beginUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<RegistryInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<RegistryInner>() { }.getType())
            .register(201, new TypeToken<RegistryInner>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #12
Source File: WorkspacesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<WorkspaceInner> beginCreateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<WorkspaceInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<WorkspaceInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #13
Source File: FirewallPolicyRuleGroupsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<Void> beginDeleteDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<Void>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .register(204, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #14
Source File: VirtualMachineScaleSetVMsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<Void> beginStartDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<Void>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #15
Source File: ManagedInstanceTdeCertificatesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<Void> beginCreateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<Void>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #16
Source File: CassandraResourcesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<ThroughputSettingsGetResultsInner> beginUpdateCassandraTableThroughputDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<ThroughputSettingsGetResultsInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<ThroughputSettingsGetResultsInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #17
Source File: DatabasesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<DatabaseInner> beginUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<DatabaseInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<DatabaseInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #18
Source File: ExpressRouteCircuitAuthorizationsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<ExpressRouteCircuitAuthorizationInner> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<ExpressRouteCircuitAuthorizationInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<ExpressRouteCircuitAuthorizationInner>() { }.getType())
            .register(201, new TypeToken<ExpressRouteCircuitAuthorizationInner>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #19
Source File: OpenShiftManagedClustersInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<OpenShiftManagedClusterInner> beginCreateOrUpdateDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<OpenShiftManagedClusterInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<OpenShiftManagedClusterInner>() { }.getType())
            .register(201, new TypeToken<OpenShiftManagedClusterInner>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #20
Source File: CassandraResourcesInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<CassandraKeyspaceGetResultsInner> beginCreateUpdateCassandraKeyspaceDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<CassandraKeyspaceGetResultsInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<CassandraKeyspaceGetResultsInner>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #21
Source File: ExpressRoutePortsInner.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ServiceResponse<Void> beginDeleteDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<Void, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<Void>() { }.getType())
            .register(202, new TypeToken<Void>() { }.getType())
            .register(204, new TypeToken<Void>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #22
Source File: FailoverGroupsInner.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
private ServiceResponse<PageImpl1<FailoverGroupInner>> listByServerDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PageImpl1<FailoverGroupInner>, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PageImpl1<FailoverGroupInner>>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #23
Source File: ManagedDatabaseSensitivityLabelsInner.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
private ServiceResponse<PageImpl1<SensitivityLabelInner>> listCurrentByDatabaseNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PageImpl1<SensitivityLabelInner>, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PageImpl1<SensitivityLabelInner>>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #24
Source File: GalleryApplicationVersionsInner.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
private ServiceResponse<PageImpl1<GalleryApplicationVersionInner>> listByGalleryApplicationNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PageImpl1<GalleryApplicationVersionInner>, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PageImpl1<GalleryApplicationVersionInner>>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #25
Source File: DefaultSecurityRulesInner.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
private ServiceResponse<PageImpl<SecurityRuleInner>> listNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PageImpl<SecurityRuleInner>, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PageImpl<SecurityRuleInner>>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #26
Source File: RegistriesInner.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
private ServiceResponse<PageImpl<RegistryInner>> listDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PageImpl<RegistryInner>, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PageImpl<RegistryInner>>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #27
Source File: PrivateLinkServicesInner.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
private ServiceResponse<PageImpl<AutoApprovedPrivateLinkServiceInner>> listAutoApprovedPrivateLinkServicesNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PageImpl<AutoApprovedPrivateLinkServiceInner>, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PageImpl<AutoApprovedPrivateLinkServiceInner>>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #28
Source File: ManagedDatabaseSensitivityLabelsInner.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
private ServiceResponse<SensitivityLabelInner> getDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<SensitivityLabelInner, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<SensitivityLabelInner>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #29
Source File: DomainsInner.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
private ServiceResponse<PageImpl1<DomainInner>> listDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PageImpl1<DomainInner>, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PageImpl1<DomainInner>>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}
 
Example #30
Source File: FileServersInner.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
private ServiceResponse<PageImpl<FileServerInner>> listByWorkspaceNextDelegate(Response<ResponseBody> response) throws CloudException, IOException, IllegalArgumentException {
    return this.client.restClient().responseBuilderFactory().<PageImpl<FileServerInner>, CloudException>newInstance(this.client.serializerAdapter())
            .register(200, new TypeToken<PageImpl<FileServerInner>>() { }.getType())
            .registerError(CloudException.class)
            .build(response);
}