public void TestLifecycleGroup() { Uri addressBase = new Uri(WebServiceUnitTest.AddressBase); IMonitor monitor = new ConsoleMonitor(); IAmazonWebServicesIdentityAnchoringBehavior anchoringBehavior = new AnchoringByIdentifierBehavior(); AmazonWebServicesProviderBase provider = new AmazonWebServicesProvider(WebServiceUnitTest.CredentialsProfileName, anchoringBehavior); Service webService = null; try { webService = new WebService(monitor, provider); webService.Start(addressBase); string identifierGroup; string identifierGroupExternal; string identifierMemberOne; string identifierMemberTwo; Uri resource; WebClient client = null; try { IDictionary<string, object> json; string characters; byte[] bytes; byte[] response; string responseCharacters; IReadOnlyDictionary<string, object> responseJson; Core2EnterpriseUser user; Member member; IReadOnlyCollection<Member> members; client = new WebClient(); identifierMemberOne = Guid.NewGuid().ToString(); string identifierMemberOneExternal = Guid.NewGuid().ToString(); user = new Core2EnterpriseUser() { Identifier = identifierMemberOne, ExternalIdentifier = identifierMemberOneExternal }; json = user.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes); responseCharacters = Encoding.UTF8.GetString(response); responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson); identifierMemberOne = user.Identifier; try { member = new Member() { Value = identifierMemberOne }; members = new Member[] { member }; identifierGroup = Guid.NewGuid().ToString(); identifierGroupExternal = Guid.NewGuid().ToString(); WindowsAzureActiveDirectoryGroup group = new WindowsAzureActiveDirectoryGroup() { Identifier = identifierGroup, ExternalIdentifier = identifierGroupExternal, Members = members }; json = group.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeGroups); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes); responseCharacters = Encoding.UTF8.GetString(response); responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); group = new WindowsAzureActiveDirectoryGroupJsonDeserializingFactory().Create(responseJson); Assert.IsNotNull(group); Assert.IsNotNull( group .Schemas .SingleOrDefault( (string item) => string.Equals( SchemaIdentifiers.WindowsAzureActiveDirectoryGroup, item, StringComparison.Ordinal))); Assert.IsFalse(string.IsNullOrWhiteSpace(group.Identifier)); string identifierGroupAmazon = group.Identifier; try { Assert.IsNotNull(group.Metadata); Assert.IsFalse(string.IsNullOrWhiteSpace(group.Metadata.ResourceType)); Assert.IsFalse(string.Equals(identifierGroup, identifierGroupAmazon, StringComparison.OrdinalIgnoreCase)); string resourcePath = string.Format( CultureInfo.InvariantCulture, WebServiceUnitTest.AddressRelativeGroupTemplate, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); response = client.DownloadData(resource); responseCharacters = Encoding.UTF8.GetString(response); responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); group = new WindowsAzureActiveDirectoryGroupJsonDeserializingFactory().Create(responseJson); Assert.IsNotNull(group); Assert.IsNotNull( group .Schemas .SingleOrDefault( (string item) => string.Equals( SchemaIdentifiers.Core2Group, item, StringComparison.Ordinal))); Assert.IsFalse(string.IsNullOrWhiteSpace(group.Identifier)); Assert.IsTrue(string.Equals(group.Identifier, identifierGroupAmazon, StringComparison.OrdinalIgnoreCase)); Assert.IsFalse(string.IsNullOrWhiteSpace(group.ExternalIdentifier)); Assert.IsTrue(string.Equals(group.ExternalIdentifier, identifierGroupExternal, StringComparison.OrdinalIgnoreCase)); identifierMemberTwo = Guid.NewGuid().ToString(); string identifierMemberTwoExternal = Guid.NewGuid().ToString(); user = new Core2EnterpriseUser() { Identifier = identifierMemberTwo, ExternalIdentifier = identifierMemberTwoExternal }; json = user.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes); responseCharacters = Encoding.UTF8.GetString(response); responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson); identifierMemberTwo = user.Identifier; try { IResourceIdentifier resourceIdentifier = new ResourceIdentifier() { Identifier = identifierGroupAmazon, SchemaIdentifier = SchemaIdentifiers.WindowsAzureActiveDirectoryGroup }; IPath path = Microsoft.SystemForCrossDomainIdentityManagement.Path.Create(AttributeNames.Members); OperationValue operationValue; PatchOperation operation; IReadOnlyCollection<PatchOperation> operations; PatchRequest2 patch; operationValue = new OperationValue() { Value = identifierMemberTwo }; operation = new PatchOperation() { Name = OperationName.Add, Path = path }; operations = new PatchOperation[] { operation }; operation.AddValue(operationValue); patch = new PatchRequest2(); patch.AddOperation(operation); json = patch.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebServiceUnitTest.MethodPatch, bytes); operationValue = new OperationValue() { Value = identifierMemberTwo }; operation = new PatchOperation() { Name = OperationName.Remove, Path = path }; operations = new PatchOperation[] { operation }; operation.AddValue(operationValue); patch = new PatchRequest2(); patch.AddOperation(operation); json = patch.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebServiceUnitTest.MethodPatch, bytes); operationValue = new OperationValue() { Value = identifierMemberOne }; operation = new PatchOperation() { Name = OperationName.Remove, Path = path }; operations = new PatchOperation[] { operation }; operation.AddValue(operationValue); patch = new PatchRequest2(); patch.AddOperation(operation); json = patch.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebServiceUnitTest.MethodPatch, bytes); } finally { resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, identifierMemberTwo); resource = new Uri(addressBase, resourcePath); bytes = new byte[0]; client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes); } } finally { string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); bytes = new byte[0]; client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes); } } finally { string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, identifierMemberOne); resource = new Uri(addressBase, resourcePath); bytes = new byte[0]; client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes); } } finally { if (client != null) { client.Dispose(); client = null; } } } finally { if (webService != null) { webService.Dispose(); webService = null; } } }
internal static ImportExportExtensionsOperationResult DeserializeImportExportExtensionsOperationResult(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; Optional <Guid> requestId = default; Optional <string> requestType = default; Optional <string> lastModifiedTime = default; Optional <string> serverName = default; Optional <string> databaseName = default; Optional <string> status = default; Optional <string> errorMessage = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("requestId")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } requestId = property0.Value.GetGuid(); continue; } if (property0.NameEquals("requestType")) { requestType = property0.Value.GetString(); continue; } if (property0.NameEquals("lastModifiedTime")) { lastModifiedTime = property0.Value.GetString(); continue; } if (property0.NameEquals("serverName")) { serverName = property0.Value.GetString(); continue; } if (property0.NameEquals("databaseName")) { databaseName = property0.Value.GetString(); continue; } if (property0.NameEquals("status")) { status = property0.Value.GetString(); continue; } if (property0.NameEquals("errorMessage")) { errorMessage = property0.Value.GetString(); continue; } } continue; } } return(new ImportExportExtensionsOperationResult(id, name, type, Optional.ToNullable(requestId), requestType.Value, lastModifiedTime.Value, serverName.Value, databaseName.Value, status.Value, errorMessage.Value)); }
internal PrivateEndpointConnection(ArmClientOptions clientOptions, TokenCredential credential, Uri uri, HttpPipeline pipeline, ResourceIdentifier id) : base(clientOptions, credential, uri, pipeline, id) { _clientDiagnostics = new ClientDiagnostics(ClientOptions); _diskAccessesRestClient = new DiskAccessesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); #if DEBUG ValidateResourceId(Id); #endif }
internal ServerConnectionPolicyData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, string location, string kind, ServerConnectionType?connectionType) : base(id, name, type, systemData) { Location = location; Kind = kind; ConnectionType = connectionType; }
internal EnvironmentContainerData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, EnvironmentContainerProperties properties) : base(id, name, resourceType, systemData) { Properties = properties; }
internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != DisasterRecovery.ResourceType) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, DisasterRecovery.ResourceType), nameof(id)); }
internal FlowLog(ArmResource options, ResourceIdentifier id) : base(options, id) { _clientDiagnostics = new ClientDiagnostics(ClientOptions); _restClient = new FlowLogsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri); }
internal AfdOrigin(ArmClientOptions clientOptions, TokenCredential credential, Uri uri, HttpPipeline pipeline, ResourceIdentifier id) : base(clientOptions, credential, uri, pipeline, id) { _clientDiagnostics = new ClientDiagnostics(ClientOptions); _afdOriginsRestClient = new AfdOriginsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); #if DEBUG ValidateResourceId(Id); #endif }
internal static PrivateEndpointConnectionData DeserializePrivateEndpointConnectionData(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; Optional <PrivateEndpoint> privateEndpoint = default; Optional <PrivateLinkServiceConnectionState> privateLinkServiceConnectionState = default; Optional <PrivateEndpointConnectionProvisioningState> provisioningState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("privateEndpoint")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } privateEndpoint = PrivateEndpoint.DeserializePrivateEndpoint(property0.Value); continue; } if (property0.NameEquals("privateLinkServiceConnectionState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } privateLinkServiceConnectionState = PrivateLinkServiceConnectionState.DeserializePrivateLinkServiceConnectionState(property0.Value); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new PrivateEndpointConnectionProvisioningState(property0.Value.GetString()); continue; } } continue; } } return(new PrivateEndpointConnectionData(id, name, type, privateEndpoint.Value, privateLinkServiceConnectionState.Value, Optional.ToNullable(provisioningState))); }
internal static PrivateAccessData DeserializePrivateAccessData(JsonElement element) { Optional <string> kind = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <bool> enabled = default; Optional <IList <PrivateAccessVirtualNetwork> > virtualNetworks = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("kind")) { kind = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("enabled")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } enabled = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("virtualNetworks")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <PrivateAccessVirtualNetwork> array = new List <PrivateAccessVirtualNetwork>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(PrivateAccessVirtualNetwork.DeserializePrivateAccessVirtualNetwork(item)); } virtualNetworks = array; continue; } } continue; } } return(new PrivateAccessData(id, name, type, systemData, kind.Value, Optional.ToNullable(enabled), Optional.ToList(virtualNetworks))); }
internal static ManagementGroupData DeserializeManagementGroup(JsonElement element) { Optional <ResourceIdentifier> id = default; Optional <string> type = default; Optional <string> name = default; Optional <string> tenantId = default; Optional <string> displayName = default; Optional <ManagementGroupDetails> details = default; Optional <IReadOnlyList <ManagementGroupChildInfo> > children = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("tenantId")) { tenantId = property0.Value.GetString(); continue; } if (property0.NameEquals("displayName")) { displayName = property0.Value.GetString(); continue; } if (property0.NameEquals("details")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } details = ManagementGroupDetails.DeserializeManagementGroupDetails(property0.Value); continue; } if (property0.NameEquals("children")) { if (property0.Value.ValueKind == JsonValueKind.Null) { children = null; continue; } List <ManagementGroupChildInfo> array = new List <ManagementGroupChildInfo>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ManagementGroupChildInfo.DeserializeManagementGroupChildInfo(item)); } children = array; continue; } } continue; } } return(new ManagementGroupData(id.Value, type.Value, name.Value, tenantId.Value, displayName.Value, details.Value, Optional.ToList(children))); }
internal static StorageAccountData DeserializeStorageAccountData(JsonElement element) { Optional <Models.Sku> sku = default; Optional <Kind> kind = default; Optional <ManagedServiceIdentity> identity = default; Optional <ExtendedLocation> extendedLocation = default; IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <ProvisioningState> provisioningState = default; Optional <Endpoints> primaryEndpoints = default; Optional <string> primaryLocation = default; Optional <AccountStatus> statusOfPrimary = default; Optional <DateTimeOffset> lastGeoFailoverTime = default; Optional <string> secondaryLocation = default; Optional <AccountStatus> statusOfSecondary = default; Optional <DateTimeOffset> creationTime = default; Optional <CustomDomain> customDomain = default; Optional <SasPolicy> sasPolicy = default; Optional <KeyPolicy> keyPolicy = default; Optional <KeyCreationTime> keyCreationTime = default; Optional <Endpoints> secondaryEndpoints = default; Optional <Encryption> encryption = default; Optional <AccessTier> accessTier = default; Optional <AzureFilesIdentityBasedAuthentication> azureFilesIdentityBasedAuthentication = default; Optional <bool> supportsHttpsTrafficOnly = default; Optional <NetworkRuleSet> networkAcls = default; Optional <bool> isSftpEnabled = default; Optional <bool> isLocalUserEnabled = default; Optional <bool> isHnsEnabled = default; Optional <GeoReplicationStats> geoReplicationStats = default; Optional <bool> failoverInProgress = default; Optional <LargeFileSharesState> largeFileSharesState = default; Optional <IReadOnlyList <PrivateEndpointConnectionData> > privateEndpointConnections = default; Optional <RoutingPreference> routingPreference = default; Optional <BlobRestoreStatus> blobRestoreStatus = default; Optional <bool> allowBlobPublicAccess = default; Optional <MinimumTlsVersion> minimumTlsVersion = default; Optional <bool> allowSharedKeyAccess = default; Optional <bool> isNfsV3Enabled = default; Optional <bool> allowCrossTenantReplication = default; Optional <bool> defaultToOAuthAuthentication = default; Optional <PublicNetworkAccess> publicNetworkAccess = default; Optional <ImmutableStorageAccount> immutableStorageWithVersioning = default; Optional <AllowedCopyScope> allowedCopyScope = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sku")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } sku = Models.Sku.DeserializeSku(property.Value); continue; } if (property.NameEquals("kind")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } kind = new Kind(property.Value.GetString()); continue; } if (property.NameEquals("identity")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } identity = JsonSerializer.Deserialize <ManagedServiceIdentity>(property.Value.ToString()); continue; } if (property.NameEquals("extendedLocation")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value); continue; } if (property.NameEquals("tags")) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = property0.Value.GetString().ToProvisioningState(); continue; } if (property0.NameEquals("primaryEndpoints")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } primaryEndpoints = Endpoints.DeserializeEndpoints(property0.Value); continue; } if (property0.NameEquals("primaryLocation")) { primaryLocation = property0.Value.GetString(); continue; } if (property0.NameEquals("statusOfPrimary")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } statusOfPrimary = property0.Value.GetString().ToAccountStatus(); continue; } if (property0.NameEquals("lastGeoFailoverTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } lastGeoFailoverTime = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("secondaryLocation")) { secondaryLocation = property0.Value.GetString(); continue; } if (property0.NameEquals("statusOfSecondary")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } statusOfSecondary = property0.Value.GetString().ToAccountStatus(); continue; } if (property0.NameEquals("creationTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } creationTime = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("customDomain")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } customDomain = CustomDomain.DeserializeCustomDomain(property0.Value); continue; } if (property0.NameEquals("sasPolicy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } sasPolicy = SasPolicy.DeserializeSasPolicy(property0.Value); continue; } if (property0.NameEquals("keyPolicy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } keyPolicy = KeyPolicy.DeserializeKeyPolicy(property0.Value); continue; } if (property0.NameEquals("keyCreationTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } keyCreationTime = KeyCreationTime.DeserializeKeyCreationTime(property0.Value); continue; } if (property0.NameEquals("secondaryEndpoints")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } secondaryEndpoints = Endpoints.DeserializeEndpoints(property0.Value); continue; } if (property0.NameEquals("encryption")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } encryption = Encryption.DeserializeEncryption(property0.Value); continue; } if (property0.NameEquals("accessTier")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } accessTier = property0.Value.GetString().ToAccessTier(); continue; } if (property0.NameEquals("azureFilesIdentityBasedAuthentication")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } azureFilesIdentityBasedAuthentication = AzureFilesIdentityBasedAuthentication.DeserializeAzureFilesIdentityBasedAuthentication(property0.Value); continue; } if (property0.NameEquals("supportsHttpsTrafficOnly")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } supportsHttpsTrafficOnly = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("networkAcls")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } networkAcls = NetworkRuleSet.DeserializeNetworkRuleSet(property0.Value); continue; } if (property0.NameEquals("isSftpEnabled")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } isSftpEnabled = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("isLocalUserEnabled")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } isLocalUserEnabled = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("isHnsEnabled")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } isHnsEnabled = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("geoReplicationStats")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } geoReplicationStats = GeoReplicationStats.DeserializeGeoReplicationStats(property0.Value); continue; } if (property0.NameEquals("failoverInProgress")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } failoverInProgress = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("largeFileSharesState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } largeFileSharesState = new LargeFileSharesState(property0.Value.GetString()); continue; } if (property0.NameEquals("privateEndpointConnections")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <PrivateEndpointConnectionData> array = new List <PrivateEndpointConnectionData>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(PrivateEndpointConnectionData.DeserializePrivateEndpointConnectionData(item)); } privateEndpointConnections = array; continue; } if (property0.NameEquals("routingPreference")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } routingPreference = RoutingPreference.DeserializeRoutingPreference(property0.Value); continue; } if (property0.NameEquals("blobRestoreStatus")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } blobRestoreStatus = BlobRestoreStatus.DeserializeBlobRestoreStatus(property0.Value); continue; } if (property0.NameEquals("allowBlobPublicAccess")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } allowBlobPublicAccess = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("minimumTlsVersion")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } minimumTlsVersion = new MinimumTlsVersion(property0.Value.GetString()); continue; } if (property0.NameEquals("allowSharedKeyAccess")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } allowSharedKeyAccess = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("isNfsV3Enabled")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } isNfsV3Enabled = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("allowCrossTenantReplication")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } allowCrossTenantReplication = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("defaultToOAuthAuthentication")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } defaultToOAuthAuthentication = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("publicNetworkAccess")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } publicNetworkAccess = new PublicNetworkAccess(property0.Value.GetString()); continue; } if (property0.NameEquals("immutableStorageWithVersioning")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } immutableStorageWithVersioning = ImmutableStorageAccount.DeserializeImmutableStorageAccount(property0.Value); continue; } if (property0.NameEquals("allowedCopyScope")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } allowedCopyScope = new AllowedCopyScope(property0.Value.GetString()); continue; } } continue; } } return(new StorageAccountData(id, name, type, systemData, tags, location, sku.Value, Optional.ToNullable(kind), identity, extendedLocation.Value, Optional.ToNullable(provisioningState), primaryEndpoints.Value, primaryLocation.Value, Optional.ToNullable(statusOfPrimary), Optional.ToNullable(lastGeoFailoverTime), secondaryLocation.Value, Optional.ToNullable(statusOfSecondary), Optional.ToNullable(creationTime), customDomain.Value, sasPolicy.Value, keyPolicy.Value, keyCreationTime.Value, secondaryEndpoints.Value, encryption.Value, Optional.ToNullable(accessTier), azureFilesIdentityBasedAuthentication.Value, Optional.ToNullable(supportsHttpsTrafficOnly), networkAcls.Value, Optional.ToNullable(isSftpEnabled), Optional.ToNullable(isLocalUserEnabled), Optional.ToNullable(isHnsEnabled), geoReplicationStats.Value, Optional.ToNullable(failoverInProgress), Optional.ToNullable(largeFileSharesState), Optional.ToList(privateEndpointConnections), routingPreference.Value, blobRestoreStatus.Value, Optional.ToNullable(allowBlobPublicAccess), Optional.ToNullable(minimumTlsVersion), Optional.ToNullable(allowSharedKeyAccess), Optional.ToNullable(isNfsV3Enabled), Optional.ToNullable(allowCrossTenantReplication), Optional.ToNullable(defaultToOAuthAuthentication), Optional.ToNullable(publicNetworkAccess), immutableStorageWithVersioning.Value, Optional.ToNullable(allowedCopyScope))); }
internal static ManagedInstanceData DeserializeManagedInstanceData(JsonElement element) { Optional <ManagedServiceIdentity> identity = default; Optional <Models.Sku> sku = default; IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <ManagedInstancePropertiesProvisioningState> provisioningState = default; Optional <ManagedServerCreateMode> managedInstanceCreateMode = default; Optional <string> fullyQualifiedDomainName = default; Optional <string> administratorLogin = default; Optional <string> administratorLoginPassword = default; Optional <string> subnetId = default; Optional <string> state = default; Optional <ManagedInstanceLicenseType> licenseType = default; Optional <int> vCores = default; Optional <int> storageSizeInGB = default; Optional <string> collation = default; Optional <string> dnsZone = default; Optional <string> dnsZonePartner = default; Optional <bool> publicDataEndpointEnabled = default; Optional <string> sourceManagedInstanceId = default; Optional <DateTimeOffset> restorePointInTime = default; Optional <ManagedInstanceProxyOverride> proxyOverride = default; Optional <string> timezoneId = default; Optional <string> instancePoolId = default; Optional <string> maintenanceConfigurationId = default; Optional <IReadOnlyList <ManagedInstancePecProperty> > privateEndpointConnections = default; Optional <string> minimalTlsVersion = default; Optional <StorageAccountType> storageAccountType = default; Optional <bool> zoneRedundant = default; Optional <string> primaryUserAssignedIdentityId = default; Optional <string> keyId = default; Optional <ManagedInstanceExternalAdministrator> administrators = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("identity")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; identity = JsonSerializer.Deserialize <ManagedServiceIdentity>(property.Value.ToString(), serializeOptions); continue; } if (property.NameEquals("sku")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } sku = Models.Sku.DeserializeSku(property.Value); continue; } if (property.NameEquals("tags")) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new ManagedInstancePropertiesProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("managedInstanceCreateMode")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } managedInstanceCreateMode = new ManagedServerCreateMode(property0.Value.GetString()); continue; } if (property0.NameEquals("fullyQualifiedDomainName")) { fullyQualifiedDomainName = property0.Value.GetString(); continue; } if (property0.NameEquals("administratorLogin")) { administratorLogin = property0.Value.GetString(); continue; } if (property0.NameEquals("administratorLoginPassword")) { administratorLoginPassword = property0.Value.GetString(); continue; } if (property0.NameEquals("subnetId")) { subnetId = property0.Value.GetString(); continue; } if (property0.NameEquals("state")) { state = property0.Value.GetString(); continue; } if (property0.NameEquals("licenseType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } licenseType = new ManagedInstanceLicenseType(property0.Value.GetString()); continue; } if (property0.NameEquals("vCores")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } vCores = property0.Value.GetInt32(); continue; } if (property0.NameEquals("storageSizeInGB")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } storageSizeInGB = property0.Value.GetInt32(); continue; } if (property0.NameEquals("collation")) { collation = property0.Value.GetString(); continue; } if (property0.NameEquals("dnsZone")) { dnsZone = property0.Value.GetString(); continue; } if (property0.NameEquals("dnsZonePartner")) { dnsZonePartner = property0.Value.GetString(); continue; } if (property0.NameEquals("publicDataEndpointEnabled")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } publicDataEndpointEnabled = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("sourceManagedInstanceId")) { sourceManagedInstanceId = property0.Value.GetString(); continue; } if (property0.NameEquals("restorePointInTime")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } restorePointInTime = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("proxyOverride")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } proxyOverride = new ManagedInstanceProxyOverride(property0.Value.GetString()); continue; } if (property0.NameEquals("timezoneId")) { timezoneId = property0.Value.GetString(); continue; } if (property0.NameEquals("instancePoolId")) { instancePoolId = property0.Value.GetString(); continue; } if (property0.NameEquals("maintenanceConfigurationId")) { maintenanceConfigurationId = property0.Value.GetString(); continue; } if (property0.NameEquals("privateEndpointConnections")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <ManagedInstancePecProperty> array = new List <ManagedInstancePecProperty>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(ManagedInstancePecProperty.DeserializeManagedInstancePecProperty(item)); } privateEndpointConnections = array; continue; } if (property0.NameEquals("minimalTlsVersion")) { minimalTlsVersion = property0.Value.GetString(); continue; } if (property0.NameEquals("storageAccountType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } storageAccountType = new StorageAccountType(property0.Value.GetString()); continue; } if (property0.NameEquals("zoneRedundant")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } zoneRedundant = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("primaryUserAssignedIdentityId")) { primaryUserAssignedIdentityId = property0.Value.GetString(); continue; } if (property0.NameEquals("keyId")) { keyId = property0.Value.GetString(); continue; } if (property0.NameEquals("administrators")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } administrators = ManagedInstanceExternalAdministrator.DeserializeManagedInstanceExternalAdministrator(property0.Value); continue; } } continue; } } return(new ManagedInstanceData(id, name, type, systemData, tags, location, identity, sku.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(managedInstanceCreateMode), fullyQualifiedDomainName.Value, administratorLogin.Value, administratorLoginPassword.Value, subnetId.Value, state.Value, Optional.ToNullable(licenseType), Optional.ToNullable(vCores), Optional.ToNullable(storageSizeInGB), collation.Value, dnsZone.Value, dnsZonePartner.Value, Optional.ToNullable(publicDataEndpointEnabled), sourceManagedInstanceId.Value, Optional.ToNullable(restorePointInTime), Optional.ToNullable(proxyOverride), timezoneId.Value, instancePoolId.Value, maintenanceConfigurationId.Value, Optional.ToList(privateEndpointConnections), minimalTlsVersion.Value, Optional.ToNullable(storageAccountType), Optional.ToNullable(zoneRedundant), primaryUserAssignedIdentityId.Value, keyId.Value, administrators.Value)); }
public override void Execute() { base.Execute(); if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnConnectionName, StringComparison.OrdinalIgnoreCase)) { this.ResourceGroupName = this.ResourceGroupName; this.ParentResourceName = this.ParentResourceName; this.Name = this.Name; } else if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnConnectionObject, StringComparison.OrdinalIgnoreCase)) { this.ResourceId = this.InputObject.Id; if (string.IsNullOrWhiteSpace(this.ResourceId)) { throw new PSArgumentException(Properties.Resources.VpnConnectionNotFound); } var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); this.Name = parsedResourceId.ResourceName; } //// Get the vpngateway object - this will throw not found if the object is not found PSVpnGateway parentGateway = this.GetVpnGateway(this.ResourceGroupName, this.ParentResourceName); if (parentGateway == null || parentGateway.Connections == null || !parentGateway.Connections.Any(connection => connection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase))) { throw new PSArgumentException(Properties.Resources.VpnConnectionNotFound); } var vpnConnectionToModify = parentGateway.Connections.FirstOrDefault(connection => connection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase)); if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnConnectionObject, StringComparison.OrdinalIgnoreCase)) { vpnConnectionToModify = this.InputObject; } if (vpnConnectionToModify.VpnLinkConnections != null && vpnConnectionToModify.VpnLinkConnections.Any()) { //// Use only link connection properties instead of vpn connection properties. if (this.SharedKey != null || this.ConnectionBandwidthInMbps > 0 || this.EnableBgp.HasValue || this.UseLocalAzureIpAddress.HasValue || this.UsePolicyBasedTrafficSelectors.HasValue || this.IpSecPolicy != null) { throw new PSArgumentException(Properties.Resources.VpnConnectionPropertyIsDeprecated); } } if (this.SharedKey != null) { vpnConnectionToModify.SharedKey = SecureStringExtensions.ConvertToString(this.SharedKey); } if (this.ConnectionBandwidthInMbps > 0) { vpnConnectionToModify.ConnectionBandwidth = Convert.ToInt32(this.ConnectionBandwidthInMbps); } if (this.EnableBgp.HasValue) { vpnConnectionToModify.EnableBgp = this.EnableBgp.Value; } if (this.UseLocalAzureIpAddress.HasValue) { vpnConnectionToModify.UseLocalAzureIpAddress = this.UseLocalAzureIpAddress.Value; } if (this.UsePolicyBasedTrafficSelectors.HasValue) { vpnConnectionToModify.UsePolicyBasedTrafficSelectors = this.UsePolicyBasedTrafficSelectors.Value; } if (this.IpSecPolicy != null) { vpnConnectionToModify.IpsecPolicies = new List <PSIpsecPolicy> { this.IpSecPolicy }; } //// Modify the linkconnections if (this.VpnSiteLinkConnection != null) { vpnConnectionToModify.VpnLinkConnections = new List <PSVpnSiteLinkConnection>(); vpnConnectionToModify.VpnLinkConnections.AddRange(this.VpnSiteLinkConnection); } if (this.EnableInternetSecurity.HasValue) { vpnConnectionToModify.EnableInternetSecurity = this.EnableInternetSecurity.Value; } if (this.RoutingConfiguration != null) { if (this.RoutingConfiguration.VnetRoutes != null && this.RoutingConfiguration.VnetRoutes.StaticRoutes != null && this.RoutingConfiguration.VnetRoutes.StaticRoutes.Any()) { throw new PSArgumentException(Properties.Resources.StaticRoutesNotSupportedForThisRoutingConfiguration); } vpnConnectionToModify.RoutingConfiguration = this.RoutingConfiguration; } if (!String.IsNullOrEmpty(this.VpnLinkConnectionMode)) { foreach (var vpnSiteLinkConnection in vpnConnectionToModify.VpnLinkConnections) { vpnSiteLinkConnection.VpnLinkConnectionMode = this.VpnLinkConnectionMode; } } if (this.TrafficSelectorPolicy != null) { vpnConnectionToModify.TrafficSelectorPolicies = this.TrafficSelectorPolicy?.ToList(); } ConfirmAction( Properties.Resources.SettingResourceMessage, this.Name, () => { WriteVerbose(String.Format(Properties.Resources.UpdatingLongRunningOperationMessage, this.ResourceGroupName, this.Name)); this.CreateOrUpdateVpnGateway(this.ResourceGroupName, this.ParentResourceName, parentGateway, parentGateway.Tag); var createdOrUpdatedVpnGateway = this.GetVpnGateway(this.ResourceGroupName, this.ParentResourceName); WriteObject(createdOrUpdatedVpnGateway.Connections.Where(connection => connection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault()); }); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (this.ApplicationInsightsComponent != null) { this.ResourceGroupName = this.ApplicationInsightsComponent.ResourceGroupName; this.Name = this.ApplicationInsightsComponent.Name; } if (!string.IsNullOrEmpty(this.ResourceId)) { ResourceIdentifier identifier = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = identifier.ResourceGroupName; this.Name = identifier.ResourceName; } ApplicationInsightsComponentBillingFeatures features = this.AppInsightsManagementClient .ComponentCurrentBillingFeatures .GetWithHttpMessagesAsync( this.ResourceGroupName, this.Name) .GetAwaiter() .GetResult() .Body; if (!string.IsNullOrEmpty(this.PricingPlan)) { if (this.PricingPlan.ToLowerInvariant().Contains("enterprise")) { features.CurrentBillingFeatures = new string[] { "Application Insights Enterprise" }; } else if (this.PricingPlan.ToLowerInvariant().Contains("limited")) { features.CurrentBillingFeatures = new string[] { "Limited Basic" }; } else { features.CurrentBillingFeatures = new string[] { "Basic" }; } } if (this.DailyCapGB != null) { features.DataVolumeCap.Cap = this.DailyCapGB.Value; } if (this.DisableNotificationWhenHitCap.IsPresent) { features.DataVolumeCap.StopSendNotificationWhenHitCap = true; } else { features.DataVolumeCap.StopSendNotificationWhenHitCap = false; } if (this.ShouldProcess(this.Name, "Update Pricing Plan")) { var putResponse = this.AppInsightsManagementClient .ComponentCurrentBillingFeatures .UpdateWithHttpMessagesAsync( this.ResourceGroupName, this.Name, features) .GetAwaiter() .GetResult(); WriteCurrentFeatures(putResponse.Body); } }
internal ApplicationGatewayPrivateLinkConfiguration(ResourceIdentifier id, string name, ResourceType?resourceType, ETag?etag, IList <ApplicationGatewayPrivateLinkIPConfiguration> ipConfigurations, NetworkProvisioningState?provisioningState) : base(id, name, resourceType) { Etag = etag; IPConfigurations = ipConfigurations; ProvisioningState = provisioningState; }
internal NamespaceDisasterRecoveryAuthorizationRuleCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { _namespaceDisasterRecoveryAuthorizationRuleDisasterRecoveryAuthorizationRulesClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ServiceBus", NamespaceDisasterRecoveryAuthorizationRule.ResourceType.Namespace, DiagnosticOptions); TryGetApiVersion(NamespaceDisasterRecoveryAuthorizationRule.ResourceType, out string namespaceDisasterRecoveryAuthorizationRuleDisasterRecoveryAuthorizationRulesApiVersion); _namespaceDisasterRecoveryAuthorizationRuleDisasterRecoveryAuthorizationRulesRestClient = new DisasterRecoveryAuthorizationRulesRestOperations(Pipeline, DiagnosticOptions.ApplicationId, BaseUri, namespaceDisasterRecoveryAuthorizationRuleDisasterRecoveryAuthorizationRulesApiVersion); #if DEBUG ValidateResourceId(Id); #endif }
internal static DiskRestorePointData DeserializeDiskRestorePointData(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; Optional <DateTimeOffset> timeCreated = default; Optional <string> sourceResourceId = default; Optional <OperatingSystemTypes> osType = default; Optional <HyperVGeneration> hyperVGeneration = default; Optional <DiskPurchasePlan> purchasePlan = default; Optional <SupportedCapabilities> supportedCapabilities = default; Optional <string> familyId = default; Optional <string> sourceUniqueId = default; Optional <Encryption> encryption = default; Optional <bool> supportsHibernation = default; Optional <NetworkAccessPolicy> networkAccessPolicy = default; Optional <PublicNetworkAccess> publicNetworkAccess = default; Optional <string> diskAccessId = default; Optional <float> completionPercent = default; Optional <string> replicationState = default; Optional <string> sourceResourceLocation = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("timeCreated")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } timeCreated = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("sourceResourceId")) { sourceResourceId = property0.Value.GetString(); continue; } if (property0.NameEquals("osType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } osType = property0.Value.GetString().ToOperatingSystemTypes(); continue; } if (property0.NameEquals("hyperVGeneration")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } hyperVGeneration = new HyperVGeneration(property0.Value.GetString()); continue; } if (property0.NameEquals("purchasePlan")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } purchasePlan = DiskPurchasePlan.DeserializeDiskPurchasePlan(property0.Value); continue; } if (property0.NameEquals("supportedCapabilities")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } supportedCapabilities = SupportedCapabilities.DeserializeSupportedCapabilities(property0.Value); continue; } if (property0.NameEquals("familyId")) { familyId = property0.Value.GetString(); continue; } if (property0.NameEquals("sourceUniqueId")) { sourceUniqueId = property0.Value.GetString(); continue; } if (property0.NameEquals("encryption")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } encryption = Encryption.DeserializeEncryption(property0.Value); continue; } if (property0.NameEquals("supportsHibernation")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } supportsHibernation = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("networkAccessPolicy")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } networkAccessPolicy = new NetworkAccessPolicy(property0.Value.GetString()); continue; } if (property0.NameEquals("publicNetworkAccess")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } publicNetworkAccess = new PublicNetworkAccess(property0.Value.GetString()); continue; } if (property0.NameEquals("diskAccessId")) { diskAccessId = property0.Value.GetString(); continue; } if (property0.NameEquals("completionPercent")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } completionPercent = property0.Value.GetSingle(); continue; } if (property0.NameEquals("replicationState")) { replicationState = property0.Value.GetString(); continue; } if (property0.NameEquals("sourceResourceLocation")) { sourceResourceLocation = property0.Value.GetString(); continue; } } continue; } } return(new DiskRestorePointData(id, name, type, Optional.ToNullable(timeCreated), sourceResourceId.Value, Optional.ToNullable(osType), Optional.ToNullable(hyperVGeneration), purchasePlan.Value, supportedCapabilities.Value, familyId.Value, sourceUniqueId.Value, encryption.Value, Optional.ToNullable(supportsHibernation), Optional.ToNullable(networkAccessPolicy), Optional.ToNullable(publicNetworkAccess), diskAccessId.Value, Optional.ToNullable(completionPercent), replicationState.Value, sourceResourceLocation.Value)); }
internal SapProviderInstanceData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, WorkloadMonitorProvisioningState?provisioningState, ResponseError errors, ProviderSpecificProperties providerSettings) : base(id, name, resourceType, systemData) { ProvisioningState = provisioningState; Errors = errors; ProviderSettings = providerSettings; }
internal static VirtualRouterPeeringData DeserializeVirtualRouterPeeringData(JsonElement element) { Optional <ETag> etag = default; Optional <ResourceIdentifier> id = default; Optional <string> name = default; Optional <ResourceType> type = default; Optional <long> peerAsn = default; Optional <string> peerIp = default; Optional <NetworkProvisioningState> provisioningState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("etag")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } etag = new ETag(property.Value.GetString()); continue; } if (property.NameEquals("id")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } type = new ResourceType(property.Value.GetString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("peerAsn")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } peerAsn = property0.Value.GetInt64(); continue; } if (property0.NameEquals("peerIp")) { peerIp = property0.Value.GetString(); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new NetworkProvisioningState(property0.Value.GetString()); continue; } } continue; } } return(new VirtualRouterPeeringData(id.Value, name.Value, Optional.ToNullable(type), Optional.ToNullable(etag), Optional.ToNullable(peerAsn), peerIp.Value, Optional.ToNullable(provisioningState))); }
internal FlowLog(ArmClientOptions clientOptions, TokenCredential credential, Uri uri, HttpPipeline pipeline, ResourceIdentifier id) : base(clientOptions, credential, uri, pipeline, id) { _clientDiagnostics = new ClientDiagnostics(ClientOptions); _restClient = new FlowLogsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri); }
internal CurrentQuotaLimitBaseData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, QuotaProperties properties) : base(id, name, resourceType, systemData) { Properties = properties; }
internal ResourceGroupExtensionClient(ArmClient client, ResourceIdentifier id) : base(client, id) { }
public override void Execute() { base.Execute(); if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnGatewayNatRuleName, StringComparison.OrdinalIgnoreCase)) { this.ResourceGroupName = this.ResourceGroupName; this.ParentResourceName = this.ParentResourceName; this.Name = this.Name; } else if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnGatewayNatRuleObject, StringComparison.OrdinalIgnoreCase)) { this.ResourceId = this.InputObject.Id; if (string.IsNullOrWhiteSpace(this.ResourceId)) { throw new PSArgumentException(Properties.Resources.VpnGatewayNatRuleNotFound); } var parsedResourceId = new ResourceIdentifier(this.ResourceId); this.ResourceGroupName = parsedResourceId.ResourceGroupName; this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); this.Name = parsedResourceId.ResourceName; } //// Get the vpngateway object - this will throw not found if the object is not found PSVpnGateway parentGateway = this.GetVpnGateway(this.ResourceGroupName, this.ParentResourceName); if (parentGateway == null || parentGateway.NatRules == null || !parentGateway.NatRules.Any(natRule => natRule.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase))) { throw new PSArgumentException(Properties.Resources.VpnGatewayNatRuleNotFound); } var vpnGatewayNatRuleToModify = parentGateway.NatRules.FirstOrDefault(natRule => natRule.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase)); if (ParameterSetName.Equals(CortexParameterSetNames.ByVpnGatewayNatRuleObject, StringComparison.OrdinalIgnoreCase)) { vpnGatewayNatRuleToModify = this.InputObject; } if (this.IpConfigurationId != null) { vpnGatewayNatRuleToModify.IpConfigurationId = IpConfigurationId; } if (this.Mode != null) { vpnGatewayNatRuleToModify.Mode = Mode; } if (this.Type != null) { vpnGatewayNatRuleToModify.VpnGatewayNatRulePropertiesType = Type; } if (this.InternalMapping != null) { vpnGatewayNatRuleToModify.InternalMappings.Clear(); foreach (string internalMappingSubnet in this.InternalMapping) { var internalMapping = new PSVpnNatRuleMapping(); internalMapping.AddressSpace = internalMappingSubnet; vpnGatewayNatRuleToModify.InternalMappings.Add(internalMapping); } } if (this.ExternalMapping != null) { vpnGatewayNatRuleToModify.ExternalMappings.Clear(); foreach (string externalMappingSubnet in this.ExternalMapping) { var externalMapping = new PSVpnNatRuleMapping(); externalMapping.AddressSpace = externalMappingSubnet; vpnGatewayNatRuleToModify.ExternalMappings.Add(externalMapping); } } ConfirmAction( Properties.Resources.SettingResourceMessage, this.Name, () => { WriteVerbose(String.Format(Properties.Resources.UpdatingLongRunningOperationMessage, this.ResourceGroupName, this.Name)); this.CreateOrUpdateVpnGateway(this.ResourceGroupName, this.ParentResourceName, parentGateway, parentGateway.Tag); var createdOrUpdatedVpnGateway = this.GetVpnGateway(this.ResourceGroupName, this.ParentResourceName); WriteObject(createdOrUpdatedVpnGateway.NatRules.Where(natRule => natRule.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault()); }); }
public async Task GlobalSetUp() { var rgLro = await GlobalClient.DefaultSubscription.GetResourceGroups().CreateOrUpdateAsync(SessionRecording.GenerateAssetName("FirewallPolicyRG-"), new ResourceGroupData(Location.WestUS2)); ResourceGroup rg = rgLro.Value; _resourceGroupIdentifier = rg.Id; VirtualNetworkData vnetData = new VirtualNetworkData() { Location = Location.WestUS2, AddressSpace = new AddressSpace() { AddressPrefixes = { "10.26.0.0/16", } }, Subnets = { new SubnetData() { Name = "Default", AddressPrefix = "10.26.1.0/26", }, new SubnetData() { Name = "AzureFirewallSubnet", AddressPrefix = "10.26.2.0/26", }, }, }; var vnetLro = await rg.GetVirtualNetworks().CreateOrUpdateAsync(SessionRecording.GenerateAssetName("vnet-"), vnetData); _network = vnetLro.Value; _networkIdentifier = _network.Id; PublicIPAddressData ipData = new PublicIPAddressData() { Location = Location.WestUS2, PublicIPAllocationMethod = IPAllocationMethod.Static, Sku = new PublicIPAddressSku() { Name = PublicIPAddressSkuName.Standard }, }; var ipLro = await rg.GetPublicIPAddresses().CreateOrUpdateAsync(SessionRecording.GenerateAssetName("publicIp-"), ipData); _publicIPAddress = ipLro.Value; _publicIPAddressIdentifier = _publicIPAddress.Id; AzureFirewallData firewallData = new AzureFirewallData(); firewallData.Location = Location.WestUS2; firewallData.IpConfigurations.Add(new AzureFirewallIPConfiguration() { Name = "fwpip", PublicIPAddress = new Models.SubResource() { Id = _publicIPAddressIdentifier }, Subnet = new Models.SubResource() { Id = _networkIdentifier.ToString() + "/subnets/AzureFirewallSubnet" }, }); var firewallLro = await rg.GetAzureFirewalls().CreateOrUpdateAsync(SessionRecording.GenerateAssetName("firewall-"), firewallData); _firewall = firewallLro.Value; _firewallIdentifier = _firewall.Id; StopSessionRecording(); }
internal static DataCollectionRuleData DeserializeDataCollectionRuleData(JsonElement element) { Optional <DataCollectionRuleProperties> properties = default; Optional <KnownDataCollectionRuleResourceKind> kind = default; Optional <string> etag = default; IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } properties = DataCollectionRuleProperties.DeserializeDataCollectionRuleProperties(property.Value); continue; } if (property.NameEquals("kind")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } kind = new KnownDataCollectionRuleResourceKind(property.Value.GetString()); continue; } if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } } return(new DataCollectionRuleData(id, name, type, systemData, tags, location, properties.Value, Optional.ToNullable(kind), etag.Value)); }
internal PatchableTemplateSpecVersionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags) : base(id, name, resourceType, systemData) { Tags = tags; }
internal static EndpointResourceData DeserializeEndpointResourceData(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <EndpointType> type0 = default; Optional <string> resourceId = default; Optional <string> provisioningState = default; Optional <string> createdBy = default; Optional <Models.CreatedByType> createdByType = default; Optional <DateTimeOffset> createdAt = default; Optional <string> lastModifiedBy = default; Optional <Models.CreatedByType> lastModifiedByType = default; Optional <DateTimeOffset> lastModifiedAt = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("type")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } type0 = new EndpointType(property0.Value.GetString()); continue; } if (property0.NameEquals("resourceId")) { resourceId = property0.Value.GetString(); continue; } if (property0.NameEquals("provisioningState")) { provisioningState = property0.Value.GetString(); continue; } } continue; } if (property.NameEquals("systemData")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("createdBy")) { createdBy = property0.Value.GetString(); continue; } if (property0.NameEquals("createdByType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } createdByType = new Models.CreatedByType(property0.Value.GetString()); continue; } if (property0.NameEquals("createdAt")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } createdAt = property0.Value.GetDateTimeOffset("O"); continue; } if (property0.NameEquals("lastModifiedBy")) { lastModifiedBy = property0.Value.GetString(); continue; } if (property0.NameEquals("lastModifiedByType")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } lastModifiedByType = new Models.CreatedByType(property0.Value.GetString()); continue; } if (property0.NameEquals("lastModifiedAt")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } lastModifiedAt = property0.Value.GetDateTimeOffset("O"); continue; } } continue; } } return(new EndpointResourceData(id, name, type, systemData, Optional.ToNullable(type0), resourceId.Value, provisioningState.Value, createdBy.Value, Optional.ToNullable(createdByType), Optional.ToNullable(createdAt), lastModifiedBy.Value, Optional.ToNullable(lastModifiedByType), Optional.ToNullable(lastModifiedAt))); }
public static AfdRuleSetResource GetAfdRuleSetResource(this ArmClient client, ResourceIdentifier id) { return(client.GetResourceClient(() => { AfdRuleSetResource.ValidateResourceId(id); return new AfdRuleSetResource(client, id); } )); }
internal RoleInstance(ArmClientOptions clientOptions, TokenCredential credential, Uri uri, HttpPipeline pipeline, ResourceIdentifier id) : base(clientOptions, credential, uri, pipeline, id) { _clientDiagnostics = new ClientDiagnostics(ClientOptions); _cloudServiceRoleInstancesRestClient = new CloudServiceRoleInstancesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); #if DEBUG ValidateResourceId(Id); #endif }
internal List<PSPermission> GetResourcePermissions(ResourceIdentifier identity) { PermissionGetResult permissionsResult = AuthorizationManagementClient.Permissions.ListForResource( identity.ResourceGroupName, identity.ToResourceIdentity()); if (permissionsResult != null) { return permissionsResult.Permissions.Select(p => p.ToPSPermission()).ToList(); } return null; }
internal PrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType type, Resources.Models.SubResource privateEndpoint, PrivateLinkServiceConnectionState privateLinkServiceConnectionState, PrivateEndpointConnectionProvisioningState?provisioningState) : base(id, name, type) { PrivateEndpoint = privateEndpoint; PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; ProvisioningState = provisioningState; }