Skip to content

Commit f297542

Browse files
committed
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-python into assertions
* 'master' of https://github.com/Azure/azure-sdk-for-python: [core] add HttpRequest and HttpResponse reprs (Azure#16972) [text analytics] add actual normalized_text tests (Azure#17123) update samples to use actual role names (Azure#17124) Sync eng/common directory with azure-sdk-tools for PR 1448 (Azure#17085) Enable APIView status check (Azure#17107) Fix PackageName typo (Azure#17109) Move SetTestPipelineVersion.ps1 to eng/common (Azure#17103) Fix paths for non-windows agents (Azure#17096) [Communication] - Identity - Update README (Azure#17091) Rename CertificateCredential's certificate_bytes -> certificate_data (Azure#17090) fix shared reqs (Azure#17095) [translation] initial library (Azure#16837) EG - more docs imrpovement (Azure#17079) [EventHubs] add logging.info to warn the usage of partition key of non-string type (Azure#17057) march release (Azure#16966) Release of Device Update for IoT Hub SDK for Python. (Azure#17005) Add Get-AllPackageInfoFromRepo (Azure#16947) Track1 package is incorrectly set as track2 (Azure#17075)
2 parents 9c67431 + d728b2f commit f297542

File tree

236 files changed

+21140
-886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+21140
-886
lines changed

eng/common/pipelines/templates/steps/create-apireview.yml

-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ steps:
1919
workingDirectory: $(Pipeline.Workspace)
2020
displayName: Create API Review for ${{ artifact.name}}
2121
condition: and(succeededOrFailed(), ne(variables['Skip.CreateApiReview'], 'true') , ne(variables['Build.Reason'],'PullRequest'), eq(variables['System.TeamProject'], 'internal'))
22-
continueOnError: true

eng/common/scripts/Create-APIReview.ps1

+12-9
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ function Submit-APIReview($packagename, $filePath, $uri, $apiKey, $apiLabel)
4141
try
4242
{
4343
$Response = Invoke-WebRequest -Method 'POST' -Uri $uri -Body $multipartContent -Headers $headers
44-
Write-Host "API Review: $($Response)"
44+
Write-Host "API Review URL: $($Response.Content)"
4545
$StatusCode = $Response.StatusCode
4646
}
4747
catch
4848
{
49+
Write-Host "Exception details: $($_.Exception.Response)"
4950
$StatusCode = $_.Exception.Response.StatusCode
5051
}
5152

@@ -101,6 +102,9 @@ foreach ($pkgName in $responses.Keys)
101102
{
102103
$pkgInfo = Get-Content $pkgPropPath | ConvertFrom-Json
103104
$version = [AzureEngSemanticVersion]::ParseVersionString($pkgInfo.Version)
105+
Write-Host "Package name: $($PackageName)"
106+
Write-Host "Version: $($version)"
107+
Write-Host "SDK Type: $($pkgInfo.SdkType)"
104108
if ($version.IsPrerelease)
105109
{
106110
Write-Host "Package version is not GA. Ignoring API view approval status"
@@ -110,12 +114,16 @@ foreach ($pkgName in $responses.Keys)
110114
$FoundFailure = $True
111115
if ($respCode -eq '201')
112116
{
113-
Write-Error "Automatic API Review approval is pending for package $($PackageName)"
117+
Write-Host "Package version $($version) is GA and automatic API Review is not yet approved for package $($PackageName)."
118+
Write-Host "Build and release is not allowed for GA package without API review approval."
119+
Write-Host "You will need to queue another build to proceed further after API review is approved"
120+
Write-Host "You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on API Approval."
114121
}
115122
else
116123
{
117-
Write-Error "Failed to create API Review for package $($PackageName)"
118-
}
124+
Write-Host "Failed to create API Review for package $($PackageName). Please reach out to Azure SDK engineering systems on teams channel and share this build details."
125+
}
126+
exit 1
119127
}
120128
else
121129
{
@@ -124,8 +132,3 @@ foreach ($pkgName in $responses.Keys)
124132
}
125133
}
126134
}
127-
if ($FoundFailure)
128-
{
129-
Write-Error "Automatic API review is not yet approved for package $($PackageName)"
130-
exit 1
131-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Sets a valid version for a package using the buildID
2+
3+
param (
4+
[Parameter(mandatory = $true)]
5+
$BuildID,
6+
[Parameter(mandatory = $true)]
7+
$PackageName,
8+
[Parameter(mandatory = $true)]
9+
$ServiceDirectory
10+
)
11+
12+
. common.ps1
13+
14+
$latestTags = git tag -l "${PackageName}_*"
15+
$semVars = @()
16+
17+
Foreach ($tags in $latestTags)
18+
{
19+
$semVars += $tags.Replace("${PackageName}_", "")
20+
}
21+
22+
$semVarsSorted = [AzureEngSemanticVersion]::SortVersionStrings($semVars)
23+
LogDebug "Last Published Version $($semVarsSorted[0])"
24+
25+
$newVersion = [AzureEngSemanticVersion]::new($semVarsSorted[0])
26+
$newVersion.PrereleaseLabel = $newVersion.DefaultPrereleaseLabel
27+
$newVersion.PrereleaseNumber = $BuildID
28+
29+
LogDebug "Version to publish [ $($newVersion.ToString()) ]"
30+
31+
SetPackageVersion -PackageName $PackagName `
32+
-Version $newVersion `
33+
-ServiceDirectory $ServiceDirectory `

eng/scripts/Language-Settings.ps1

+53-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,58 @@ $packagePattern = "*.zip"
55
$MetadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/python-packages.csv"
66
$BlobStorageUrl = "https://azuresdkdocs.blob.core.windows.net/%24web?restype=container&comp=list&prefix=python%2F&delimiter=%2F"
77

8+
function Get-AllPackageInfoFromRepo ($serviceDirectory)
9+
{
10+
$allPackageProps = @()
11+
$searchPath = Join-Path sdk * * setup.py
12+
if ($serviceDirectory)
13+
{
14+
$searchPath = Join-Path sdk ${serviceDirectory} * setup.py
15+
}
16+
17+
$allPkgPropLines = $null
18+
try
19+
{
20+
Push-Location $RepoRoot
21+
pip install packaging==20.4 -q -I
22+
$allPkgPropLines = python (Join-path eng scripts get_package_properties.py) -s $searchPath
23+
}
24+
catch
25+
{
26+
# This is soft error and failure is expected for python metapackages
27+
LogError "Failed to get all package properties"
28+
}
29+
finally
30+
{
31+
Pop-Location
32+
}
33+
34+
foreach ($line in $allPkgPropLines)
35+
{
36+
$pkgInfo = ($line -Split ",").Trim("()' ")
37+
$packageName = $pkgInfo[0]
38+
$packageVersion = $pkgInfo[1]
39+
$isNewSdk = ($pkgInfo[2] -eq "True")
40+
$setupPyDir = $pkgInfo[3]
41+
$pkgDirectoryPath = Resolve-Path (Join-Path -Path $RepoRoot $setupPyDir)
42+
$serviceDirectoryName = Split-Path (Split-Path -Path $pkgDirectoryPath -Parent) -Leaf
43+
if ($packageName -match "mgmt")
44+
{
45+
$sdkType = "mgmt"
46+
}
47+
else
48+
{
49+
$sdkType = "client"
50+
}
51+
$pkgProp = [PackageProps]::new($packageName, $packageVersion, $pkgDirectoryPath, $serviceDirectoryName)
52+
$pkgProp.IsNewSdk = $isNewSdk
53+
$pkgProp.SdkType = $sdkType
54+
$pkgProp.ArtifactName = $packageName
55+
$allPackageProps += $pkgProp
56+
}
57+
return $allPackageProps
58+
}
59+
860
function Get-python-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName)
961
{
1062
$packageName = $pkgName.Replace('_', '-')
@@ -41,7 +93,7 @@ function Get-python-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName)
4193
{
4294
$pkgProp.SdkType = "client"
4395
}
44-
$pkgProp.IsNewSdk = $setupProps[2]
96+
$pkgProp.IsNewSdk = ($setupProps[2] -eq "True")
4597
$pkgProp.ArtifactName = $pkgName
4698
return $pkgProp
4799
}

eng/scripts/get_package_properties.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import argparse
2+
import sys
3+
import glob
4+
import os
5+
6+
sys.path.append(os.path.join('scripts', 'devops_tasks'))
7+
from common_tasks import get_package_properties
8+
9+
if __name__ == '__main__':
10+
parser = argparse.ArgumentParser(description='Get package version details from the repo')
11+
parser.add_argument('-s', '--search_path', required=True, help='The scope of the search')
12+
args = parser.parse_args()
13+
14+
for p in glob.glob(args.search_path, recursive=True):
15+
if os.path.basename(os.path.dirname(p)) != 'azure-mgmt' and os.path.basename(os.path.dirname(p)) != 'azure' and os.path.basename(os.path.dirname(p)) != 'azure-storage':
16+
print(get_package_properties(os.path.dirname(p)))

sdk/communication/azure-communication-identity/README.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Azure Communication Identity Package client library for Python
44

5-
Azure Communication Identity client package is intended to be used to setup the basics for opening a way to use Azure Communication Service offerings. This package helps to create identities user tokens to be used by other client packages such as chat, calling, sms.
5+
Azure Communication Identity client package is intended to be used to setup the basics for opening a way to use Azure Communication Service offerings. This package helps to create identity user tokens to be used by other client packages such as chat, calling, sms.
66

77
[Source code](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-identity) | [Package (Pypi)](https://pypi.org/project/azure-communication-identity/) | [API reference documentation](https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/communication/azure-communication-identity) | [Product documentation](https://docs.microsoft.com/azure/communication-services/quickstarts/access-tokens?pivots=programming-language-python)
88

@@ -51,21 +51,12 @@ The following section provides several code snippets covering some of the most c
5151

5252
### Creating a new user
5353

54-
Use the `create_user` method to create a new user.
54+
Use the `create_user` method to create a new user.
5555
```python
5656
user = identity_client.create_user()
5757
print("User created with id:" + user.identifier)
5858
```
5959

60-
Alternatively, use the `create_user_and_token` method to create a new user and issue a token for it.\
61-
For this option, a list of `CommunicationTokenScope` must be defined (see "Issuing an access token" for more information)
62-
63-
```python
64-
user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
65-
print("User id:" + user.identifier)
66-
print("Token issued with value: " + tokenresponse.token)
67-
```
68-
6960
### Issuing or Refreshing an access token for a user
7061

7162
Use the `get_token` method to issue or refresh a scoped access token for the user. \
@@ -77,6 +68,14 @@ Pass in the user object as a parameter, and a list of `CommunicationTokenScope`.
7768
tokenresponse = identity_client.get_token(user, scopes=[CommunicationTokenScope.CHAT])
7869
print("Token issued with value: " + tokenresponse.token)
7970
```
71+
### Creating a user and a token in a single request
72+
For convenience, use `create_user_and_token` to create a new user and issue a token with one function call. This translates into a single web request as opposed to creating a user first and then issuing a token.
73+
74+
```python
75+
user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
76+
print("User id:" + user.identifier)
77+
print("Token issued with value: " + tokenresponse.token)
78+
```
8079

8180
### Revoking a user's access tokens
8281

sdk/core/azure-core/CHANGELOG.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Release History
22

3-
## 1.12.0 (Unreleased)
3+
## 1.12.0 (2021-03-08)
44

55
### Features
66

77
- Added `azure.core.messaging.CloudEvent` model that follows the cloud event spec.
8-
- Added `azure.core.serialization.NULL` sentinel value
8+
- Added `azure.core.serialization.NULL` sentinel value
9+
10+
### Bug Fixes
11+
12+
- Improve `repr`s for `HttpRequest` and `HttpResponse`s #16972
913

1014
## 1.11.0 (2021-02-08)
1115

sdk/core/azure-core/azure/core/pipeline/transport/_base.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ def __init__(self, method, url, headers=None, files=None, data=None):
234234
self.multipart_mixed_info = None # type: Optional[Tuple]
235235

236236
def __repr__(self):
237-
return "<HttpRequest [%s]>" % (self.method)
237+
return "<HttpRequest [{}], url: '{}'>".format(
238+
self.method, self.url
239+
)
238240

239241
def __deepcopy__(self, memo=None):
240242
try:
@@ -592,6 +594,15 @@ def raise_for_status(self):
592594
if self.status_code >= 400:
593595
raise HttpResponseError(response=self)
594596

597+
def __repr__(self):
598+
# there doesn't have to be a content type
599+
content_type_str = (
600+
", Content-Type: {}".format(self.content_type) if self.content_type else ""
601+
)
602+
return "<{}: {} {}{}>".format(
603+
type(self).__name__, self.status_code, self.reason, content_type_str
604+
)
605+
595606

596607
class HttpResponse(_HttpResponseBase): # pylint: disable=abstract-method
597608
def stream_download(self, pipeline):

sdk/core/azure-core/tests/async_tests/test_universal_http_async.py

+11
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ def __init__(self, body_bytes, headers=None):
9898
self._body = body_bytes
9999
self._headers = headers
100100
self._cache = {}
101+
self.status = 200
102+
self.reason = "OK"
101103

102104
req_response = MockAiohttpClientResponse(body_bytes, headers)
103105

@@ -120,3 +122,12 @@ async def test_aiohttp_response_text():
120122
{'Content-Type': 'text/plain'}
121123
)
122124
assert res.text(encoding) == '56', "Encoding {} didn't work".format(encoding)
125+
126+
def test_repr():
127+
res = _create_aiohttp_response(
128+
b'\xef\xbb\xbf56',
129+
{}
130+
)
131+
res.content_type = "text/plain"
132+
133+
assert repr(res) == "<AioHttpTransportResponse: 200 OK, Content-Type: text/plain>"

sdk/core/azure-core/tests/test_pipeline.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def test_request_url_with_params(self):
285285
request.format_parameters({"g": "h"})
286286

287287
self.assertIn(request.url, ["a/b/c?g=h&t=y", "a/b/c?t=y&g=h"])
288-
288+
289289
def test_request_url_with_params_as_list(self):
290290

291291
request = HttpRequest("GET", "/")
@@ -300,7 +300,7 @@ def test_request_url_with_params_with_none_in_list(self):
300300
request.url = "a/b/c?t=y"
301301
with pytest.raises(ValueError):
302302
request.format_parameters({"g": ["h",None]})
303-
303+
304304
def test_request_url_with_params_with_none(self):
305305

306306
request = HttpRequest("GET", "/")
@@ -328,6 +328,10 @@ def test_request_text(self):
328328
# We want a direct string
329329
assert request.data == "foo"
330330

331+
def test_repr(self):
332+
request = HttpRequest("GET", "hello.com")
333+
assert repr(request) == "<HttpRequest [GET], url: 'hello.com'>"
334+
331335

332336
if __name__ == "__main__":
333337
unittest.main()

sdk/core/azure-core/tests/test_requests_universal.py

+7
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,10 @@ def test_requests_response_text():
8282
{'Content-Type': 'text/plain'}
8383
)
8484
assert res.text(encoding) == '56', "Encoding {} didn't work".format(encoding)
85+
86+
def test_repr():
87+
res = _create_requests_response(
88+
b'\xef\xbb\xbf56',
89+
{'Content-Type': 'text/plain'}
90+
)
91+
assert repr(res) == "<RequestsTransportResponse: 200 OK, Content-Type: text/plain>"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Release History
2+
3+
## 1.0.0b1 (2021-03-03)
4+
* This is the initial release of Azure Device Update for IoT Hub library.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
recursive-include tests *.py
2+
recursive-include samples *.py *.md
3+
include *.md
4+
include azure/__init__.py
5+
include azure/iot/__init__.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Azure Device Update for IoT Hub client library for Python
2+
3+
The library provides access to the Device Update for IoT Hub service that enables customers to publish updates for their IoT devices to the cloud, and then deploy these updates to their devices (approve updates to groups of devices managed and provisioned in IoT Hub).
4+
5+
[Source code](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/deviceupdate/azure-iot-deviceupdate) | [Package (PyPI)](https://aka.ms/azsdk/python/deviceupdate-pypi) | [Product documentation](https://docs.microsoft.com/azure/iot-hub-device-update/understand-device-update)
6+
7+
## Getting started
8+
9+
### Prerequisites
10+
11+
- Microsoft Azure Subscription: To call Microsoft Azure services, you need to create an [Azure subscription](https://azure.microsoft.com/free/)
12+
- Device Update for IoT Hub instance
13+
- Azure IoT Hub instance
14+
- Python 2.7, or 3.6 or later is required to use this package.
15+
16+
### Install the package
17+
18+
Install the Device Update for IoT Hub client library for Python with [pip](https://pypi.org/project/pip/):
19+
20+
```bash
21+
pip install azure-iot-deviceupdate --pre
22+
```
23+
24+
## Key concepts
25+
26+
Device Update for IoT Hub is a managed service that enables you to deploy over-the-air updates for your IoT devices. The client library has one main component named **AzureDeviceUpdateServiceDataPlane**. The component allows you to access all three main client services:
27+
28+
- **UpdatesOperations**: update management (import, enumerate, delete, etc.)
29+
- **DevicesOperations**: device management (enumerate devices and retrieve device properties)
30+
- **DeploymentsOperations**: deployment management (start and monitor update deployments to a set of devices)
31+
32+
You can learn more about Device Update for IoT Hub by visiting [Device Update for IoT Hub](https://github.com/azure/iot-hub-device-update).
33+
34+
## Examples
35+
36+
You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/deviceupdate/azure-iot-deviceupdate/samples).
37+
38+
## Troubleshooting
39+
40+
The Device Update for IoT Hub client will raise exceptions defined in [Azure Core][https://github.com/azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/readme.md].
41+
42+
## Next steps
43+
44+
Get started with our [Device Update for IoT Hub samples](https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/deviceupdate/azure-iot-deviceupdate/samples)
45+
46+
## Contributing
47+
48+
If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project.
49+
50+
<!-- LINKS -->
51+
[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore

0 commit comments

Comments
 (0)