internal PrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType type, string location, IReadOnlyDictionary <string, string> tags, string etag, PrivateEndpoint privateEndpoint, PrivateLinkServiceConnectionState privateLinkServiceConnectionState, PrivateEndpointConnectionProvisioningState?provisioningState) : base(id, name, type, location, tags) { Etag = etag; PrivateEndpoint = privateEndpoint; PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; ProvisioningState = provisioningState; }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (PrivateEndpoint != null) { PrivateEndpoint.Validate(); } }
public async Task <Response <PrivateEndpoint> > GetAsync(string resourceGroupName, string privateEndpointName, string expand = null, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (privateEndpointName == null) { throw new ArgumentNullException(nameof(privateEndpointName)); } using var message = CreateGetRequest(resourceGroupName, privateEndpointName, expand); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { PrivateEndpoint value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = PrivateEndpoint.DeserializePrivateEndpoint(document.RootElement); } return(Response.FromValue(value, message.Response)); }
public PSPrivateEndpoint ToPsPrivateEndpoint(PrivateEndpoint privateEndpoint) { var psPrivateEndpoint = NetworkResourceManagerProfile.Mapper.Map <PSPrivateEndpoint>(privateEndpoint); psPrivateEndpoint.Tag = TagsConversionHelper.CreateTagHashtable(privateEndpoint.Tags); return(psPrivateEndpoint); }
internal PrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ProvisioningState?provisioningState, PrivateEndpoint privateEndpoint, IReadOnlyList <string> groupIds, PrivateLinkServiceConnectionState privateLinkServiceConnectionState) : base(id, name, resourceType, systemData) { ProvisioningState = provisioningState; PrivateEndpoint = privateEndpoint; GroupIds = groupIds; PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; }
internal static PSPrivateEndpoint CreateFromPrivateEndpoint(PrivateEndpoint privateEndpoint) { if (privateEndpoint == null) { return(null); } return(new PSPrivateEndpoint(privateEndpoint.Id)); }
internal PrivateEndpointConnectionReference(string id, string name, string type, ProvisioningState?provisioningState, PrivateEndpoint privateEndpoint, PrivateLinkServiceConnectionState privateLinkServiceConnectionState) { Id = id; Name = name; Type = type; ProvisioningState = provisioningState; PrivateEndpoint = privateEndpoint; PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; }
internal MachineLearningPrivateEndpointConnectionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, ManagedServiceIdentity identity, AzureLocation?location, IDictionary <string, string> tags, MachineLearningSku sku, PrivateEndpoint privateEndpoint, MachineLearningPrivateLinkServiceConnectionState connectionState, MachineLearningPrivateEndpointConnectionProvisioningState?provisioningState) : base(id, name, resourceType, systemData) { Identity = identity; Location = location; Tags = tags; Sku = sku; PrivateEndpoint = privateEndpoint; ConnectionState = connectionState; ProvisioningState = provisioningState; }
internal PrivateEndpointConnection(string id, string name, string type, string etag, PrivateEndpoint privateEndpoint, PrivateLinkServiceConnectionState privateLinkServiceConnectionState, ProvisioningState?provisioningState, string linkIdentifier) : base(id) { Name = name; Type = type; Etag = etag; PrivateEndpoint = privateEndpoint; PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; ProvisioningState = provisioningState; LinkIdentifier = linkIdentifier; }
private IList <PrivateEndpointConnection> CreatePrivateEndpoints(ResourceGroup resourceGroup, string location, Server server, VirtualNetwork vnet, int n = 1) { string testPrefix = "privateendpointconnectioncrudtest-"; for (int i = 0; i < n; i++) { string privateEndpointName = SqlManagementTestUtilities.GenerateName(testPrefix); PrivateEndpoint pe = new PrivateEndpoint() { Location = location, ManualPrivateLinkServiceConnections = new List <PrivateLinkServiceConnection>() { new PrivateLinkServiceConnection() { Name = testPrefix + "pls", PrivateLinkServiceId = server.Id, GroupIds = new List <string>() { "sqlServer" }, RequestMessage = "Please approve my request" } }, Subnet = vnet.Subnets[0] }; PrivateEndpoint per = networkClient.PrivateEndpoints.CreateOrUpdate(resourceGroup.Name, privateEndpointName, pe); Assert.Equal(privateEndpointName, per.Name); Assert.Equal("Pending", per.ManualPrivateLinkServiceConnections[0].PrivateLinkServiceConnectionState.Status); } var pecs = sqlClient.PrivateEndpointConnections.ListByServer(resourceGroup.Name, server.Name).ToList(); Assert.Equal(n, (int)pecs.Count()); return(pecs); }
public PrivateEndpoint CreatePrivateEndpoint(string resourceGroupName, string privateEndpointNamePrefix, string privateLinkResourceId, string groupId, string subnetId, string location) { var privateEndpointName = $"{privateEndpointNamePrefix}PrivateEndpoint"; var serviceConnectionName = $"{privateEndpointNamePrefix}ServiceConnection"; var groupIds = new List <string>() { groupId }; var pe = new PrivateEndpoint(); pe.Subnet = new Subnet(id: subnetId); pe.Location = location; var plsConnection = new PrivateLinkServiceConnection(); plsConnection.Name = serviceConnectionName; plsConnection.PrivateLinkServiceId = privateLinkResourceId; plsConnection.GroupIds = groupIds; pe.PrivateLinkServiceConnections = new List <PrivateLinkServiceConnection>() { plsConnection }; return(WrappedNetworkClient.PrivateEndpoints.CreateOrUpdate(resourceGroupName, privateEndpointName, pe)); }
public PrivateEndpoint CreatePrivateEndpoint(string resourceGroupName, string privateEndpointName, PrivateEndpoint privateEndpointParameter) { return(networkManagementClient.PrivateEndpoints.CreateOrUpdate(resourceGroupName, privateEndpointName, privateEndpointParameter)); }
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))); }
/// <summary> /// Creates a Stream Analytics Private Endpoint or replaces an already existing /// Private Endpoint. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='privateEndpoint'> /// The definition of the private endpoint that will be used to create a new /// cluster or replace the existing one. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='clusterName'> /// The name of the cluster. /// </param> /// <param name='privateEndpointName'> /// The name of the private endpoint. /// </param> /// <param name='ifMatch'> /// The ETag of the resource. Omit this value to always overwrite the current /// record set. Specify the last-seen ETag value to prevent accidentally /// overwriting concurrent changes. /// </param> /// <param name='ifNoneMatch'> /// Set to '*' to allow a new resource to be created, but to prevent updating /// an existing record set. Other values will result in a 412 Pre-condition /// Failed response. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <PrivateEndpoint> CreateOrUpdateAsync(this IPrivateEndpointsOperations operations, PrivateEndpoint privateEndpoint, string resourceGroupName, string clusterName, string privateEndpointName, string ifMatch = default(string), string ifNoneMatch = default(string), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(privateEndpoint, resourceGroupName, clusterName, privateEndpointName, ifMatch, ifNoneMatch, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
internal static PrivateEndpointConnectionData DeserializePrivateEndpointConnectionData(JsonElement element) { Optional <string> etag = default; Optional <string> location = default; Optional <IReadOnlyDictionary <string, string> > tags = default; 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("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("location")) { location = 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("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, location.Value, Optional.ToDictionary(tags), etag.Value, privateEndpoint.Value, privateLinkServiceConnectionState.Value, Optional.ToNullable(provisioningState))); }
internal PrivateEndpointConnectionItem(PrivateEndpoint privateEndpoint, PrivateLinkServiceConnectionState privateLinkServiceConnectionState, PrivateEndpointConnectionProvisioningState?provisioningState) { PrivateEndpoint = privateEndpoint; PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; ProvisioningState = provisioningState; }
/// <summary> /// Update the state of specified private endpoint connection associated with /// the container registry. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group to which the container registry belongs. /// </param> /// <param name='registryName'> /// The name of the container registry. /// </param> /// <param name='privateEndpointConnectionName'> /// The name of the private endpoint connection. /// </param> /// <param name='privateEndpoint'> /// The resource of private endpoint. /// </param> /// <param name='privateLinkServiceConnectionState'> /// A collection of information about the state of the connection between /// service consumer and provider. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async System.Threading.Tasks.Task <PrivateEndpointConnection> BeginCreateOrUpdateAsync(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string registryName, string privateEndpointConnectionName, PrivateEndpoint privateEndpoint = default(PrivateEndpoint), PrivateLinkServiceConnectionState privateLinkServiceConnectionState = default(PrivateLinkServiceConnectionState), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, registryName, privateEndpointConnectionName, privateEndpoint, privateLinkServiceConnectionState, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates an private endpoint in the specified resource group. /// </summary> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='privateEndpointName'> /// The name of the private endpoint. /// </param> /// <param name='parameters'> /// Parameters supplied to the create or update private endpoint operation. /// </param> /// <param name='customHeaders'> /// The headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public async Task <AzureOperationResponse <PrivateEndpoint> > CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string privateEndpointName, PrivateEndpoint parameters, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send Request AzureOperationResponse <PrivateEndpoint> _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, privateEndpointName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); return(await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false)); }
/// <summary> /// Creates or updates an private endpoint in the specified resource group. /// </summary> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='privateEndpointName'> /// The name of the private endpoint. /// </param> /// <param name='parameters'> /// Parameters supplied to the create or update private endpoint operation. /// </param> /// <param name='customHeaders'> /// Headers that will be added to request. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> /// <exception cref="ErrorException"> /// Thrown when the operation returned an invalid status code /// </exception> /// <exception cref="SerializationException"> /// Thrown when unable to deserialize the response /// </exception> /// <exception cref="ValidationException"> /// Thrown when a required parameter is null /// </exception> /// <exception cref="System.ArgumentNullException"> /// Thrown when a required parameter is null /// </exception> /// <return> /// A response object containing the response body and response headers. /// </return> public async Task <AzureOperationResponse <PrivateEndpoint> > BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string privateEndpointName, PrivateEndpoint parameters, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceGroupName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); } if (privateEndpointName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "privateEndpointName"); } if (parameters == null) { throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } if (Client.SubscriptionId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; if (_shouldTrace) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("privateEndpointName", privateEndpointName); tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/privateEndpoints/{privateEndpointName}").ToString(); _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); _url = _url.Replace("{privateEndpointName}", System.Uri.EscapeDataString(privateEndpointName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List <string> _queryParameters = new List <string>(); if (Client.ApiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); } if (_queryParameters.Count > 0) { _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); } // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; _httpRequest.Method = new HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) { _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); } if (Client.AcceptLanguage != null) { if (_httpRequest.Headers.Contains("accept-language")) { _httpRequest.Headers.Remove("accept-language"); } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } if (customHeaders != null) { foreach (var _header in customHeaders) { if (_httpRequest.Headers.Contains(_header.Key)) { _httpRequest.Headers.Remove(_header.Key); } _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); } } // Serialize Request string _requestContent = null; if (parameters != null) { _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); _httpRequest.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); } // Set Credentials if (Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); } // Send Request if (_shouldTrace) { ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); } HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; if ((int)_statusCode != 200 && (int)_statusCode != 201) { var ex = new ErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); Error _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject <Error>(_responseContent, Client.DeserializationSettings); if (_errorBody != null) { ex.Body = _errorBody; } } catch (JsonException) { // Ignore the exception } ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); if (_shouldTrace) { ServiceClientTracing.Error(_invocationId, ex); } _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw ex; } // Create Result var _result = new AzureOperationResponse <PrivateEndpoint>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } // Deserialize Response if ((int)_statusCode == 200) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <PrivateEndpoint>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } // Deserialize Response if ((int)_statusCode == 201) { _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject <PrivateEndpoint>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) { _httpResponse.Dispose(); } throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); } return(_result); }
/// <summary> /// Creates or updates an private endpoint in the specified resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='privateEndpointName'> /// The name of the private endpoint. /// </param> /// <param name='parameters'> /// Parameters supplied to the create or update private endpoint operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <PrivateEndpoint> BeginCreateOrUpdateAsync(this IPrivateEndpointsOperations operations, string resourceGroupName, string privateEndpointName, PrivateEndpoint parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, privateEndpointName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates or updates an private endpoint in the specified resource group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='privateEndpointName'> /// The name of the private endpoint. /// </param> /// <param name='parameters'> /// Parameters supplied to the create or update private endpoint operation /// </param> public static PrivateEndpoint BeginCreateOrUpdate(this IPrivateEndpointsOperations operations, string resourceGroupName, string privateEndpointName, PrivateEndpoint parameters) { return(operations.BeginCreateOrUpdateAsync(resourceGroupName, privateEndpointName, parameters).GetAwaiter().GetResult()); }
public virtual async Task <Response <PrivateEndpointConnection> > PutAsync(string resourceGroupName, string accountName, string privateEndpointConnectionName, PrivateEndpoint privateEndpoint = null, PrivateLinkServiceConnectionState privateLinkServiceConnectionState = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("PrivateEndpointConnectionsClient.Put"); scope.Start(); try { return(await RestClient.PutAsync(resourceGroupName, accountName, privateEndpointConnectionName, privateEndpoint, privateLinkServiceConnectionState, cancellationToken).ConfigureAwait(false)); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual PrivateEndpointsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string privateEndpointName, PrivateEndpoint parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (privateEndpointName == null) { throw new ArgumentNullException(nameof(privateEndpointName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("PrivateEndpointsClient.StartCreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, privateEndpointName, parameters, cancellationToken); return(new PrivateEndpointsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, privateEndpointName, parameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }
internal static MachineLearningPrivateEndpointConnectionData DeserializeMachineLearningPrivateEndpointConnectionData(JsonElement element) { Optional <ManagedServiceIdentity> identity = default; Optional <AzureLocation> location = default; Optional <IDictionary <string, string> > tags = default; Optional <MachineLearningSku> sku = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <PrivateEndpoint> privateEndpoint = default; Optional <MachineLearningPrivateLinkServiceConnectionState> privateLinkServiceConnectionState = default; Optional <MachineLearningPrivateEndpointConnectionProvisioningState> provisioningState = 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("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("sku")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } sku = MachineLearningSku.DeserializeMachineLearningSku(property.Value); 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 = new ResourceType(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("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 = MachineLearningPrivateLinkServiceConnectionState.DeserializeMachineLearningPrivateLinkServiceConnectionState(property0.Value); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new MachineLearningPrivateEndpointConnectionProvisioningState(property0.Value.GetString()); continue; } } continue; } } return(new MachineLearningPrivateEndpointConnectionData(id, name, type, systemData, identity, Optional.ToNullable(location), Optional.ToDictionary(tags), sku.Value, privateEndpoint.Value, privateLinkServiceConnectionState.Value, Optional.ToNullable(provisioningState))); }
internal PrivateEndpointConnection(string id, string name, string type, PrivateEndpoint privateEndpoint, PrivateLinkServiceConnectionState privateLinkServiceConnectionState, string provisioningState) : base(id, name, type) { PrivateEndpoint = privateEndpoint; PrivateLinkServiceConnectionState = privateLinkServiceConnectionState; ProvisioningState = provisioningState; }
public async Task PrivateEndpointOperationsTest() { using (MockContext context = MockContext.Start(this.GetType())) { string resourceGroupName = TestUtilities.GenerateName("sjrg"); string clusterName = TestUtilities.GenerateName("sj"); string privateEndpointName = TestUtilities.GenerateName("testpe"); var resourceManagementClient = this.GetResourceManagementClient(context); var streamAnalyticsManagementClient = this.GetStreamAnalyticsManagementClient(context); string expectedClusterResourceId = TestHelper.GetClusterResourceId( streamAnalyticsManagementClient.SubscriptionId, resourceGroupName, clusterName); string expectedPrivateEndpointResourceId = TestHelper.GetPrivateEndpointResourceId( streamAnalyticsManagementClient.SubscriptionId, resourceGroupName, clusterName, privateEndpointName); string expectedPrivateLinkServiceId = "/subscriptions/113d0adc-1017-40e9-84ff-763f52896cc2/resourceGroups/sjrg5830/providers/Microsoft.EventHub/namespaces/testeventhub4asacluster"; Cluster exceptedCluster = new Cluster() { Location = TestHelper.DefaultLocation, Sku = new ClusterSku() { Name = ClusterSkuName.Default, Capacity = 36 } }; // Create Resource Group resourceManagementClient.ResourceGroups.CreateOrUpdate(resourceGroupName, new ResourceGroup { Location = TestHelper.DefaultLocation }); PrivateLinkServiceConnection privateLinkServiceConnection = new PrivateLinkServiceConnection() { PrivateLinkServiceId = expectedPrivateLinkServiceId, GroupIds = new string[] { "namespace" } }; PrivateEndpoint exceptedPrivateEndpoint = new PrivateEndpoint() { Properties = new PrivateEndpointProperties() { ManualPrivateLinkServiceConnections = new List <PrivateLinkServiceConnection> { privateLinkServiceConnection } } }; // PUT cluster var putCluster = await streamAnalyticsManagementClient.Clusters.CreateOrUpdateWithHttpMessagesAsync(exceptedCluster, resourceGroupName, clusterName);; // PUT privateendpoint var putPrivateEndpoint = await streamAnalyticsManagementClient.PrivateEndpoints.CreateOrUpdateWithHttpMessagesAsync(exceptedPrivateEndpoint, resourceGroupName, clusterName, privateEndpointName);; // Null out because secrets are not returned in responses Assert.Equal(expectedClusterResourceId, putCluster.Body.Id); Assert.Equal(clusterName, putCluster.Body.Name); Assert.Equal(TestHelper.ClusterFullResourceType, putCluster.Body.Type); Assert.Equal("Succeeded", putCluster.Body.Properties.ProvisioningState); Assert.Equal(privateEndpointName, putPrivateEndpoint.Body.Name); Assert.Equal(expectedPrivateLinkServiceId, putPrivateEndpoint.Body.Properties.ManualPrivateLinkServiceConnections[0].PrivateLinkServiceId); Assert.Equal(TestHelper.PrivateEndpointFullResourceType, putPrivateEndpoint.Body.Type); Assert.Equal("PendingCreation", putPrivateEndpoint.Body.Properties.ManualPrivateLinkServiceConnections[0].PrivateLinkServiceConnectionState.Status); // Verify GET request returns expected private endpoint var getPrivateEndpoint = await streamAnalyticsManagementClient.PrivateEndpoints.GetWithHttpMessagesAsync(resourceGroupName, clusterName, privateEndpointName); Assert.Equal(putPrivateEndpoint.Body.Etag, getPrivateEndpoint.Body.Etag); // List private endpoints var listByCluster = streamAnalyticsManagementClient.PrivateEndpoints.ListByCluster(resourceGroupName, clusterName); Assert.Single(listByCluster); // Delete private endpoints streamAnalyticsManagementClient.PrivateEndpoints.Delete(resourceGroupName, clusterName, privateEndpointName); // Verify that list operation returns an empty list after deleting the job listByCluster = streamAnalyticsManagementClient.PrivateEndpoints.ListByCluster(resourceGroupName, clusterName); Assert.Empty(listByCluster); } }
/// <summary> /// Update the state of specified private endpoint connection associated with /// the container registry. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group to which the container registry belongs. /// </param> /// <param name='registryName'> /// The name of the container registry. /// </param> /// <param name='privateEndpointConnectionName'> /// The name of the private endpoint connection. /// </param> /// <param name='privateEndpoint'> /// The resource of private endpoint. /// </param> /// <param name='privateLinkServiceConnectionState'> /// A collection of information about the state of the connection between /// service consumer and provider. /// </param> public static PrivateEndpointConnection CreateOrUpdate(this IPrivateEndpointConnectionsOperations operations, string resourceGroupName, string registryName, string privateEndpointConnectionName, PrivateEndpoint privateEndpoint = default(PrivateEndpoint), PrivateLinkServiceConnectionState privateLinkServiceConnectionState = default(PrivateLinkServiceConnectionState)) { return(operations.CreateOrUpdateAsync(resourceGroupName, registryName, privateEndpointConnectionName, privateEndpoint, privateLinkServiceConnectionState).GetAwaiter().GetResult()); }
/// <summary> /// Creates a Stream Analytics Private Endpoint or replaces an already existing /// Private Endpoint. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='privateEndpoint'> /// The definition of the private endpoint that will be used to create a new /// cluster or replace the existing one. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='clusterName'> /// The name of the cluster. /// </param> /// <param name='privateEndpointName'> /// The name of the private endpoint. /// </param> /// <param name='ifMatch'> /// The ETag of the resource. Omit this value to always overwrite the current /// record set. Specify the last-seen ETag value to prevent accidentally /// overwriting concurrent changes. /// </param> /// <param name='ifNoneMatch'> /// Set to '*' to allow a new resource to be created, but to prevent updating /// an existing record set. Other values will result in a 412 Pre-condition /// Failed response. /// </param> public static PrivateEndpoint CreateOrUpdate(this IPrivateEndpointsOperations operations, PrivateEndpoint privateEndpoint, string resourceGroupName, string clusterName, string privateEndpointName, string ifMatch = default(string), string ifNoneMatch = default(string)) { return(operations.CreateOrUpdateAsync(privateEndpoint, resourceGroupName, clusterName, privateEndpointName, ifMatch, ifNoneMatch).GetAwaiter().GetResult()); }
public PSPrivateEndpoint(PrivateEndpoint privateEndpoint) { this.Id = privateEndpoint?.Id; }
internal static WebPubSubPrivateEndpointConnectionData DeserializeWebPubSubPrivateEndpointConnectionData(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <ProvisioningState> provisioningState = default; Optional <PrivateEndpoint> privateEndpoint = default; Optional <IReadOnlyList <string> > groupIds = default; Optional <WebPubSubPrivateLinkServiceConnectionState> privateLinkServiceConnectionState = 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("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("privateEndpoint")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } privateEndpoint = PrivateEndpoint.DeserializePrivateEndpoint(property0.Value); continue; } if (property0.NameEquals("groupIds")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(item.GetString()); } groupIds = array; continue; } if (property0.NameEquals("privateLinkServiceConnectionState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } privateLinkServiceConnectionState = WebPubSubPrivateLinkServiceConnectionState.DeserializeWebPubSubPrivateLinkServiceConnectionState(property0.Value); continue; } } continue; } } return(new WebPubSubPrivateEndpointConnectionData(id, name, type, systemData, Optional.ToNullable(provisioningState), privateEndpoint.Value, Optional.ToList(groupIds), privateLinkServiceConnectionState.Value)); }