示例#1
0
        private async Task <UserCollection> GetApiManagementUsersAsync(string subscriptionId, string resourceGroup, string apiManagementName, string nextLink = "")
        {
            var responseValue = "";
            var urlEnd        = "";

            if (nextLink != "")
            {
                urlEnd = nextLink.Substring(nextLink.IndexOf("2019-01-01") + 10);
            }

            responseValue = await ExecuteGetRequest("https://management.azure.com/subscriptions/", subscriptionId, resourceGroup, apiManagementName, "/users", "?api-version=2019-01-01" + urlEnd);

            if (responseValue != null && !responseValue.Equals(string.Empty))
            {
                UserCollection users = System.Text.Json.JsonSerializer.Deserialize <UserCollection>(responseValue);
                foreach (var user in users.value)
                {
                    GroupContractCollection groups = await GerUserGroups(subscriptionId, resourceGroup, apiManagementName, user.Id);

                    user.Properties.Groups = groups;
                    user.sourceAPIM        = apiManagementName;
                }
                return(users);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        private async Task <UserCollection> GetApiManagementUsersAsync(string subscriptionId, string resourceGroup, string apiManagementName, int startAt = 0)
        {
            var responseValue = "";
            var urlParameters = "?api-version=2019-01-01";

            if (startAt != 0)
            {
                urlParameters += "&$skip=" + startAt;
            }

            responseValue = await ExecuteGetRequest("https://management.azure.com/subscriptions/", subscriptionId, resourceGroup, apiManagementName, "/users", urlParameters);

            if (responseValue != null && !responseValue.Equals(string.Empty))
            {
                UserCollection users = System.Text.Json.JsonSerializer.Deserialize <UserCollection>(responseValue);
                foreach (var user in users.value)
                {
                    GroupContractCollection groups = await GerUserGroups(subscriptionId, resourceGroup, apiManagementName, user.Id);

                    user.Properties.Groups = groups;
                    user.sourceAPIM        = apiManagementName;
                }
                return(users);
            }
            else
            {
                return(null);
            }
        }