public override void ExecuteCmdlet()
        {
            SharedPrivateLinkResource resource =
                new SharedPrivateLinkResource(
                    name: Name,
                    properties: new SharedPrivateLinkResourceProperties
            {
                GroupId = GroupId,
                PrivateLinkResourceId = PrivateLinkResourceId,
                RequestMessage        = RequestMessage,
                ResourceRegion        = ResourceRegion
            });

            if (ShouldProcess(Name, Resources.CreateSharedPrivateLinkResource))
            {
                CatchThrowInnerException(() =>
                {
                    var response =
                        SearchClient.SharedPrivateLinkResources.CreateOrUpdateWithHttpMessagesAsync(
                            ResourceGroupName,
                            ServiceName,
                            Name,
                            resource).Result;

                    WriteSharedPrivateLinkResource(response.Body);
                });
            }
        }
 protected void WriteSharedPrivateLinkResource(SharedPrivateLinkResource resource)
 {
     if (resource != null)
     {
         WriteObject((PSSharedPrivateLinkResource)resource);
     }
 }
Exemplo n.º 3
0
        public static PSAfdOrigin ToPSAfdOrigin(this SdkAfdOrigin sdkOrigin)
        {
            JObject sharedPrivateLinkResourceJObject = (JObject)sdkOrigin.SharedPrivateLinkResource;

            SharedPrivateLinkResource sharedPrivateLinkResource = null;

            if (sharedPrivateLinkResourceJObject != null)
            {
                sharedPrivateLinkResource = sharedPrivateLinkResourceJObject.ToObject <SharedPrivateLinkResource>();
            }

            // origin group name is not present here since it is not provided by the SDK
            // we extract the origin group name via the input and utility methods and then add it to the PSAfdOrigin
            return(new PSAfdOrigin
            {
                Id = sdkOrigin.Id,
                Name = sdkOrigin.Name,
                Type = sdkOrigin.Type,
                ProvisioningState = sdkOrigin.ProvisioningState,
                HostName = sdkOrigin.HostName,
                HttpPort = sdkOrigin.HttpPort,
                HttpsPort = sdkOrigin.HttpsPort,
                OriginHostHeader = sdkOrigin.OriginHostHeader,
                Priority = sdkOrigin.Priority,
                Weight = sdkOrigin.Weight,
                EnabledState = sdkOrigin.EnabledState,
                PrivateLinkId = sharedPrivateLinkResource?.PrivateLink?.Id,
                //PrivateLinkGroupId = sharedPrivateLinkResource?.GroupId, // confirm this field
                PrivateLinkLocation = sharedPrivateLinkResource?.PrivateLinkLocation,
                //PrivateLinkStatus = sharedPrivateLinkResource?.Status, // confirm this field
                PrivateLinkRequestMessage = sharedPrivateLinkResource?.RequestMessage
            });
        }
Exemplo n.º 4
0
        public void CanPerformSharedPrivateLinkManagement()
        {
            Run(() =>
            {
                SearchManagementClient searchMgmt = GetSearchManagementClient();

                SharedPrivateLinkResource resource = searchMgmt.SharedPrivateLinkResources.CreateOrUpdate(
                    Data.ResourceGroupName,
                    Data.ServiceName,
                    Data.SharedPrivateLinkResourceName,
                    new SharedPrivateLinkResource(
                        name: Data.SharedPrivateLinkResourceName,
                        properties: new SharedPrivateLinkResourceProperties(
                            privateLinkResourceId: Data.StorageAccountId,
                            groupId: Data.SharedPrivateLinkResourceGroupId,
                            requestMessage: Data.SharedPrivateLinkResourceRequestMessage)));

                Assert.NotNull(resource);

                resource = searchMgmt.SharedPrivateLinkResources.Get(
                    Data.ResourceGroupName,
                    Data.ServiceName,
                    Data.SharedPrivateLinkResourceName);

                Assert.EndsWith($"/sharedPrivateLinkResources/{Data.SharedPrivateLinkResourceName}", resource.Id);
                Assert.Equal("Microsoft.Search/searchServices/sharedPrivateLinkResources", resource.Type);
                Assert.Equal(SharedPrivateLinkResourceProvisioningState.Succeeded, resource.Properties.ProvisioningState);
                Assert.Equal(SharedPrivateLinkResourceStatus.Pending, resource.Properties.Status);

                var resources = searchMgmt.SharedPrivateLinkResources.ListByService(
                    Data.ResourceGroupName,
                    Data.ServiceName);

                Assert.Single(resources);

                // shouldn't throw an exception
                searchMgmt.SharedPrivateLinkResources.Delete(
                    Data.ResourceGroupName,
                    Data.ServiceName,
                    Data.SharedPrivateLinkResourceName);
            });
        }
Exemplo n.º 5
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(ResourceIdParameterSetName, StringComparison.InvariantCulture))
            {
                SetParameters(ResourceId);
            }
            else if (ParameterSetName.Equals(InputObjectParameterSetName, StringComparison.InvariantCulture))
            {
                SetParameters(InputObject.Id);
            }
            else if (ParameterSetName.Equals(ParentObjectParameterSetName, StringComparison.InvariantCulture))
            {
                ResourceGroupName = ParentObject.ResourceGroupName;
                ServiceName       = ParentObject.Name;
            }

            if (ShouldProcess(Name, Resources.UpdateSharedPrivateLinkResource))
            {
                CatchThrowInnerException(() =>
                {
                    SharedPrivateLinkResource resource =
                        SearchClient.SharedPrivateLinkResources.GetWithHttpMessagesAsync(
                            ResourceGroupName,
                            ServiceName,
                            Name).Result.Body;

                    // only allowed to update this
                    resource.Properties.RequestMessage = RequestMessage;

                    var response =
                        SearchClient.SharedPrivateLinkResources.CreateOrUpdateWithHttpMessagesAsync(
                            ResourceGroupName,
                            ServiceName,
                            Name,
                            resource).Result;

                    WriteSharedPrivateLinkResource(response.Body);
                });
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Creates or updates a shared private link resource managed by the Search
 /// service in the given resource group.
 /// <see href="https://aka.ms/search-manage" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group within the current subscription. You can
 /// obtain this value from the Azure Resource Manager API or the portal.
 /// </param>
 /// <param name='searchServiceName'>
 /// The name of the Azure Cognitive Search service associated with the
 /// specified resource group.
 /// </param>
 /// <param name='sharedPrivateLinkResourceName'>
 /// The name of the shared private link resource managed by the Azure Cognitive
 /// Search service within the specified resource group.
 /// </param>
 /// <param name='sharedPrivateLinkResource'>
 /// The definition of the shared private link resource to create or update.
 /// </param>
 /// <param name='searchManagementRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SharedPrivateLinkResource> CreateOrUpdateAsync(this ISharedPrivateLinkResourcesOperations operations, string resourceGroupName, string searchServiceName, string sharedPrivateLinkResourceName, SharedPrivateLinkResource sharedPrivateLinkResource, SearchManagementRequestOptions searchManagementRequestOptions = default(SearchManagementRequestOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, searchServiceName, sharedPrivateLinkResourceName, sharedPrivateLinkResource, searchManagementRequestOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Creates or updates a shared private link resource managed by the Search
 /// service in the given resource group.
 /// <see href="https://aka.ms/search-manage" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group within the current subscription. You can
 /// obtain this value from the Azure Resource Manager API or the portal.
 /// </param>
 /// <param name='searchServiceName'>
 /// The name of the Azure Cognitive Search service associated with the
 /// specified resource group.
 /// </param>
 /// <param name='sharedPrivateLinkResourceName'>
 /// The name of the shared private link resource managed by the Azure Cognitive
 /// Search service within the specified resource group.
 /// </param>
 /// <param name='sharedPrivateLinkResource'>
 /// The definition of the shared private link resource to create or update.
 /// </param>
 /// <param name='searchManagementRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static SharedPrivateLinkResource CreateOrUpdate(this ISharedPrivateLinkResourcesOperations operations, string resourceGroupName, string searchServiceName, string sharedPrivateLinkResourceName, SharedPrivateLinkResource sharedPrivateLinkResource, SearchManagementRequestOptions searchManagementRequestOptions = default(SearchManagementRequestOptions))
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, searchServiceName, sharedPrivateLinkResourceName, sharedPrivateLinkResource, searchManagementRequestOptions).GetAwaiter().GetResult());
 }
Exemplo n.º 8
0
 /// <summary>
 /// Create or update a shared private link resource
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='sharedPrivateLinkResourceName'>
 /// The name of the shared private link resource
 /// </param>
 /// <param name='parameters'>
 /// The shared private link resource
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group that contains the resource. You can obtain
 /// this value from the Azure Resource Manager API or the portal.
 /// </param>
 /// <param name='resourceName'>
 /// The name of the resource.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SharedPrivateLinkResource> BeginCreateOrUpdateAsync(this ISignalRSharedPrivateLinkResourcesOperations operations, string sharedPrivateLinkResourceName, SharedPrivateLinkResource parameters, string resourceGroupName, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(sharedPrivateLinkResourceName, parameters, resourceGroupName, resourceName, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Create or update a shared private link resource
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='sharedPrivateLinkResourceName'>
 /// The name of the shared private link resource
 /// </param>
 /// <param name='parameters'>
 /// The shared private link resource
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group that contains the resource. You can obtain
 /// this value from the Azure Resource Manager API or the portal.
 /// </param>
 /// <param name='resourceName'>
 /// The name of the resource.
 /// </param>
 public static SharedPrivateLinkResource BeginCreateOrUpdate(this ISignalRSharedPrivateLinkResourcesOperations operations, string sharedPrivateLinkResourceName, SharedPrivateLinkResource parameters, string resourceGroupName, string resourceName)
 {
     return(operations.BeginCreateOrUpdateAsync(sharedPrivateLinkResourceName, parameters, resourceGroupName, resourceName).GetAwaiter().GetResult());
 }
Exemplo n.º 10
0
        internal static MachineLearningWorkspaceData DeserializeMachineLearningWorkspaceData(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 <string>              workspaceId                     = default;
            Optional <string>              description                     = default;
            Optional <string>              friendlyName                    = default;
            Optional <string>              keyVault                        = default;
            Optional <string>              applicationInsights             = default;
            Optional <string>              containerRegistry               = default;
            Optional <string>              storageAccount                  = default;
            Optional <Uri>                 discoveryUrl                    = default;
            Optional <ProvisioningState>   provisioningState               = default;
            Optional <EncryptionProperty>  encryption                      = default;
            Optional <bool>                hbiWorkspace                    = default;
            Optional <string>              serviceProvisionedResourceGroup = default;
            Optional <int>                 privateLinkCount                = default;
            Optional <string>              imageBuildCompute               = default;
            Optional <bool>                allowPublicAccessWhenBehindVnet = default;
            Optional <PublicNetworkAccess> publicNetworkAccess             = default;
            Optional <IReadOnlyList <MachineLearningPrivateEndpointConnectionData> > privateEndpointConnections = default;
            Optional <IList <SharedPrivateLinkResource> > sharedPrivateLinkResources = default;
            Optional <NotebookResourceInfo>            notebookInfo = default;
            Optional <ServiceManagedResourcesSettings> serviceManagedResourcesSettings = default;
            Optional <string> primaryUserAssignedIdentity = default;
            Optional <Guid>   tenantId          = default;
            Optional <bool>   storageHnsEnabled = default;
            Optional <Uri>    mlFlowTrackingUri = 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("workspaceId"))
                        {
                            workspaceId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("description"))
                        {
                            description = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("friendlyName"))
                        {
                            friendlyName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("keyVault"))
                        {
                            keyVault = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("applicationInsights"))
                        {
                            applicationInsights = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("containerRegistry"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                containerRegistry = null;
                                continue;
                            }
                            containerRegistry = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("storageAccount"))
                        {
                            storageAccount = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("discoveryUrl"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                discoveryUrl = null;
                                continue;
                            }
                            discoveryUrl = new Uri(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("encryption"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            encryption = EncryptionProperty.DeserializeEncryptionProperty(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("hbiWorkspace"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            hbiWorkspace = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("serviceProvisionedResourceGroup"))
                        {
                            serviceProvisionedResourceGroup = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("privateLinkCount"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            privateLinkCount = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("imageBuildCompute"))
                        {
                            imageBuildCompute = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("allowPublicAccessWhenBehindVnet"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            allowPublicAccessWhenBehindVnet = 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("privateEndpointConnections"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <MachineLearningPrivateEndpointConnectionData> array = new List <MachineLearningPrivateEndpointConnectionData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(MachineLearningPrivateEndpointConnectionData.DeserializeMachineLearningPrivateEndpointConnectionData(item));
                            }
                            privateEndpointConnections = array;
                            continue;
                        }
                        if (property0.NameEquals("sharedPrivateLinkResources"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <SharedPrivateLinkResource> array = new List <SharedPrivateLinkResource>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(SharedPrivateLinkResource.DeserializeSharedPrivateLinkResource(item));
                            }
                            sharedPrivateLinkResources = array;
                            continue;
                        }
                        if (property0.NameEquals("notebookInfo"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            notebookInfo = NotebookResourceInfo.DeserializeNotebookResourceInfo(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("serviceManagedResourcesSettings"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            serviceManagedResourcesSettings = ServiceManagedResourcesSettings.DeserializeServiceManagedResourcesSettings(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("primaryUserAssignedIdentity"))
                        {
                            primaryUserAssignedIdentity = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("tenantId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            tenantId = property0.Value.GetGuid();
                            continue;
                        }
                        if (property0.NameEquals("storageHnsEnabled"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            storageHnsEnabled = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("mlFlowTrackingUri"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                mlFlowTrackingUri = null;
                                continue;
                            }
                            mlFlowTrackingUri = new Uri(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new MachineLearningWorkspaceData(id, name, type, systemData, identity, Optional.ToNullable(location), Optional.ToDictionary(tags), sku.Value, workspaceId.Value, description.Value, friendlyName.Value, keyVault.Value, applicationInsights.Value, containerRegistry.Value, storageAccount.Value, discoveryUrl.Value, Optional.ToNullable(provisioningState), encryption.Value, Optional.ToNullable(hbiWorkspace), serviceProvisionedResourceGroup.Value, Optional.ToNullable(privateLinkCount), imageBuildCompute.Value, Optional.ToNullable(allowPublicAccessWhenBehindVnet), Optional.ToNullable(publicNetworkAccess), Optional.ToList(privateEndpointConnections), Optional.ToList(sharedPrivateLinkResources), notebookInfo.Value, serviceManagedResourcesSettings.Value, primaryUserAssignedIdentity.Value, Optional.ToNullable(tenantId), Optional.ToNullable(storageHnsEnabled), mlFlowTrackingUri.Value));
        }