internal P2SVpnGateway(ArmResource options, P2SVpnGatewayData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _restClient        = new P2SVpnGatewaysRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
Beispiel #2
0
        P2SVpnGatewayResource IOperationSource <P2SVpnGatewayResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = P2SVpnGatewayData.DeserializeP2SVpnGatewayData(document.RootElement);

            return(new P2SVpnGatewayResource(_client, data));
        }
 internal P2SVpnGateway(ArmResource options, P2SVpnGatewayData resource) : base(options, new ResourceIdentifier(resource.Id))
 {
     HasData                   = true;
     _data                     = resource;
     _clientDiagnostics        = new ClientDiagnostics(ClientOptions);
     _p2sVpnGatewaysRestClient = new P2SVpnGatewaysRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Beispiel #4
0
        internal static VpnServerConfigurationData DeserializeVpnServerConfigurationData(JsonElement element)
        {
            Optional <ETag> etag = default;
            Optional <ResourceIdentifier>                                  id                           = default;
            Optional <string>                                              name                         = default;
            Optional <ResourceType>                                        type                         = default;
            Optional <AzureLocation>                                       location                     = default;
            Optional <IDictionary <string, string> >                       tags                         = default;
            Optional <IList <VpnGatewayTunnelingProtocol> >                vpnProtocols                 = default;
            Optional <IList <VpnAuthenticationType> >                      vpnAuthenticationTypes       = default;
            Optional <IList <VpnServerConfigVpnClientRootCertificate> >    vpnClientRootCertificates    = default;
            Optional <IList <VpnServerConfigVpnClientRevokedCertificate> > vpnClientRevokedCertificates = default;
            Optional <IList <VpnServerConfigRadiusServerRootCertificate> > radiusServerRootCertificates = default;
            Optional <IList <VpnServerConfigRadiusClientRootCertificate> > radiusClientRootCertificates = default;
            Optional <IList <IPsecPolicy> >                                vpnClientIpsecPolicies       = default;
            Optional <string>                                              radiusServerAddress          = default;
            Optional <string>                                              radiusServerSecret           = default;
            Optional <IList <RadiusServer> >                               radiusServers                = default;
            Optional <AadAuthenticationParameters>                         aadAuthenticationParameters  = default;
            Optional <string>                                              provisioningState            = default;
            Optional <IReadOnlyList <P2SVpnGatewayData> >                  p2SVpnGateways               = 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("location"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    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("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("vpnProtocols"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VpnGatewayTunnelingProtocol> array = new List <VpnGatewayTunnelingProtocol>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(new VpnGatewayTunnelingProtocol(item.GetString()));
                            }
                            vpnProtocols = array;
                            continue;
                        }
                        if (property0.NameEquals("vpnAuthenticationTypes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VpnAuthenticationType> array = new List <VpnAuthenticationType>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(new VpnAuthenticationType(item.GetString()));
                            }
                            vpnAuthenticationTypes = array;
                            continue;
                        }
                        if (property0.NameEquals("vpnClientRootCertificates"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VpnServerConfigVpnClientRootCertificate> array = new List <VpnServerConfigVpnClientRootCertificate>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(VpnServerConfigVpnClientRootCertificate.DeserializeVpnServerConfigVpnClientRootCertificate(item));
                            }
                            vpnClientRootCertificates = array;
                            continue;
                        }
                        if (property0.NameEquals("vpnClientRevokedCertificates"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VpnServerConfigVpnClientRevokedCertificate> array = new List <VpnServerConfigVpnClientRevokedCertificate>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(VpnServerConfigVpnClientRevokedCertificate.DeserializeVpnServerConfigVpnClientRevokedCertificate(item));
                            }
                            vpnClientRevokedCertificates = array;
                            continue;
                        }
                        if (property0.NameEquals("radiusServerRootCertificates"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VpnServerConfigRadiusServerRootCertificate> array = new List <VpnServerConfigRadiusServerRootCertificate>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(VpnServerConfigRadiusServerRootCertificate.DeserializeVpnServerConfigRadiusServerRootCertificate(item));
                            }
                            radiusServerRootCertificates = array;
                            continue;
                        }
                        if (property0.NameEquals("radiusClientRootCertificates"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VpnServerConfigRadiusClientRootCertificate> array = new List <VpnServerConfigRadiusClientRootCertificate>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(VpnServerConfigRadiusClientRootCertificate.DeserializeVpnServerConfigRadiusClientRootCertificate(item));
                            }
                            radiusClientRootCertificates = array;
                            continue;
                        }
                        if (property0.NameEquals("vpnClientIpsecPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IPsecPolicy> array = new List <IPsecPolicy>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(IPsecPolicy.DeserializeIPsecPolicy(item));
                            }
                            vpnClientIpsecPolicies = array;
                            continue;
                        }
                        if (property0.NameEquals("radiusServerAddress"))
                        {
                            radiusServerAddress = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("radiusServerSecret"))
                        {
                            radiusServerSecret = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("radiusServers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <RadiusServer> array = new List <RadiusServer>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(RadiusServer.DeserializeRadiusServer(item));
                            }
                            radiusServers = array;
                            continue;
                        }
                        if (property0.NameEquals("aadAuthenticationParameters"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            aadAuthenticationParameters = AadAuthenticationParameters.DeserializeAadAuthenticationParameters(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("p2SVpnGateways"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <P2SVpnGatewayData> array = new List <P2SVpnGatewayData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(P2SVpnGatewayData.DeserializeP2SVpnGatewayData(item));
                            }
                            p2SVpnGateways = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new VpnServerConfigurationData(id.Value, name.Value, Optional.ToNullable(type), Optional.ToNullable(location), Optional.ToDictionary(tags), Optional.ToNullable(etag), Optional.ToList(vpnProtocols), Optional.ToList(vpnAuthenticationTypes), Optional.ToList(vpnClientRootCertificates), Optional.ToList(vpnClientRevokedCertificates), Optional.ToList(radiusServerRootCertificates), Optional.ToList(radiusClientRootCertificates), Optional.ToList(vpnClientIpsecPolicies), radiusServerAddress.Value, radiusServerSecret.Value, Optional.ToList(radiusServers), aadAuthenticationParameters.Value, provisioningState.Value, Optional.ToList(p2SVpnGateways)));
        }
 internal P2SVpnGateway(ArmClient client, P2SVpnGatewayData data) : this(client, new ResourceIdentifier(data.Id))
 {
     HasData = true;
     _data   = data;
 }
        public virtual P2SVpnGatewayCreateOrUpdateOperation CreateOrUpdate(string gatewayName, P2SVpnGatewayData p2SVpnGatewayParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (gatewayName == null)
            {
                throw new ArgumentNullException(nameof(gatewayName));
            }
            if (p2SVpnGatewayParameters == null)
            {
                throw new ArgumentNullException(nameof(p2SVpnGatewayParameters));
            }

            using var scope = _clientDiagnostics.CreateScope("P2SVpnGatewayCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _restClient.CreateOrUpdate(Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters, cancellationToken);
                var operation = new P2SVpnGatewayCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Beispiel #7
0
        public async virtual Task <ArmOperation <P2SVpnGateway> > CreateOrUpdateAsync(bool waitForCompletion, string gatewayName, P2SVpnGatewayData p2SVpnGatewayParameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName));
            Argument.AssertNotNull(p2SVpnGatewayParameters, nameof(p2SVpnGatewayParameters));

            using var scope = _p2SVpnGatewayP2sVpnGatewaysClientDiagnostics.CreateScope("P2SVpnGatewayCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _p2SVpnGatewayP2sVpnGatewaysRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkArmOperation <P2SVpnGateway>(new P2SVpnGatewayOperationSource(Client), _p2SVpnGatewayP2sVpnGatewaysClientDiagnostics, Pipeline, _p2SVpnGatewayP2sVpnGatewaysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, p2SVpnGatewayParameters).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Beispiel #8
0
        public virtual ArmOperation <P2SVpnGatewayResource> CreateOrUpdate(WaitUntil waitUntil, string gatewayName, P2SVpnGatewayData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _p2SVpnGatewayP2sVpnGatewaysClientDiagnostics.CreateScope("P2SVpnGatewayCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _p2SVpnGatewayP2sVpnGatewaysRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, data, cancellationToken);
                var operation = new NetworkArmOperation <P2SVpnGatewayResource>(new P2SVpnGatewayOperationSource(Client), _p2SVpnGatewayP2sVpnGatewaysClientDiagnostics, Pipeline, _p2SVpnGatewayP2sVpnGatewaysRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Beispiel #9
0
 internal P2SVpnGatewayResource(ArmClient client, P2SVpnGatewayData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }