From 54df845a8d8ce9e5f19e97471218a7ade49cd4f3 Mon Sep 17 00:00:00 2001 From: dragonfly91 Date: Wed, 3 Jun 2015 12:17:03 +0530 Subject: [PATCH 1/2] DownloadVaultCredentials cmdlet (testing in progress) v2 --- .../AzureBackup/AzureBackup.sln | 9 +- .../BackupServicesManagment.csproj | 36 ++- .../BackupServicesManagementClient.cs | 13 ++ .../IBackupServicesManagementClient.cs | 9 + .../Generated/IVaultCredentialOperations.cs | 56 +++++ .../Generated/JobOperations.cs | 7 +- .../Generated/Models/RawCertificateData.cs | 51 +++++ .../ResourceCertificateAndACSDetails.cs | 162 ++++++++++++++ .../Models/VaultCredUploadCertRequest.cs | 51 +++++ .../Models/VaultCredUploadCertResponse.cs | 52 +++++ .../Generated/ProtectionPolicyOperations.cs | 32 +-- .../Generated/VaultCredentialOperations.cs | 211 ++++++++++++++++++ .../VaultCredentialOperationsExtensions.cs | 85 +++++++ 13 files changed, 757 insertions(+), 17 deletions(-) create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IVaultCredentialOperations.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RawCertificateData.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/ResourceCertificateAndACSDetails.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/VaultCredUploadCertRequest.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/VaultCredUploadCertResponse.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/VaultCredentialOperations.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/VaultCredentialOperationsExtensions.cs diff --git a/src/ResourceManagement/AzureBackup/AzureBackup.sln b/src/ResourceManagement/AzureBackup/AzureBackup.sln index ee7520ab97fa7..d18505134f478 100644 --- a/src/ResourceManagement/AzureBackup/AzureBackup.sln +++ b/src/ResourceManagement/AzureBackup/AzureBackup.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackupServicesManagment", "BackupServicesManagment\BackupServicesManagment.csproj", "{38A6741C-77A3-42A8-A846-83373BE57C7F}" EndProject @@ -9,6 +9,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestDependencies", "..\..\T EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackupServices.Tests", "BackupServices.Tests\BackupServices.Tests.csproj", "{472DDC1D-318A-477C-949B-10811FDA6730}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{2C5BD9EC-5B75-46B0-B84E-29A1F1F9909D}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.Config = .nuget\NuGet.Config + .nuget\NuGet.exe = .nuget\NuGet.exe + .nuget\NuGet.targets = .nuget\NuGet.targets + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Net40-Debug|Any CPU = Net40-Debug|Any CPU diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj b/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj index 0bf19f7492966..786d1bbd96cf9 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj @@ -16,7 +16,41 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackupServicesManagementClient.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackupServicesManagementClient.cs index 543eda11deea2..9ebf641ad8318 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackupServicesManagementClient.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackupServicesManagementClient.cs @@ -122,6 +122,17 @@ public virtual IProtectionPolicyOperations ProtectionPolicy get { return this._protectionPolicy; } } + private IVaultCredentialOperations _vaultCredentials; + + /// + /// Definition of Vault credential-related operations for the Azure + /// Backup extension. + /// + public virtual IVaultCredentialOperations VaultCredentials + { + get { return this._vaultCredentials; } + } + /// /// Initializes a new instance of the BackupServicesManagementClient /// class. @@ -131,6 +142,7 @@ public BackupServicesManagementClient() { this._job = new JobOperations(this); this._protectionPolicy = new ProtectionPolicyOperations(this); + this._vaultCredentials = new VaultCredentialOperations(this); this._apiVersion = "2013-03-01"; this._longRunningOperationInitialTimeout = -1; this._longRunningOperationRetryTimeout = -1; @@ -233,6 +245,7 @@ public BackupServicesManagementClient(HttpClient httpClient) { this._job = new JobOperations(this); this._protectionPolicy = new ProtectionPolicyOperations(this); + this._vaultCredentials = new VaultCredentialOperations(this); this._apiVersion = "2013-03-01"; this._longRunningOperationInitialTimeout = -1; this._longRunningOperationRetryTimeout = -1; diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackupServicesManagementClient.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackupServicesManagementClient.cs index f16cad2f4fa9c..7763b34e435b4 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackupServicesManagementClient.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackupServicesManagementClient.cs @@ -97,5 +97,14 @@ IProtectionPolicyOperations ProtectionPolicy { get; } + + /// + /// Definition of Vault credential-related operations for the Azure + /// Backup extension. + /// + IVaultCredentialOperations VaultCredentials + { + get; + } } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IVaultCredentialOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IVaultCredentialOperations.cs new file mode 100644 index 0000000000000..d4176c626ba9e --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IVaultCredentialOperations.cs @@ -0,0 +1,56 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices +{ + /// + /// Definition of Vault credential-related operations for the Azure Backup + /// extension. + /// + public partial interface IVaultCredentialOperations + { + /// + /// Uploads vault credential certificate. + /// + /// + /// Name of the certificate. + /// + /// + /// Certificate parameters. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a certificate response. + /// + Task UploadCertificateAsync(string certificateName, VaultCredUploadCertRequest vaultCredUploadCertRequest, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/JobOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/JobOperations.cs index 2bfcce94357f5..e1d2abc912824 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/JobOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/JobOperations.cs @@ -98,7 +98,7 @@ public async Task ListAsync(JobQueryParameter parameters, Custo url = url + "/Subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { - url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId.ToString()); + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/resourceGroups/"; url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); @@ -162,7 +162,6 @@ public async Task ListAsync(JobQueryParameter parameters, Custo // Set Headers httpRequest.Headers.Add("Accept-Language", "en-us"); - httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); @@ -319,6 +318,10 @@ public async Task ListAsync(JobQueryParameter parameters, Custo } result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } if (shouldTrace) { diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RawCertificateData.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RawCertificateData.cs new file mode 100644 index 0000000000000..d0e694a4cba0d --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RawCertificateData.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// Model for raw certificate data. + /// + public partial class RawCertificateData + { + private string _certificate; + + /// + /// Optional. Gets or sets the base64 encoded certificate raw data + /// string. + /// + public string Certificate + { + get { return this._certificate; } + set { this._certificate = value; } + } + + /// + /// Initializes a new instance of the RawCertificateData class. + /// + public RawCertificateData() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/ResourceCertificateAndACSDetails.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/ResourceCertificateAndACSDetails.cs new file mode 100644 index 0000000000000..4134ade24cadb --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/ResourceCertificateAndACSDetails.cs @@ -0,0 +1,162 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The resource certificate and ACS details. + /// + public partial class ResourceCertificateAndACSDetails + { + private string _certificate; + + /// + /// Optional. Gets or sets the base64 encoded certificate raw data + /// string. + /// + public string Certificate + { + get { return this._certificate; } + set { this._certificate = value; } + } + + private string _friendlyName; + + /// + /// Optional. Certificate friendlyname. + /// + public string FriendlyName + { + get { return this._friendlyName; } + set { this._friendlyName = value; } + } + + private string _globalAcsHostName; + + /// + /// Optional. Acs mgmt host name to connect to. + /// + public string GlobalAcsHostName + { + get { return this._globalAcsHostName; } + set { this._globalAcsHostName = value; } + } + + private string _globalAcsNamespace; + + /// + /// Optional. ACS namespace name - tenant for our service. + /// + public string GlobalAcsNamespace + { + get { return this._globalAcsNamespace; } + set { this._globalAcsNamespace = value; } + } + + private string _globalAcsRPRealm; + + /// + /// Optional. Global ACS namespace RP realm. + /// + public string GlobalAcsRPRealm + { + get { return this._globalAcsRPRealm; } + set { this._globalAcsRPRealm = value; } + } + + private string _issuer; + + /// + /// Optional. Certificate issuer. + /// + public string Issuer + { + get { return this._issuer; } + set { this._issuer = value; } + } + + private long _resourceId; + + /// + /// Optional. Resource ID. + /// + public long ResourceId + { + get { return this._resourceId; } + set { this._resourceId = value; } + } + + private string _subject; + + /// + /// Optional. Certificate Subject Name. + /// + public string Subject + { + get { return this._subject; } + set { this._subject = value; } + } + + private string _thumbprint; + + /// + /// Optional. Certificate thumbrprint. + /// + public string Thumbprint + { + get { return this._thumbprint; } + set { this._thumbprint = value; } + } + + private DateTime _validFrom; + + /// + /// Optional. Certificate Validity start Date time. + /// + public DateTime ValidFrom + { + get { return this._validFrom; } + set { this._validFrom = value; } + } + + private DateTime _validTo; + + /// + /// Optional. Certificate Validity End Date time. + /// + public DateTime ValidTo + { + get { return this._validTo; } + set { this._validTo = value; } + } + + /// + /// Initializes a new instance of the ResourceCertificateAndACSDetails + /// class. + /// + public ResourceCertificateAndACSDetails() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/VaultCredUploadCertRequest.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/VaultCredUploadCertRequest.cs new file mode 100644 index 0000000000000..e1da431c7d746 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/VaultCredUploadCertRequest.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The request model for the upload vault credential certificate operation. + /// + public partial class VaultCredUploadCertRequest + { + private RawCertificateData _rawCertificateData; + + /// + /// Optional. Certificate properties. + /// + public RawCertificateData RawCertificateData + { + get { return this._rawCertificateData; } + set { this._rawCertificateData = value; } + } + + /// + /// Initializes a new instance of the VaultCredUploadCertRequest class. + /// + public VaultCredUploadCertRequest() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/VaultCredUploadCertResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/VaultCredUploadCertResponse.cs new file mode 100644 index 0000000000000..33adc469d92a7 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/VaultCredUploadCertResponse.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using Microsoft.Azure; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The definition of a certificate response. + /// + public partial class VaultCredUploadCertResponse : AzureOperationResponse + { + private ResourceCertificateAndACSDetails _resourceCertificateAndACSDetails; + + /// + /// Optional. The resource certificate and ACS details. + /// + public ResourceCertificateAndACSDetails ResourceCertificateAndACSDetails + { + get { return this._resourceCertificateAndACSDetails; } + set { this._resourceCertificateAndACSDetails = value; } + } + + /// + /// Initializes a new instance of the VaultCredUploadCertResponse class. + /// + public VaultCredUploadCertResponse() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs index 1a4a03ac890e3..4681d3e7ccf00 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs @@ -98,7 +98,7 @@ public async Task GetAsync(string jobId, CustomRequestHeaders c url = url + "/Subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { - url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId.ToString()); + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/resourceGroups/"; url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); @@ -142,7 +142,6 @@ public async Task GetAsync(string jobId, CustomRequestHeaders c // Set Headers httpRequest.Headers.Add("Accept-Language", "en-us"); - httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); @@ -352,6 +351,10 @@ public async Task GetAsync(string jobId, CustomRequestHeaders c } result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } if (shouldTrace) { @@ -408,7 +411,7 @@ public async Task ListAsync(CustomRequestHeaders c url = url + "/Subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { - url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId.ToString()); + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/resourceGroups/"; url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); @@ -448,7 +451,6 @@ public async Task ListAsync(CustomRequestHeaders c // Set Headers httpRequest.Headers.Add("Accept-Language", "en-us"); - httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); @@ -494,18 +496,18 @@ public async Task ListAsync(CustomRequestHeaders c responseDoc = JToken.Parse(responseContent); } - JToken protectionPolicyInfoResponseValue = responseDoc["ProtectionPolicyInfoResponse"]; - if (protectionPolicyInfoResponseValue != null && protectionPolicyInfoResponseValue.Type != JTokenType.Null) + if (responseDoc != null && responseDoc.Type != JTokenType.Null) { - ProtectionPolicyInfoResponse protectionPolicyInfoResponseInstance = new ProtectionPolicyInfoResponse(); + ProtectionPolicyInfoResponse protectionPoliciesInstance = new ProtectionPolicyInfoResponse(); + result.ProtectionPolicies = protectionPoliciesInstance; - JToken objectsArray = protectionPolicyInfoResponseValue["Objects"]; + JToken objectsArray = responseDoc["Objects"]; if (objectsArray != null && objectsArray.Type != JTokenType.Null) { foreach (JToken objectsValue in ((JArray)objectsArray)) { ProtectionPolicyInfo protectionPolicyInfoInstance = new ProtectionPolicyInfo(); - protectionPolicyInfoResponseInstance.Objects.Add(protectionPolicyInfoInstance); + protectionPoliciesInstance.Objects.Add(protectionPolicyInfoInstance); JToken workloadTypeValue = objectsValue["WorkloadType"]; if (workloadTypeValue != null && workloadTypeValue.Type != JTokenType.Null) @@ -604,23 +606,27 @@ public async Task ListAsync(CustomRequestHeaders c } } - JToken resultCountValue = protectionPolicyInfoResponseValue["ResultCount"]; + JToken resultCountValue = responseDoc["ResultCount"]; if (resultCountValue != null && resultCountValue.Type != JTokenType.Null) { int resultCountInstance = ((int)resultCountValue); - protectionPolicyInfoResponseInstance.ResultCount = resultCountInstance; + protectionPoliciesInstance.ResultCount = resultCountInstance; } - JToken skiptokenValue = protectionPolicyInfoResponseValue["Skiptoken"]; + JToken skiptokenValue = responseDoc["Skiptoken"]; if (skiptokenValue != null && skiptokenValue.Type != JTokenType.Null) { string skiptokenInstance = ((string)skiptokenValue); - protectionPolicyInfoResponseInstance.Skiptoken = skiptokenInstance; + protectionPoliciesInstance.Skiptoken = skiptokenInstance; } } } result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } if (shouldTrace) { diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/VaultCredentialOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/VaultCredentialOperations.cs new file mode 100644 index 0000000000000..69a0e23004530 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/VaultCredentialOperations.cs @@ -0,0 +1,211 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices +{ + /// + /// Definition of Vault credential-related operations for the Azure Backup + /// extension. + /// + internal partial class VaultCredentialOperations : IServiceOperations, IVaultCredentialOperations + { + /// + /// Initializes a new instance of the VaultCredentialOperations class. + /// + /// + /// Reference to the service client. + /// + internal VaultCredentialOperations(BackupServicesManagementClient client) + { + this._client = client; + } + + private BackupServicesManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient. + /// + public BackupServicesManagementClient Client + { + get { return this._client; } + } + + /// + /// Uploads vault credential certificate. + /// + /// + /// Optional. Name of the certificate. + /// + /// + /// Optional. Certificate parameters. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a certificate response. + /// + public async Task UploadCertificateAsync(string certificateName, VaultCredUploadCertRequest vaultCredUploadCertRequest, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("certificateName", certificateName); + tracingParameters.Add("vaultCredUploadCertRequest", vaultCredUploadCertRequest); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + TracingAdapter.Enter(invocationId, this, "UploadCertificateAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/Subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourceGroups/"; + url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); + url = url + "/providers/"; + url = url + "Microsoft.Backupseadev01"; + url = url + "/"; + url = url + "BackupVault"; + url = url + "/"; + url = url + Uri.EscapeDataString(this.Client.ResourceName); + url = url + "/certificates/"; + if (certificateName != null) + { + url = url + Uri.EscapeDataString(certificateName); + } + List queryParameters = new List(); + queryParameters.Add("api-version=2014-09-01.1.0"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Put; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + httpRequest.Headers.Add("Accept-Language", "en-us"); + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + VaultCredUploadCertResponse result = null; + // Deserialize Response + result = new VaultCredUploadCertResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/VaultCredentialOperationsExtensions.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/VaultCredentialOperationsExtensions.cs new file mode 100644 index 0000000000000..7f2f1fa69db60 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/VaultCredentialOperationsExtensions.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices +{ + public static partial class VaultCredentialOperationsExtensions + { + /// + /// Uploads vault credential certificate. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IVaultCredentialOperations. + /// + /// + /// Optional. Name of the certificate. + /// + /// + /// Optional. Certificate parameters. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a certificate response. + /// + public static VaultCredUploadCertResponse UploadCertificate(this IVaultCredentialOperations operations, string certificateName, VaultCredUploadCertRequest vaultCredUploadCertRequest, CustomRequestHeaders customRequestHeaders) + { + return Task.Factory.StartNew((object s) => + { + return ((IVaultCredentialOperations)s).UploadCertificateAsync(certificateName, vaultCredUploadCertRequest, customRequestHeaders); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Uploads vault credential certificate. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IVaultCredentialOperations. + /// + /// + /// Optional. Name of the certificate. + /// + /// + /// Optional. Certificate parameters. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// The definition of a certificate response. + /// + public static Task UploadCertificateAsync(this IVaultCredentialOperations operations, string certificateName, VaultCredUploadCertRequest vaultCredUploadCertRequest, CustomRequestHeaders customRequestHeaders) + { + return operations.UploadCertificateAsync(certificateName, vaultCredUploadCertRequest, customRequestHeaders, CancellationToken.None); + } + } +} From 8666fe29d784583c1909e54750d9cca099fb637b Mon Sep 17 00:00:00 2001 From: dragonfly91 Date: Wed, 3 Jun 2015 13:32:44 +0530 Subject: [PATCH 2/2] committing generated code. --- .../BackupServicesManagment.csproj | 53 ++- .../Generated/BackUpOperations.cs | 250 ++++++++++++++ .../Generated/BackUpOperationsExtensions.cs | 91 ++++++ .../BackupServicesManagementClient.cs | 38 +++ .../Generated/IBackUpOperations.cs | 50 +++ .../IBackupServicesManagementClient.cs | 26 ++ .../Generated/IRecoveryPointOperations.cs | 49 +++ .../Generated/JobOperations.cs | 7 +- .../Generated/Models/RecoveryPointInfo.cs | 73 +++++ .../Models/RecoveryPointInfoResponse.cs | 92 ++++++ .../Models/RecoveryPointListResponse.cs | 52 +++ .../Generated/OperationResponse.cs | 51 +++ .../Generated/ProtectionPolicyOperations.cs | 32 +- .../Generated/RecoveryPointOperations.cs | 309 ++++++++++++++++++ .../RecoveryPointOperationsExtensions.cs | 91 ++++++ 15 files changed, 1248 insertions(+), 16 deletions(-) create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperations.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperationsExtensions.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackUpOperations.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IRecoveryPointOperations.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointInfo.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointInfoResponse.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointListResponse.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/OperationResponse.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/RecoveryPointOperations.cs create mode 100644 src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/RecoveryPointOperationsExtensions.cs diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj b/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj index 0bf19f7492966..44582ac2d1845 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/BackupServicesManagment.csproj @@ -16,7 +16,58 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperations.cs new file mode 100644 index 0000000000000..62d7171f2e5c5 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperations.cs @@ -0,0 +1,250 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.BackupServices +{ + /// + /// Definition of BackUp operations for the Azure Backup extension. + /// + internal partial class BackUpOperations : IServiceOperations, IBackUpOperations + { + /// + /// Initializes a new instance of the BackUpOperations class. + /// + /// + /// Reference to the service client. + /// + internal BackUpOperations(BackupServicesManagementClient client) + { + this._client = client; + } + + private BackupServicesManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient. + /// + public BackupServicesManagementClient Client + { + get { return this._client; } + } + + /// + /// Get the list of all Protection Policy. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + public async Task TriggerBackUpAsync(CustomRequestHeaders customRequestHeaders, string containerName, string dataSourceType, string dataSourceId, CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("dataSourceType", dataSourceType); + tracingParameters.Add("dataSourceId", dataSourceId); + TracingAdapter.Enter(invocationId, this, "TriggerBackUpAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/Subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourceGroups/"; + url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); + url = url + "/providers/"; + url = url + "Microsoft.Backupseadev01"; + url = url + "/"; + url = url + "BackupVault"; + url = url + "/"; + url = url + Uri.EscapeDataString(this.Client.ResourceName); + url = url + "/containers/"; + if (containerName != null) + { + url = url + Uri.EscapeDataString(containerName); + } + url = url + "/datasources/"; + if (dataSourceType != null) + { + url = url + Uri.EscapeDataString(dataSourceType); + } + url = url + "/"; + if (dataSourceId != null) + { + url = url + Uri.EscapeDataString(dataSourceId); + } + url = url + "/backup"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-09-01.1.0"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Post; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + httpRequest.Headers.Add("Accept-Language", "en-us"); + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + OperationResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new OperationResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + JToken operationResponseValue = responseDoc["OperationResponse"]; + if (operationResponseValue != null && operationResponseValue.Type != JTokenType.Null) + { + OperationResponse operationResponseInstance = new OperationResponse(); + + JToken operationIdValue = operationResponseValue["OperationId"]; + if (operationIdValue != null && operationIdValue.Type != JTokenType.Null) + { + Guid operationIdInstance = Guid.Parse(((string)operationIdValue)); + operationResponseInstance.OperationId = operationIdInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperationsExtensions.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperationsExtensions.cs new file mode 100644 index 0000000000000..ab7efc9096ea4 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackUpOperationsExtensions.cs @@ -0,0 +1,91 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices +{ + public static partial class BackUpOperationsExtensions + { + /// + /// Get the list of all Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IBackUpOperations. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// The definition of a Operation Response. + /// + public static OperationResponse TriggerBackUp(this IBackUpOperations operations, CustomRequestHeaders customRequestHeaders, string containerName, string dataSourceType, string dataSourceId) + { + return Task.Factory.StartNew((object s) => + { + return ((IBackUpOperations)s).TriggerBackUpAsync(customRequestHeaders, containerName, dataSourceType, dataSourceId); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get the list of all Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IBackUpOperations. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// The definition of a Operation Response. + /// + public static Task TriggerBackUpAsync(this IBackUpOperations operations, CustomRequestHeaders customRequestHeaders, string containerName, string dataSourceType, string dataSourceId) + { + return operations.TriggerBackUpAsync(customRequestHeaders, containerName, dataSourceType, dataSourceId, CancellationToken.None); + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackupServicesManagementClient.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackupServicesManagementClient.cs index 543eda11deea2..de3be4ba5eb9b 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackupServicesManagementClient.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/BackupServicesManagementClient.cs @@ -100,6 +100,16 @@ public string ResourceName set { this._resourceName = value; } } + private IBackUpOperations _backUp; + + /// + /// Definition of BackUp operations for the Azure Backup extension. + /// + public virtual IBackUpOperations BackUp + { + get { return this._backUp; } + } + private IJobOperations _job; /// @@ -122,6 +132,28 @@ public virtual IProtectionPolicyOperations ProtectionPolicy get { return this._protectionPolicy; } } + private IRecoveryPointOperations _recoveryPoint; + + /// + /// Definition of Recovery Point operations for the Azure Backup + /// extension. + /// + public virtual IRecoveryPointOperations RecoveryPoint + { + get { return this._recoveryPoint; } + } + + private IVaultCredentialOperations _vaultCredentials; + + /// + /// Definition of Vault credential-related operations for the Azure + /// Backup extension. + /// + public virtual IVaultCredentialOperations VaultCredentials + { + get { return this._vaultCredentials; } + } + /// /// Initializes a new instance of the BackupServicesManagementClient /// class. @@ -129,8 +161,11 @@ public virtual IProtectionPolicyOperations ProtectionPolicy public BackupServicesManagementClient() : base() { + this._backUp = new BackUpOperations(this); this._job = new JobOperations(this); this._protectionPolicy = new ProtectionPolicyOperations(this); + this._recoveryPoint = new RecoveryPointOperations(this); + this._vaultCredentials = new VaultCredentialOperations(this); this._apiVersion = "2013-03-01"; this._longRunningOperationInitialTimeout = -1; this._longRunningOperationRetryTimeout = -1; @@ -231,8 +266,11 @@ public BackupServicesManagementClient(string resourceName, string resourceGroupN public BackupServicesManagementClient(HttpClient httpClient) : base(httpClient) { + this._backUp = new BackUpOperations(this); this._job = new JobOperations(this); this._protectionPolicy = new ProtectionPolicyOperations(this); + this._recoveryPoint = new RecoveryPointOperations(this); + this._vaultCredentials = new VaultCredentialOperations(this); this._apiVersion = "2013-03-01"; this._longRunningOperationInitialTimeout = -1; this._longRunningOperationRetryTimeout = -1; diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackUpOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackUpOperations.cs new file mode 100644 index 0000000000000..c89f0217eb4f2 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackUpOperations.cs @@ -0,0 +1,50 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices +{ + /// + /// Definition of BackUp operations for the Azure Backup extension. + /// + public partial interface IBackUpOperations + { + /// + /// Get the list of all Protection Policy. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The definition of a Operation Response. + /// + Task TriggerBackUpAsync(CustomRequestHeaders customRequestHeaders, string containerName, string dataSourceType, string dataSourceId, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackupServicesManagementClient.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackupServicesManagementClient.cs index f16cad2f4fa9c..d0da5012c6568 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackupServicesManagementClient.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IBackupServicesManagementClient.cs @@ -80,6 +80,14 @@ string ResourceName get; set; } + /// + /// Definition of BackUp operations for the Azure Backup extension. + /// + IBackUpOperations BackUp + { + get; + } + /// /// Definition of Protection Policy operations for the Azure Backup /// extension. @@ -97,5 +105,23 @@ IProtectionPolicyOperations ProtectionPolicy { get; } + + /// + /// Definition of Recovery Point operations for the Azure Backup + /// extension. + /// + IRecoveryPointOperations RecoveryPoint + { + get; + } + + /// + /// Definition of Vault credential-related operations for the Azure + /// Backup extension. + /// + IVaultCredentialOperations VaultCredentials + { + get; + } } } diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IRecoveryPointOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IRecoveryPointOperations.cs new file mode 100644 index 0000000000000..9bc0760076ecf --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/IRecoveryPointOperations.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices +{ + /// + /// Definition of Recovery Point operations for the Azure Backup extension. + /// + public partial interface IRecoveryPointOperations + { + /// + /// Get the list of all Protection Policy. + /// + /// + /// Request header parameters. + /// + /// + /// Cancellation token. + /// + /// + /// The response model for the list RecoveryPoints operation. + /// + Task ListAsync(CustomRequestHeaders customRequestHeaders, string containerName, string dataSourceType, string dataSourceId, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/JobOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/JobOperations.cs index 2bfcce94357f5..e1d2abc912824 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/JobOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/JobOperations.cs @@ -98,7 +98,7 @@ public async Task ListAsync(JobQueryParameter parameters, Custo url = url + "/Subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { - url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId.ToString()); + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/resourceGroups/"; url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); @@ -162,7 +162,6 @@ public async Task ListAsync(JobQueryParameter parameters, Custo // Set Headers httpRequest.Headers.Add("Accept-Language", "en-us"); - httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); @@ -319,6 +318,10 @@ public async Task ListAsync(JobQueryParameter parameters, Custo } result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } if (shouldTrace) { diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointInfo.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointInfo.cs new file mode 100644 index 0000000000000..090b2b9e3c62d --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointInfo.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The definition of a RecoveryPoint Info object. + /// + public partial class RecoveryPointInfo : ManagementResponseObject + { + private string _recoveryPointAdditionalInfo; + + /// + /// Optional. RecoveryPointAdditionalInfo of RecoveryPointInfo. + /// + public string RecoveryPointAdditionalInfo + { + get { return this._recoveryPointAdditionalInfo; } + set { this._recoveryPointAdditionalInfo = value; } + } + + private DateTime _recoveryPointTime; + + /// + /// Optional. RecoveryPointTime of RecoveryPointInfo. + /// + public DateTime RecoveryPointTime + { + get { return this._recoveryPointTime; } + set { this._recoveryPointTime = value; } + } + + private string _recoveryPointType; + + /// + /// Optional. RecoveryPointType of RecoveryPointInfo. + /// + public string RecoveryPointType + { + get { return this._recoveryPointType; } + set { this._recoveryPointType = value; } + } + + /// + /// Initializes a new instance of the RecoveryPointInfo class. + /// + public RecoveryPointInfo() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointInfoResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointInfoResponse.cs new file mode 100644 index 0000000000000..b20cdc586fc0b --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointInfoResponse.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using Hyak.Common; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The definition of a Recovery Point Info Response. + /// + public partial class RecoveryPointInfoResponse : ManagementBaseObject, IEnumerable + { + private IList _objects; + + /// + /// Optional. The ID of the source Server. + /// + public IList Objects + { + get { return this._objects; } + set { this._objects = value; } + } + + private int _resultCount; + + /// + /// Optional. The ID of the source Server. + /// + public int ResultCount + { + get { return this._resultCount; } + set { this._resultCount = value; } + } + + private string _skiptoken; + + /// + /// Optional. The ID of the source Server. + /// + public string Skiptoken + { + get { return this._skiptoken; } + set { this._skiptoken = value; } + } + + /// + /// Initializes a new instance of the RecoveryPointInfoResponse class. + /// + public RecoveryPointInfoResponse() + { + this.Objects = new LazyList(); + } + + /// + /// Gets the sequence of Objects. + /// + public IEnumerator GetEnumerator() + { + return this.Objects.GetEnumerator(); + } + + /// + /// Gets the sequence of Objects. + /// + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointListResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointListResponse.cs new file mode 100644 index 0000000000000..6a98291c8e79d --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/Models/RecoveryPointListResponse.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using Microsoft.Azure; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices.Models +{ + /// + /// The response model for the list RecoveryPoints operation. + /// + public partial class RecoveryPointListResponse : AzureOperationResponse + { + private RecoveryPointInfoResponse _recoveryPoints; + + /// + /// Optional. The list of RecoveryPoints for the resource id. + /// + public RecoveryPointInfoResponse RecoveryPoints + { + get { return this._recoveryPoints; } + set { this._recoveryPoints = value; } + } + + /// + /// Initializes a new instance of the RecoveryPointListResponse class. + /// + public RecoveryPointListResponse() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/OperationResponse.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/OperationResponse.cs new file mode 100644 index 0000000000000..b0ba5936db256 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/OperationResponse.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using Microsoft.Azure; + +namespace Microsoft.Azure.Management.BackupServices +{ + /// + /// The definition of a Operation Response. + /// + public partial class OperationResponse : AzureOperationResponse + { + private Guid _operationId; + + /// + /// Optional. The Objects of the JobResponse. + /// + public Guid OperationId + { + get { return this._operationId; } + set { this._operationId = value; } + } + + /// + /// Initializes a new instance of the OperationResponse class. + /// + public OperationResponse() + { + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs index 1a4a03ac890e3..4681d3e7ccf00 100644 --- a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/ProtectionPolicyOperations.cs @@ -98,7 +98,7 @@ public async Task GetAsync(string jobId, CustomRequestHeaders c url = url + "/Subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { - url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId.ToString()); + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/resourceGroups/"; url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); @@ -142,7 +142,6 @@ public async Task GetAsync(string jobId, CustomRequestHeaders c // Set Headers httpRequest.Headers.Add("Accept-Language", "en-us"); - httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); @@ -352,6 +351,10 @@ public async Task GetAsync(string jobId, CustomRequestHeaders c } result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } if (shouldTrace) { @@ -408,7 +411,7 @@ public async Task ListAsync(CustomRequestHeaders c url = url + "/Subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { - url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId.ToString()); + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/resourceGroups/"; url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); @@ -448,7 +451,6 @@ public async Task ListAsync(CustomRequestHeaders c // Set Headers httpRequest.Headers.Add("Accept-Language", "en-us"); - httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); @@ -494,18 +496,18 @@ public async Task ListAsync(CustomRequestHeaders c responseDoc = JToken.Parse(responseContent); } - JToken protectionPolicyInfoResponseValue = responseDoc["ProtectionPolicyInfoResponse"]; - if (protectionPolicyInfoResponseValue != null && protectionPolicyInfoResponseValue.Type != JTokenType.Null) + if (responseDoc != null && responseDoc.Type != JTokenType.Null) { - ProtectionPolicyInfoResponse protectionPolicyInfoResponseInstance = new ProtectionPolicyInfoResponse(); + ProtectionPolicyInfoResponse protectionPoliciesInstance = new ProtectionPolicyInfoResponse(); + result.ProtectionPolicies = protectionPoliciesInstance; - JToken objectsArray = protectionPolicyInfoResponseValue["Objects"]; + JToken objectsArray = responseDoc["Objects"]; if (objectsArray != null && objectsArray.Type != JTokenType.Null) { foreach (JToken objectsValue in ((JArray)objectsArray)) { ProtectionPolicyInfo protectionPolicyInfoInstance = new ProtectionPolicyInfo(); - protectionPolicyInfoResponseInstance.Objects.Add(protectionPolicyInfoInstance); + protectionPoliciesInstance.Objects.Add(protectionPolicyInfoInstance); JToken workloadTypeValue = objectsValue["WorkloadType"]; if (workloadTypeValue != null && workloadTypeValue.Type != JTokenType.Null) @@ -604,23 +606,27 @@ public async Task ListAsync(CustomRequestHeaders c } } - JToken resultCountValue = protectionPolicyInfoResponseValue["ResultCount"]; + JToken resultCountValue = responseDoc["ResultCount"]; if (resultCountValue != null && resultCountValue.Type != JTokenType.Null) { int resultCountInstance = ((int)resultCountValue); - protectionPolicyInfoResponseInstance.ResultCount = resultCountInstance; + protectionPoliciesInstance.ResultCount = resultCountInstance; } - JToken skiptokenValue = protectionPolicyInfoResponseValue["Skiptoken"]; + JToken skiptokenValue = responseDoc["Skiptoken"]; if (skiptokenValue != null && skiptokenValue.Type != JTokenType.Null) { string skiptokenInstance = ((string)skiptokenValue); - protectionPolicyInfoResponseInstance.Skiptoken = skiptokenInstance; + protectionPoliciesInstance.Skiptoken = skiptokenInstance; } } } result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } if (shouldTrace) { diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/RecoveryPointOperations.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/RecoveryPointOperations.cs new file mode 100644 index 0000000000000..4cefa333eaab8 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/RecoveryPointOperations.cs @@ -0,0 +1,309 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.BackupServices +{ + /// + /// Definition of Recovery Point operations for the Azure Backup extension. + /// + internal partial class RecoveryPointOperations : IServiceOperations, IRecoveryPointOperations + { + /// + /// Initializes a new instance of the RecoveryPointOperations class. + /// + /// + /// Reference to the service client. + /// + internal RecoveryPointOperations(BackupServicesManagementClient client) + { + this._client = client; + } + + private BackupServicesManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient. + /// + public BackupServicesManagementClient Client + { + get { return this._client; } + } + + /// + /// Get the list of all Protection Policy. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Cancellation token. + /// + /// + /// The response model for the list RecoveryPoints operation. + /// + public async Task ListAsync(CustomRequestHeaders customRequestHeaders, string containerName, string dataSourceType, string dataSourceId, CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("customRequestHeaders", customRequestHeaders); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("dataSourceType", dataSourceType); + tracingParameters.Add("dataSourceId", dataSourceId); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/Subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourceGroups/"; + url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); + url = url + "/providers/"; + url = url + "Microsoft.Backupseadev01"; + url = url + "/"; + url = url + "BackupVault"; + url = url + "/"; + url = url + Uri.EscapeDataString(this.Client.ResourceName); + url = url + "/containers/"; + if (containerName != null) + { + url = url + Uri.EscapeDataString(containerName); + } + url = url + "/datasources/"; + if (dataSourceType != null) + { + url = url + Uri.EscapeDataString(dataSourceType); + } + url = url + "/"; + if (dataSourceId != null) + { + url = url + Uri.EscapeDataString(dataSourceId); + } + url = url + "/recoverypoints"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-09-01.1.0"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + httpRequest.Headers.Add("Accept-Language", "en-us"); + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + RecoveryPointListResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new RecoveryPointListResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + RecoveryPointInfoResponse recoveryPointsInstance = new RecoveryPointInfoResponse(); + result.RecoveryPoints = recoveryPointsInstance; + + JToken objectsArray = responseDoc["Objects"]; + if (objectsArray != null && objectsArray.Type != JTokenType.Null) + { + foreach (JToken objectsValue in ((JArray)objectsArray)) + { + RecoveryPointInfo recoveryPointInfoInstance = new RecoveryPointInfo(); + recoveryPointsInstance.Objects.Add(recoveryPointInfoInstance); + + JToken recoveryPointTypeValue = objectsValue["RecoveryPointType"]; + if (recoveryPointTypeValue != null && recoveryPointTypeValue.Type != JTokenType.Null) + { + string recoveryPointTypeInstance = ((string)recoveryPointTypeValue); + recoveryPointInfoInstance.RecoveryPointType = recoveryPointTypeInstance; + } + + JToken recoveryPointTimeValue = objectsValue["RecoveryPointTime"]; + if (recoveryPointTimeValue != null && recoveryPointTimeValue.Type != JTokenType.Null) + { + DateTime recoveryPointTimeInstance = ((DateTime)recoveryPointTimeValue); + recoveryPointInfoInstance.RecoveryPointTime = recoveryPointTimeInstance; + } + + JToken recoveryPointAdditionalInfoValue = objectsValue["RecoveryPointAdditionalInfo"]; + if (recoveryPointAdditionalInfoValue != null && recoveryPointAdditionalInfoValue.Type != JTokenType.Null) + { + string recoveryPointAdditionalInfoInstance = ((string)recoveryPointAdditionalInfoValue); + recoveryPointInfoInstance.RecoveryPointAdditionalInfo = recoveryPointAdditionalInfoInstance; + } + + JToken instanceIdValue = objectsValue["InstanceId"]; + if (instanceIdValue != null && instanceIdValue.Type != JTokenType.Null) + { + string instanceIdInstance = ((string)instanceIdValue); + recoveryPointInfoInstance.InstanceId = instanceIdInstance; + } + + JToken nameValue = objectsValue["Name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + recoveryPointInfoInstance.Name = nameInstance; + } + + JToken operationInProgressValue = objectsValue["OperationInProgress"]; + if (operationInProgressValue != null && operationInProgressValue.Type != JTokenType.Null) + { + bool operationInProgressInstance = ((bool)operationInProgressValue); + recoveryPointInfoInstance.OperationInProgress = operationInProgressInstance; + } + } + } + + JToken resultCountValue = responseDoc["ResultCount"]; + if (resultCountValue != null && resultCountValue.Type != JTokenType.Null) + { + int resultCountInstance = ((int)resultCountValue); + recoveryPointsInstance.ResultCount = resultCountInstance; + } + + JToken skiptokenValue = responseDoc["Skiptoken"]; + if (skiptokenValue != null && skiptokenValue.Type != JTokenType.Null) + { + string skiptokenInstance = ((string)skiptokenValue); + recoveryPointsInstance.Skiptoken = skiptokenInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-client-request-id")) + { + customRequestHeaders.ClientRequestId = httpResponse.Headers.GetValues("x-ms-client-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/RecoveryPointOperationsExtensions.cs b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/RecoveryPointOperationsExtensions.cs new file mode 100644 index 0000000000000..f2ddd3c529cf0 --- /dev/null +++ b/src/ResourceManagement/AzureBackup/BackupServicesManagment/Generated/RecoveryPointOperationsExtensions.cs @@ -0,0 +1,91 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Management.BackupServices +{ + public static partial class RecoveryPointOperationsExtensions + { + /// + /// Get the list of all Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IRecoveryPointOperations. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// The response model for the list RecoveryPoints operation. + /// + public static RecoveryPointListResponse List(this IRecoveryPointOperations operations, CustomRequestHeaders customRequestHeaders, string containerName, string dataSourceType, string dataSourceId) + { + return Task.Factory.StartNew((object s) => + { + return ((IRecoveryPointOperations)s).ListAsync(customRequestHeaders, containerName, dataSourceType, dataSourceId); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get the list of all Protection Policy. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.BackupServices.IRecoveryPointOperations. + /// + /// + /// Optional. Request header parameters. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// Optional. + /// + /// + /// The response model for the list RecoveryPoints operation. + /// + public static Task ListAsync(this IRecoveryPointOperations operations, CustomRequestHeaders customRequestHeaders, string containerName, string dataSourceType, string dataSourceId) + { + return operations.ListAsync(customRequestHeaders, containerName, dataSourceType, dataSourceId, CancellationToken.None); + } + } +}