Coder Social home page Coder Social logo

appcenter-rest-python's Introduction

This is a minimal Python wrapper around the App Center REST APIs to get you up and running. If you are looking for something more substantial, please refer to the REST API documentation: https://openapi.appcenter.ms/

You can install with pip install appcenter

Usage

# 1. Import the library
import appcenter

# 2. Create a new client
client = appcenter.AppCenterClient(access_token="abc123def456")

# 3. Check some error groups
start = datetime.datetime.now() - datetime.timedelta(days=10)
for group in client.crashes.get_error_groups(owner_name="owner", app_name="myapp", start_time=start):
    print(group.errorGroupId)
    
# 4. Get recent versions
for version in client.versions.all(owner_name="owner", app_name="myapp"):
    print(version)
    
# 5. Create a new release
client.versions.upload_and_release(
    owner_name="owner",
    app_name="myapp",
    version="0.1",
    build_number="123",
    binary_path="/path/to/some.ipa",
    group_id="12345678-abcd-9012-efgh-345678901234",
    release_notes="These are some release notes",
    branch_name="test_branch",
    commit_hash="1234567890123456789012345678901234567890",
    commit_message="This is a commit message"
)

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

appcenter-rest-python's People

Contributors

dalemyers avatar danielamitay avatar dependabot[bot] avatar detachhead avatar flaminestone avatar guojiubo avatar jingshizheng avatar luras-oil avatar microsoftopensource avatar msftgits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appcenter-rest-python's Issues

Upload and release failing

Uploading a release keeps failing with 500 from server, eg.

Failed to post in release: method=POST, url=https://api.appcenter.ms/v0.1/apps/org-name/app-name/releases/1477/groups, status_code=500, error=<code=dependent_service_error, m
essage=Error: {"error":{"code":"DatabaseError","message":"Conversion failed when converting from a character string to uniqueidentifier."}}>

might be related with the recent issues at appcenter -> https://status.appcenter.ms/incidents/jvl3rs5tmdlx?u=k9xw0m8pkd90
I used directly the api and just checked if this lib is working, maybe it's also another mistake, just want to raise this here.

Suddenly receiving appcenter.derived_client.AppCenterHTTPException

Since approx. 10:00 AM CET we are receiving appcenter.derived_client.AppCenterHTTPException from appcenter/crashes.py
`

23-Feb-2022 10:19:34 Traceback (most recent call last):
23-Feb-2022 10:19:34 File "analyse_crashes.py", line 458, in
23-Feb-2022 10:19:34 main()
23-Feb-2022 10:19:34 File "analyse_crashes.py", line 350, in main
23-Feb-2022 10:19:34 android_reu_groups = android_reu_crashes_handler.groups()
23-Feb-2022 10:19:34 File "analyse_crashes.py", line 79, in groups
23-Feb-2022 10:19:34 groups = list(self.client.get_error_groups(owner_name=self.owner_name,
23-Feb-2022 10:19:34 File "/Users/bamboo/Library/Python/3.8/lib/python/site-packages/appcenter/crashes.py", line 208, in get_error_groups
23-Feb-2022 10:19:34 response = self.get(request_url)
23-Feb-2022 10:19:34 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tenacity/init.py", line 333, in wrapped_f
23-Feb-2022 10:19:34 return self(f, *args, **kw)
23-Feb-2022 10:19:34 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tenacity/init.py", line 423, in call
23-Feb-2022 10:19:34 do = self.iter(retry_state=retry_state)
23-Feb-2022 10:19:34 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tenacity/init.py", line 360, in iter
23-Feb-2022 10:19:34 return fut.result()
23-Feb-2022 10:19:34 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/_base.py", line 432, in result
23-Feb-2022 10:19:34 return self.__get_result()
23-Feb-2022 10:19:34 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
23-Feb-2022 10:19:34 raise self._exception
23-Feb-2022 10:19:34 File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tenacity/init.py", line 426, in call
23-Feb-2022 10:19:34 result = fn(*args, **kwargs)
23-Feb-2022 10:19:34 File "/Users/bamboo/Library/Python/3.8/lib/python/site-packages/appcenter/derived_client.py", line 185, in get
23-Feb-2022 10:19:34 raise create_exception(response)
23-Feb-2022 10:19:34 appcenter.derived_client.AppCenterHTTPException: <method=GET, url=https://api.appcenter.ms/v0.1/apps/Home-Connect/Home-Connect-App-1/errors/errorGroups?start=2021-11-25T11%3A19%3A03&$top=30&$token=e7cbb259-aeed-407b-8d63-1eb61d241b84, status_code=502, text={"message":"internal error","err_message":"error: activity_name: graph router, exception: ESOCKETTIMEDOUT, current_request_url: /v0.1/apps/Home-Connect/Home-Connect-App-1/errors/errorGroups?start=2021-11-25T11%3A19%3A03&$top=30, api_path: v0.1/apps/{owner_name}/{app_name}/errors/errorGroups, beacon: errors, code: ESOCKETTIMEDOUT. Correlation ID: 14863e1b-34c7-4d46-b3fa-7e6897c60faf"}>

`

Python 3.6.8 no longer works with the latest updates

Hi, my team has been using this dependency as part of our CD process for awhile and we noticed the newer versions broke after 2.0.2. The error:

  File "~/.pyenv/versions/3.6.8/lib/python3.6/site-packages/appcenter/__init__.py", line 19, in <module>
    from appcenter.tokens import AppCenterTokensClient
  File "<fstring>", line 1
    (name=)

I've tracked it down to the debug statements in tokens.py. It appears that the newer f-string syntax of "{name=}" is not supported in 3.6.x. If possible, could those be fixed to support older versions of Python? Unfortunately, we don't have any control over the version of Python available to us.

Multi-threaded requests

While getting crash groups and crashes, the operation will take a long time if the number of crash groups is very large.

Is that possible to get the total number of pages and download the crash group data using multiple threads?

upload_and_release() got an unexpected keyword argument 'version'

Recent changes lead to a usage issue on our end:

in <module>
25-Jan-2022 08:26:00	    client.versions.upload_and_release(
25-Jan-2022 08:26:00	TypeError: upload_and_release() got an unexpected keyword argument 'version'

I saw a version 3 is released not sure what changed yet. Will try to pin to previous release for us.
I think it would be nice to have a CHANGELOG here in repo to spot changes quickly. Also not sure if README is up to date.

Edit: i just see #7 maybe related.

add `timeout` when sending requests

I wrote a scripts to pull version info every 30 seconds and when getting all versions by :

response = self.get(request_url)

I encounter a problem that the process seems stuck sometime and the last log i got is always:

[2023-11-02 04:35:03,968][INFO][appcenter.versions]	Getting versions of app: [******]
[2023-11-02 04:35:03,968][DEBUG][appcenter.versions]	Generated URL: https://api.appcenter.ms/v0.1/apps/[******]/[******]
[2023-11-02 04:35:03,968][DEBUG][urllib3.connectionpool]	Starting new HTTPS connection (8): api.appcenter.ms:443
[2023-11-02 04:35:28,896][DEBUG][urllib3.connectionpool]	https://api.appcenter.ms:443 "GET /v0.1/apps/[******]/[******]/releases?published_only=false&scope=tester HTTP/1.1" 200 990783

After investigation i confirm that it blames to the missing timeout setting when:

response = self.session.get(url)

and after changing to

response = self.session.get(url, timeout=10)

things seems normal and i will get TimeoutError as expected.

So could we add timeout argument? I am not sure should we set a default value or additionally expose it to the function that calls it.

Client stopped working with 403.

We are using appcenter for nightly and weekly builds. Client suddenly stopped working tonight with a 403 invalid token.
We didn't touched our script nor our access tokens.
Already checked status.appcenter.ms but distribute status is green there. Was there a change on the API that not reflected in the client?

Exception when handling upload error.

I'm encountering an exception when trying to uploading a zip file for a windows artifact.
This is what I'm trying to run:

    client = appcenter.AppCenterClient(access_token=accessToken)
    client.versions.upload_and_release(
        owner_name=ownerName,
        app_name=appName,
        binary_path=artifactFile,       # A zip file that works when uploaded using the site.
        group_id=distributionGroup,     # 00000000-0000-0000-0000-000000000000 (Collaborators)
        release_notes="upload test"
    )

And the issues happen here:

+ response_data.get("error_details", "?")

This is the exception:

Exception has occurred: AttributeError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
'CommitUploadResponse' object has no attribute 'get'
  File "C:\Python310\Lib\site-packages\appcenter\versions.py", line 489, in _wait_for_upload
    + response_data.get("error_details", "?")
  File "C:\Python310\Lib\site-packages\appcenter\versions.py", line 624, in upload_build
    upload_end_response = self._wait_for_upload(
  File "C:\Python310\Lib\site-packages\appcenter\versions.py", line 682, in upload_and_release
    release_id = self.upload_build(
  File "C:\Utils\UploadToAppCenter.py", line 72, in main
    client.versions.upload_and_release(
  File "C:\Utils\UploadToAppCenter.py", line 87, in <module>
    main()
  File "C:\Python310\Lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python310\Lib\runpy.py", line 196, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
AttributeError: 'CommitUploadResponse' object has no attribute 'get'

The response I'm getting :
b'{"id":"some-guid-A","upload_status":"error","error_details":"A problem occured while extracting your app. (Correlation ID: some-guid-B)"}'

404 for generate_upload_url() call

Hi!

This is probably not related to the sdk, but rather to the infrastructure behind it. Unfortunately, I didn't find another channel to report this. If there is one, I'd be happy to forward it there.

Anyhow, we started to receive 404 since recently for a few of our registered apps in AppCenter. There are still apps that work somehow. Is there anything we can do about this? The built-in retries don't succeed either.

WARNING:__main__.appcenter.versions:Failed to post in get_upload_url: method=POST, url=https://api.appcenter.ms/v0.1/apps/***/***/uploads/releases, status_code=404, error=<code=Not Found, message=Not found. Correlation ID: f5a9a76d-2e53-441b-b074-b720a36f7728>

BuildInfo not deserialized correctly

Hi,

I noticed when you call client.versions.all() in the result the BuildInfo object remains empty for all versions, because it is trying to deserialize the keys from the response branchName, commitHash and commitMessage into the object with the keys branch_name, commit_hash and commit_message.

Bastian

How to download raw crash-reports?

Hello,

we are using this python-library to create issues in our issuestracker based on an appcenter crash.
Is it possible to also access the raw crash-report to attach it to our newly created issue?

I did not find anything in HandledErrorDetail but in the "error info dictionary" (via self.client.error_info_dictionary) I saw that there is blobReference which kind of indicates to a JSON-file. But I did not find a way to access/download this file.

Is this possible at all?

Cheers, Andy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.