ms_rest_azure2 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +95 -0
- data/LICENSE.txt +21 -0
- data/README.md +71 -0
- data/lib/ms_rest_azure/active_directory_service_settings.rb +63 -0
- data/lib/ms_rest_azure/async_operation_status.rb +78 -0
- data/lib/ms_rest_azure/azure_cli_error.rb +12 -0
- data/lib/ms_rest_azure/azure_environment.rb +163 -0
- data/lib/ms_rest_azure/azure_operation_error.rb +40 -0
- data/lib/ms_rest_azure/azure_operation_response.rb +20 -0
- data/lib/ms_rest_azure/azure_service_client.rb +304 -0
- data/lib/ms_rest_azure/cloud_error_data.rb +48 -0
- data/lib/ms_rest_azure/common/configurable.rb +89 -0
- data/lib/ms_rest_azure/common/default.rb +57 -0
- data/lib/ms_rest_azure/credentials/application_token_provider.rb +124 -0
- data/lib/ms_rest_azure/credentials/azure_cli_token_provider.rb +97 -0
- data/lib/ms_rest_azure/credentials/cognitive_services_credentials.rb +42 -0
- data/lib/ms_rest_azure/credentials/msi_token_provider.rb +219 -0
- data/lib/ms_rest_azure/credentials/topic_credentials.rb +40 -0
- data/lib/ms_rest_azure/final_state_via.rb +16 -0
- data/lib/ms_rest_azure/polling_state.rb +139 -0
- data/lib/ms_rest_azure/serialization.rb +43 -0
- data/lib/ms_rest_azure/typed_error_info.rb +33 -0
- data/lib/ms_rest_azure/version.rb +7 -0
- data/lib/ms_rest_azure.rb +32 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d021a2b4acb7e92e648a99bf817a1558520364b6e142fcf58dec00ced50e2bf9
|
4
|
+
data.tar.gz: 66fd41214e8964f9f156d42cab47ed6252f9e28b14b278957fd11c0d70557957
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 985e2adade2c212e1455a51881eb1a180720c7a11533dca7d22ff7049d06c4658b343a0136d39d87a7125b671e9b08f6408605d096112f72ff8d2d16ea69efd7
|
7
|
+
data.tar.gz: 87be1c67067b433cf1da6a44458bb91221b46e53268f6e94d4b43ca9fdd5c9bdae9ca58027cb94500eaa13230d4b8dc6ea75df0c9c320722d3121d2ec9c1c951
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
##2020.05.21 ms_rest_azure version 0.12.0
|
2
|
+
* Unpin unf_ext dependency version.
|
3
|
+
* Update active_directory_endpoint_url in US Cloud.
|
4
|
+
|
5
|
+
##2020.03.05 ms_rest_azure version 0.11.2
|
6
|
+
* Added Azure CLI Token provider.
|
7
|
+
* Update faraday version to allow 1.0.0.
|
8
|
+
* Expose token expires properties to users.
|
9
|
+
|
10
|
+
##2019.05.14 ms_rest_azure version 0.11.1
|
11
|
+
* Set unf_ext dependency version to 0.0.7.2. This change has been done to accommodate the changes made to unf_ext. Refer [Issue #604](https://github.com/meew0/discordrb/issues/604) for further details.
|
12
|
+
* Added correlation_request_id & client_request_id to AzureOperationResponse.
|
13
|
+
|
14
|
+
##2018.07.31 ms_rest_azure version 0.11.0
|
15
|
+
* Added USER_DEFINED_IMDS_MAX_RETRY_TIME to msi_token_provider. Refer [PR #1539](https://github.com/Azure/azure-sdk-for-ruby/pull/1539) and [Issue #1344](https://github.com/Azure/azure-sdk-for-ruby/issues/1344) for further details.
|
16
|
+
* Modified Long Running Operation Logic to make final calls based on Final State Via value. Refer [PR #1537](https://github.com/Azure/azure-sdk-for-ruby/pull/1537) for further details.
|
17
|
+
|
18
|
+
##2018.06.08 ms_rest_azure version 0.10.8
|
19
|
+
* Added case insensitive comparison to Operation status.
|
20
|
+
|
21
|
+
##2018.05.16 ms_rest_azure version 0.10.7
|
22
|
+
* Added new error code 410 for IMDS Support for MSI Token Provider class.
|
23
|
+
|
24
|
+
##2018.04.16 ms_rest_azure version 0.10.6
|
25
|
+
* Added encoding of client id, object id and msi_id in the MSI Token provider class. Refer[PR #1288](https://github.com/Azure/azure-sdk-for-ruby/pull/1288) for further details.
|
26
|
+
|
27
|
+
##2018.04.16 ms_rest_azure version 0.10.5
|
28
|
+
* Added new error codes for IMDS Support for MSI Token Provider class. Refer [PR #1286](https://github.com/Azure/azure-sdk-for-ruby/pull/1286) and [Issue #1285](https://github.com/Azure/azure-sdk-for-ruby/issues/1285) for further details.
|
29
|
+
|
30
|
+
##2018.04.04 ms_rest_azure version 0.10.4
|
31
|
+
* Added IMDS Support for MSI Token Provider class. Refer [PR #1282](https://github.com/Azure/azure-sdk-for-ruby/pull/1282) for further details.
|
32
|
+
|
33
|
+
##2018.02.06 ms_rest_azure version 0.10.3
|
34
|
+
* Removed subscription_id check from configurable. Refer [PR# 1261](https://github.com/Azure/azure-sdk-for-ruby/pull/1261) for further details.
|
35
|
+
|
36
|
+
##2018.01.30 ms_rest_azure version 0.10.2
|
37
|
+
* Added CognitiveServicesCredentials class for the cognitive services data plane SDK. Refer [PR #1257](https://github.com/Azure/azure-sdk-for-ruby/pull/1257) for further details.
|
38
|
+
* Added TopicCredentials class for the event grid data plane SDK. Refer [PR #1257](https://github.com/Azure/azure-sdk-for-ruby/pull/1257) for further details.
|
39
|
+
|
40
|
+
##2017.12.19 ms_rest_azure version 0.10.1
|
41
|
+
* Added support for user assigned identity to MSITokenProvider Modified portal URLs for Azure cloud environments. Refer [Issue #1175](https://github.com/Azure/azure-sdk-for-ruby/issues/1175) for further details.
|
42
|
+
|
43
|
+
##2017.11.10 ms_rest_azure version 0.10.0
|
44
|
+
* Modified portal URLs for Azure cloud environments. Refer [PR #1106](https://github.com/Azure/azure-sdk-for-ruby/pull/1106) for further details.
|
45
|
+
* [Breaking Change] Removed Resource and SubResource classes. Refer [PR #1106](https://github.com/Azure/azure-sdk-for-ruby/pull/1106) for further details.
|
46
|
+
* Added Configurable and Default classes to be used by the profile gems. Refer [PR #1111](https://github.com/Azure/azure-sdk-for-ruby/pull/1111) for further details.
|
47
|
+
|
48
|
+
##2017.09.11 ms_rest_azure version 0.9.0
|
49
|
+
* [Breaking Change] Managed Service Identity authentication to acquire token does not require `tenant_id`.[Issue #930](https://github.com/Azure/azure-sdk-for-ruby/issues/930) [PR #931](https://github.com/Azure/azure-sdk-for-ruby/pull/931)
|
50
|
+
|
51
|
+
##2017.08.28 ms_rest_azure version 0.8.2
|
52
|
+
* Enable Managed Service Identity authentication features into ms_rest_azure runtime for azure_mgmt_* sdks.[Issue #884](https://github.com/Azure/azure-sdk-for-ruby/issues/884) [PR #889](https://github.com/Azure/azure-sdk-for-ruby/pull/889)
|
53
|
+
|
54
|
+
##2017.07.10 ms_rest_azure version 0.8.1
|
55
|
+
* [Bug Fix] Fixed the issue with the polling status object to handle the response code and provisioning status correctly.[Issue #817](https://github.com/Azure/azure-sdk-for-ruby/issues/817) [PR #828](https://github.com/Azure/azure-sdk-for-ruby/pull/828)
|
56
|
+
|
57
|
+
##2017.06.30 ms_rest_azure version 0.8.0
|
58
|
+
* [Breaking Change] Changed the name of the azure environments from 'Azure' to 'AzureCloud' and 'AzureChina' to 'AzureChinaCloud'.[Issue #600](https://github.com/Azure/azure-sdk-for-ruby/issues/600) [PR #711](https://github.com/Azure/azure-sdk-for-ruby/pull/711)
|
59
|
+
* Added 'Accept' header with the value 'application/json'.[Issue #701](https://github.com/Azure/azure-sdk-for-ruby/issues/701) [PR #710](https://github.com/Azure/azure-sdk-for-ruby/pull/710)
|
60
|
+
|
61
|
+
##2017.02.06 ms_rest_azure version 0.7.0
|
62
|
+
* [Breaking Change] Correcting typo in `storage_endpoint_suffix` key for azure environments [Issue #603](https://github.com/Azure/azure-sdk-for-ruby/issues/603) [PR #604](https://github.com/Azure/azure-sdk-for-ruby/pull/604)
|
63
|
+
* [Breaking Change] Handling custom deserialization block in `MsRestAzure::AzureServiceClient.update_state_from_azure_async_operation_header` [PR #656](https://github.com/Azure/azure-sdk-for-ruby/pull/656)
|
64
|
+
* Adding `resource_group` property on MsRestAzure::Resource to be populated with Azure resource group name when available from `id` [Issue 340](https://github.com/Azure/azure-sdk-for-ruby/issues/340) [PR #620](https://github.com/Azure/azure-sdk-for-ruby/pull/620)
|
65
|
+
* Deriving `MsREstAzure::Resource` from `MsRestAzure::SubResource` to share `id` property [PR #663](https://github.com/Azure/azure-sdk-for-ruby/pull/663)
|
66
|
+
|
67
|
+
##2016.11.14 ms_rest_azure version 0.6.2
|
68
|
+
* Update to ms_rest v0.6.2 due to fix for missing default ca-cert for providing ssl options [#580](https://github.com/Azure/azure-sdk-for-ruby/issues/580)
|
69
|
+
|
70
|
+
##2016.11.11 ms_rest_azure version 0.6.1
|
71
|
+
* Adding telemetry extension point into AzureServiceClient [#543](https://github.com/Azure/azure-sdk-for-ruby/pull/543)
|
72
|
+
* Removing explicit json dependency [#523](https://github.com/Azure/azure-sdk-for-ruby/pull/523)
|
73
|
+
|
74
|
+
##2016.10.05 ms_rest_azure version 0.6.0
|
75
|
+
* Minimum supported Ruby version is 2.0.0 [#1463](https://github.com/Azure/autorest/pull/1463)
|
76
|
+
* Implemented generic request method for AzureServiceClient [#1447](https://github.com/Azure/autorest/pull/1447)
|
77
|
+
* Improved AzureOperationError class to expose error_message and error_code properties [#1450](https://github.com/Azure/autorest/pull/1450)
|
78
|
+
|
79
|
+
##2016.09.15 ms_rest_azure version 0.5.0
|
80
|
+
* Updating ms_rest dependency to version 0.5.0
|
81
|
+
* Adding known Azure Environments in ruby runtime for easy discovery
|
82
|
+
* Default Azure active directory url is updated from `https://login.windows.net/` to `https://login.microsoftonline.com/` (Breaking Change)
|
83
|
+
* Using bundled default ca-cert from ms_rest
|
84
|
+
|
85
|
+
##2016.08.10 ms_rest_azure version 0.4.0
|
86
|
+
* Adding & inheriting serialization class from ms_rest generic serializer
|
87
|
+
|
88
|
+
##2016.07.21 ms_rest_azure version 0.3.1
|
89
|
+
* [Bug fixes](https://github.com/Azure/autorest/commit/ede944a1fa30a7453aa30e6fa79154dc43393cdf)
|
90
|
+
|
91
|
+
##2016.07.14 ms_rest_azure version 0.3.0
|
92
|
+
* Embracing latest ms_rest version [0.3.0](https://rubygems.org/gems/ms_rest)
|
93
|
+
|
94
|
+
##2016.05.19 ms_rest_azure version 0.2.3
|
95
|
+
* Support patch for long running operations. See [#1011](https://github.com/Azure/autorest/pull/1011), [#1056](https://github.com/Azure/autorest/pull/1056)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Microsoft Corporation
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Intro
|
2
|
+
|
3
|
+
MsRestAzure is a library which supports the Azure clients (SDKs) generated with Autorest tool. It contains core logic and helper classes for error handling and authentication. Also it includes azure specific logic like long polling functionality and Azure application authentication. Usually it is not supposed to be used as a standalone gem but only as a dependency for generated client gems.
|
4
|
+
|
5
|
+
# Supported Ruby Versions
|
6
|
+
|
7
|
+
* Ruby 2.0
|
8
|
+
* Ruby 2.1
|
9
|
+
* Ruby 2.2
|
10
|
+
|
11
|
+
Note: x64 Ruby for Windows is known to have some compatibility issues.
|
12
|
+
|
13
|
+
# Installation
|
14
|
+
|
15
|
+
install the appropriate gem:
|
16
|
+
|
17
|
+
```
|
18
|
+
gem install ms_rest_azure
|
19
|
+
```
|
20
|
+
|
21
|
+
and reference it in your code:
|
22
|
+
|
23
|
+
```Ruby
|
24
|
+
require 'ms_rest_azure'
|
25
|
+
```
|
26
|
+
|
27
|
+
# Running tests
|
28
|
+
|
29
|
+
MsRestAzure has only unit tests which doesn't require any preparation, just run 'rspec' command from the gem directory.
|
30
|
+
|
31
|
+
# Contribution
|
32
|
+
|
33
|
+
To start working on the gem the only additional dev dependecy is required - rspec. After you've added a new feature and all specs pass - you're good to go with PR. But before starting any bug/feature - please make sure you've thoroughly discussed it with repository maintainers. This gem already powers a few SDKs and backward compatibility should taken in account.
|
34
|
+
|
35
|
+
# Adding gem to you generated SDK
|
36
|
+
|
37
|
+
Reference it in the gemfile and also add this line to your client's gemspec file:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
spec.add_runtime_dependency 'ms_rest_azure', '~> 0.12.0'
|
41
|
+
```
|
42
|
+
Don't forget to correct the version.
|
43
|
+
|
44
|
+
# Utilizing MSI(Managed Service Identity) Token Provider
|
45
|
+
|
46
|
+
MSI support has been enabled in `ms_rest_azure` version `0.9.0`. Below code snippet demonstrates how to use MSITokenProvider with default port `50342`:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
provider = MsRestAzure::MSITokenProvider.new()
|
50
|
+
credentials = MsRest::TokenCredentials.new(provider)
|
51
|
+
```
|
52
|
+
|
53
|
+
**Note**: As of 04/04/2018, there are 2 supported ways to get MSI Token.
|
54
|
+
1. Using the extension installed locally and accessing http://localhost:50342/oauth2/token to get the MSI Token
|
55
|
+
2. Accessing the http://169.254.169.254/metadata/identity/oauth2/token to get the MSI Token (default)
|
56
|
+
|
57
|
+
Usually, you do not have to worry about the way you get the MSI token. If you would like to access the token specifically using the first approach, then set the environment variable 'MSI_VM' to true.
|
58
|
+
|
59
|
+
# Utilizing Telemetry Extension in your SDK
|
60
|
+
|
61
|
+
We encourage the customer of ms_rest_azure library to provide information about their product sent via telemetry extension point as below:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
additional_user_agent_information = 'fog-azure-rm/0.2.0' # Refer https://github.com/Azure/azure-sdk-for-ruby/issues/517 for more info.
|
65
|
+
azure_service_client.add_user_agent_information(additional_user_agent_information)
|
66
|
+
```
|
67
|
+
|
68
|
+
|
69
|
+
# Provide feedback
|
70
|
+
|
71
|
+
Send email to the azsdkteam@microsoft.com or file new issue in this repository.
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
4
|
+
|
5
|
+
module MsRestAzure
|
6
|
+
#
|
7
|
+
# Class which represents an settings for Azure AD authentication.
|
8
|
+
#
|
9
|
+
class ActiveDirectoryServiceSettings
|
10
|
+
|
11
|
+
# @return [String] auth token.
|
12
|
+
attr_accessor :authentication_endpoint
|
13
|
+
|
14
|
+
# @return [String] auth token.
|
15
|
+
attr_accessor :token_audience
|
16
|
+
|
17
|
+
#
|
18
|
+
# Returns a set of properties required to login into regular Azure cloud.
|
19
|
+
#
|
20
|
+
# @return [ActiveDirectoryServiceSettings] settings required for authentication.
|
21
|
+
def self.get_azure_settings
|
22
|
+
get_settings(MsRestAzure::AzureEnvironments::AzureCloud)
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# Returns a set of properties required to login into Azure China cloud.
|
27
|
+
#
|
28
|
+
# @return [ActiveDirectoryServiceSettings] settings required for authentication.
|
29
|
+
def self.get_azure_china_settings
|
30
|
+
get_settings(MsRestAzure::AzureEnvironments::AzureChinaCloud)
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Returns a set of properties required to login into Azure German Cloud.
|
35
|
+
#
|
36
|
+
# @return [ActiveDirectoryServiceSettings] settings required for authentication.
|
37
|
+
def self.get_azure_german_settings
|
38
|
+
get_settings(MsRestAzure::AzureEnvironments::AzureGermanCloud)
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Returns a set of properties required to login into Azure US Government.
|
43
|
+
#
|
44
|
+
# @return [ActiveDirectoryServiceSettings] settings required for authentication.
|
45
|
+
def self.get_azure_us_government_settings
|
46
|
+
get_settings(MsRestAzure::AzureEnvironments::AzureUSGovernment)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
#
|
52
|
+
# Returns a set of properties required to login into Azure Cloud.
|
53
|
+
#
|
54
|
+
# @param azure_environment [AzureEnvironment] An instance of AzureEnvironment.
|
55
|
+
# @return [ActiveDirectoryServiceSettings] settings required for authentication.
|
56
|
+
def self.get_settings(azure_environment = MsRestAzure::AzureEnvironments::Azure)
|
57
|
+
settings = ActiveDirectoryServiceSettings.new
|
58
|
+
settings.authentication_endpoint = azure_environment.active_directory_endpoint_url
|
59
|
+
settings.token_audience = azure_environment.active_directory_resource_id
|
60
|
+
settings
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
4
|
+
|
5
|
+
module MsRestAzure
|
6
|
+
#
|
7
|
+
# Defines values for AsyncOperationStatus enum.
|
8
|
+
#
|
9
|
+
class AsyncOperationStatus
|
10
|
+
ACCEPTED = 'Accepted'
|
11
|
+
IN_PROGRESS_STATUS = 'InProgress'
|
12
|
+
RUNNING = 'Running'
|
13
|
+
SUCCESS_STATUS = 'Succeeded'
|
14
|
+
FAILED_STATUS = 'Failed'
|
15
|
+
CANCELED_STATUS = 'Canceled'
|
16
|
+
|
17
|
+
ALL_STATUSES = [ACCEPTED, FAILED_STATUS, CANCELED_STATUS, SUCCESS_STATUS, IN_PROGRESS_STATUS, RUNNING]
|
18
|
+
FAILED_STATUSES = [FAILED_STATUS, CANCELED_STATUS]
|
19
|
+
TERMINAL_STATUSES = [FAILED_STATUS, CANCELED_STATUS, SUCCESS_STATUS]
|
20
|
+
|
21
|
+
DEFAULT_DELAY = 30
|
22
|
+
|
23
|
+
# @return [Integer] delay in seconds which should be used for polling for result of async operation.
|
24
|
+
attr_accessor :retry_after
|
25
|
+
|
26
|
+
# @return [MsRestAzure::CloudErrorData] error information about async operation.
|
27
|
+
attr_accessor :error
|
28
|
+
|
29
|
+
# @return [Stirng] status of polling.
|
30
|
+
attr_accessor :status
|
31
|
+
|
32
|
+
#
|
33
|
+
# Checks if given status is terminal one.
|
34
|
+
# @param status [String] status to verify
|
35
|
+
#
|
36
|
+
# @return [Boolean] True if given status is terminal one, false otherwise.
|
37
|
+
def self.is_terminal_status(status)
|
38
|
+
TERMINAL_STATUSES.any? { |st| st.casecmp(status) == 0 }
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# Checks if given status is failed one.
|
43
|
+
# @param status [String] status to verify
|
44
|
+
#
|
45
|
+
# @return [Boolean] True if given status is failed one, false otherwise.
|
46
|
+
def self.is_failed_status(status)
|
47
|
+
FAILED_STATUSES.any? { |st| st.casecmp(status) == 0 }
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Checks if given status is successful one.
|
52
|
+
# @param status [String] status to verify
|
53
|
+
#
|
54
|
+
# @return [Boolean] True if given status is successful one, false otherwise.
|
55
|
+
def self.is_successful_status(status)
|
56
|
+
return (status.casecmp(SUCCESS_STATUS) == 0)
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Deserializes given hash into AsyncOperationStatus object.
|
61
|
+
# @param object [Hash] object to deserialize.
|
62
|
+
#
|
63
|
+
# @return [AsyncOperationStatus] deserialized object.
|
64
|
+
def self.deserialize_object(object)
|
65
|
+
return if object.nil?
|
66
|
+
output_object = AsyncOperationStatus.new
|
67
|
+
|
68
|
+
output_object.status = object['status']
|
69
|
+
|
70
|
+
output_object.error = CloudErrorData.deserialize_object(object['error'])
|
71
|
+
|
72
|
+
output_object.retry_after = Integer(object['retryAfter']) unless object['retryAfter'].nil?
|
73
|
+
|
74
|
+
output_object
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
4
|
+
|
5
|
+
module MsRestAzure
|
6
|
+
#
|
7
|
+
# Class which represents an error with the Azure CLI.
|
8
|
+
#
|
9
|
+
class AzureCliError < StandardError
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
4
|
+
|
5
|
+
module MsRestAzure
|
6
|
+
module AzureEnvironments
|
7
|
+
#
|
8
|
+
# An instance of this class describes an environment in Azure
|
9
|
+
#
|
10
|
+
class AzureEnvironment
|
11
|
+
|
12
|
+
# @return [String] the Environment name
|
13
|
+
attr_reader :name
|
14
|
+
|
15
|
+
# @return [String] the management portal URL
|
16
|
+
attr_reader :portal_url
|
17
|
+
|
18
|
+
# @return [String] the publish settings file URL
|
19
|
+
attr_reader :publishing_profile_url
|
20
|
+
|
21
|
+
# @return [String] the management service endpoint
|
22
|
+
attr_reader :management_endpoint_url
|
23
|
+
|
24
|
+
# @return [String] the resource management endpoint
|
25
|
+
attr_reader :resource_manager_endpoint_url
|
26
|
+
|
27
|
+
# @return [String] the sql server management endpoint for mobile commands
|
28
|
+
attr_reader :sql_management_endpoint_url
|
29
|
+
|
30
|
+
# @return [String] the dns suffix for sql servers
|
31
|
+
attr_reader :sql_server_hostname_suffix
|
32
|
+
|
33
|
+
# @return [String] the template gallery endpoint
|
34
|
+
attr_reader :gallery_endpoint_url
|
35
|
+
|
36
|
+
# @return [String] the Active Directory login endpoint
|
37
|
+
attr_reader :active_directory_endpoint_url
|
38
|
+
|
39
|
+
# @return [String] the resource ID to obtain AD tokens for
|
40
|
+
attr_reader :active_directory_resource_id
|
41
|
+
|
42
|
+
# @return [String] the Active Directory resource ID
|
43
|
+
attr_reader :active_directory_graph_resource_id
|
44
|
+
|
45
|
+
# @return [String] the Active Directory resource ID
|
46
|
+
attr_reader :active_directory_graph_api_version
|
47
|
+
|
48
|
+
# @return [String] the endpoint suffix for storage accounts
|
49
|
+
attr_reader :storage_endpoint_suffix
|
50
|
+
|
51
|
+
# @return [String] the KeyVault service dns suffix
|
52
|
+
attr_reader :key_vault_dns_suffix
|
53
|
+
|
54
|
+
# @return [String] the data lake store filesystem service dns suffix
|
55
|
+
attr_reader :datalake_store_filesystem_endpoint_suffix
|
56
|
+
|
57
|
+
# @return [String] the data lake analytics job and catalog service dns suffix
|
58
|
+
attr_reader :datalake_analytics_catalog_and_job_endpoint_suffix
|
59
|
+
|
60
|
+
# @return [Boolean] determines whether the authentication endpoint should be validated with Azure AD. Default value is true.
|
61
|
+
attr_reader :validate_authority
|
62
|
+
|
63
|
+
def initialize(options)
|
64
|
+
required_properties = [:name, :portal_url, :management_endpoint_url, :resource_manager_endpoint_url, :active_directory_endpoint_url, :active_directory_resource_id]
|
65
|
+
|
66
|
+
required_supplied_properties = required_properties & options.keys
|
67
|
+
|
68
|
+
if required_supplied_properties.nil? || required_supplied_properties.empty? || (required_supplied_properties & required_properties) != required_properties
|
69
|
+
raise ArgumentError.new("#{required_properties.to_s} are the required properties but provided properties are #{options.to_s}")
|
70
|
+
end
|
71
|
+
|
72
|
+
required_supplied_properties.each do |prop|
|
73
|
+
if options[prop].nil? || !options[prop].is_a?(String) || options[prop].empty?
|
74
|
+
raise ArgumentError.new("Value of the '#{prop}' property must be of type String and non empty.")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Setting default to true
|
79
|
+
@validate_authority = true
|
80
|
+
|
81
|
+
options.each do |k, v|
|
82
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
AzureCloud = AzureEnvironments::AzureEnvironment.new({
|
88
|
+
:name => 'AzureCloud',
|
89
|
+
:portal_url => 'https://portal.azure.com',
|
90
|
+
:publishing_profile_url => 'http://go.microsoft.com/fwlink/?LinkId=254432',
|
91
|
+
:management_endpoint_url => 'https://management.core.windows.net',
|
92
|
+
:resource_manager_endpoint_url => 'https://management.azure.com/',
|
93
|
+
:sql_management_endpoint_url => 'https://management.core.windows.net:8443/',
|
94
|
+
:sql_server_hostname_suffix => '.database.windows.net',
|
95
|
+
:gallery_endpoint_url => 'https://gallery.azure.com/',
|
96
|
+
:active_directory_endpoint_url => 'https://login.microsoftonline.com/',
|
97
|
+
:active_directory_resource_id => 'https://management.core.windows.net/',
|
98
|
+
:active_directory_graph_resource_id => 'https://graph.windows.net/',
|
99
|
+
:active_directory_graph_api_version => '2013-04-05',
|
100
|
+
:storage_endpoint_suffix => '.core.windows.net',
|
101
|
+
:key_vault_dns_suffix => '.vault.azure.net',
|
102
|
+
:datalake_store_filesystem_endpoint_suffix => 'azuredatalakestore.net',
|
103
|
+
:datalake_analytics_catalog_and_job_endpoint_suffix => 'azuredatalakeanalytics.net'
|
104
|
+
})
|
105
|
+
AzureChinaCloud = AzureEnvironments::AzureEnvironment.new({
|
106
|
+
:name => 'AzureChinaCloud',
|
107
|
+
:portal_url => 'https://portal.azure.cn',
|
108
|
+
:publishing_profile_url => 'http://go.microsoft.com/fwlink/?LinkID=301774',
|
109
|
+
:management_endpoint_url => 'https://management.core.chinacloudapi.cn',
|
110
|
+
:resource_manager_endpoint_url => 'https://management.chinacloudapi.cn',
|
111
|
+
:sql_management_endpoint_url => 'https://management.core.chinacloudapi.cn:8443/',
|
112
|
+
:sql_server_hostname_suffix => '.database.chinacloudapi.cn',
|
113
|
+
:gallery_endpoint_url => 'https://gallery.chinacloudapi.cn/',
|
114
|
+
:active_directory_endpoint_url => 'https://login.chinacloudapi.cn/',
|
115
|
+
:active_directory_resource_id => 'https://management.core.chinacloudapi.cn/',
|
116
|
+
:active_directory_graph_resource_id => 'https://graph.chinacloudapi.cn/',
|
117
|
+
:active_directory_graph_api_version => '2013-04-05',
|
118
|
+
:storage_endpoint_suffix => '.core.chinacloudapi.cn',
|
119
|
+
:key_vault_dns_suffix => '.vault.azure.cn',
|
120
|
+
# TODO: add dns suffixes for the china cloud for datalake store and datalake analytics once they are defined.
|
121
|
+
:datalake_store_filesystem_endpoint_suffix => 'N/A',
|
122
|
+
:datalake_analytics_catalog_and_job_endpoint_suffix => 'N/A'
|
123
|
+
})
|
124
|
+
AzureUSGovernment = AzureEnvironments::AzureEnvironment.new({
|
125
|
+
:name => 'AzureUSGovernment',
|
126
|
+
:portal_url => 'https://portal.azure.us',
|
127
|
+
:publishing_profile_url => 'https://manage.windowsazure.us/publishsettings/index',
|
128
|
+
:management_endpoint_url => 'https://management.core.usgovcloudapi.net',
|
129
|
+
:resource_manager_endpoint_url => 'https://management.usgovcloudapi.net',
|
130
|
+
:sql_management_endpoint_url => 'https://management.core.usgovcloudapi.net:8443/',
|
131
|
+
:sql_server_hostname_suffix => '.database.usgovcloudapi.net',
|
132
|
+
:gallery_endpoint_url => 'https://gallery.usgovcloudapi.net/',
|
133
|
+
:active_directory_endpoint_url => 'https://login.microsoftonline.us/',
|
134
|
+
:active_directory_resource_id => 'https://management.core.usgovcloudapi.net/',
|
135
|
+
:active_directory_graph_resource_id => 'https://graph.windows.net/',
|
136
|
+
:active_directory_graph_api_version => '2013-04-05',
|
137
|
+
:storage_endpoint_suffix => '.core.usgovcloudapi.net',
|
138
|
+
:key_vault_dns_suffix => '.vault.usgovcloudapi.net',
|
139
|
+
# TODO: add dns suffixes for the US government for datalake store and datalake analytics once they are defined.
|
140
|
+
:datalake_store_filesystem_endpoint_suffix => 'N/A',
|
141
|
+
:datalake_analytics_catalog_and_job_endpoint_suffix => 'N/A'
|
142
|
+
})
|
143
|
+
AzureGermanCloud = AzureEnvironments::AzureEnvironment.new({
|
144
|
+
:name => 'AzureGermanCloud',
|
145
|
+
:portal_url => 'http://portal.microsoftazure.de/',
|
146
|
+
:publishing_profile_url => 'https://manage.microsoftazure.de/publishsettings/index',
|
147
|
+
:management_endpoint_url => 'https://management.core.cloudapi.de',
|
148
|
+
:resource_manager_endpoint_url => 'https://management.microsoftazure.de',
|
149
|
+
:sql_management_endpoint_url => 'https://management.core.cloudapi.de:8443/',
|
150
|
+
:sql_server_hostname_suffix => '.database.cloudapi.de',
|
151
|
+
:gallery_endpoint_url => 'https://gallery.cloudapi.de/',
|
152
|
+
:active_directory_endpoint_url => 'https://login.microsoftonline.de/',
|
153
|
+
:active_directory_resource_id => 'https://management.core.cloudapi.de/',
|
154
|
+
:active_directory_graph_resource_id => 'https://graph.cloudapi.de/',
|
155
|
+
:active_directory_graph_api_version => '2013-04-05',
|
156
|
+
:storage_endpoint_suffix => '.core.cloudapi.de',
|
157
|
+
:key_vault_dns_suffix => '.vault.microsoftazure.de',
|
158
|
+
# TODO: add dns suffixes for the US government for datalake store and datalake analytics once they are defined.
|
159
|
+
:datalake_store_filesystem_endpoint_suffix => 'N/A',
|
160
|
+
:datalake_analytics_catalog_and_job_endpoint_suffix => 'N/A'
|
161
|
+
})
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
4
|
+
|
5
|
+
module MsRestAzure
|
6
|
+
#
|
7
|
+
# Class which represents an Azure error.
|
8
|
+
#
|
9
|
+
class AzureOperationError < MsRest::HttpOperationError
|
10
|
+
|
11
|
+
# @return [String] the error message.
|
12
|
+
attr_accessor :error_message
|
13
|
+
|
14
|
+
# @return [String] the error code.
|
15
|
+
attr_accessor :error_code
|
16
|
+
|
17
|
+
#
|
18
|
+
# Creates and initialize new instance of the AzureOperationError class.
|
19
|
+
# @param [Hash] the HTTP request data (uri, body, headers).
|
20
|
+
# @param [Faraday::Response] the HTTP response object.
|
21
|
+
# @param [String] body the HTTP response body.
|
22
|
+
# @param [String] error message.
|
23
|
+
#
|
24
|
+
def initialize(*args)
|
25
|
+
super(*args)
|
26
|
+
|
27
|
+
# Try to parse @body to find useful error message and code
|
28
|
+
# Body should meet the error condition response requirements for Microsoft REST API Guidelines
|
29
|
+
# https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md#7102-error-condition-responses
|
30
|
+
begin
|
31
|
+
unless @body.nil?
|
32
|
+
@error_message = @body['error']['message']
|
33
|
+
@error_code = @body['error']['code']
|
34
|
+
@msg = "#{@msg}: #{@error_code}: #{@error_message}"
|
35
|
+
end
|
36
|
+
rescue
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
|
+
# Licensed under the MIT License. See License.txt in the project root for license information.
|
4
|
+
|
5
|
+
module MsRestAzure
|
6
|
+
#
|
7
|
+
# Class which represents the data received and deserialized from Azure service.
|
8
|
+
#
|
9
|
+
class AzureOperationResponse < MsRest::HttpOperationResponse
|
10
|
+
|
11
|
+
# @return [String] identificator of the request.
|
12
|
+
attr_accessor :request_id
|
13
|
+
|
14
|
+
# @return [String] Correlation Id of the request.
|
15
|
+
attr_accessor :correlation_request_id
|
16
|
+
|
17
|
+
# @return [String] Client Request Id of the request.
|
18
|
+
attr_accessor :client_request_id
|
19
|
+
end
|
20
|
+
end
|