Replace owner_name with org_name

This commit is contained in:
Dale Myers 2024-05-17 10:25:28 +01:00
Родитель dee4fa9054
Коммит 75ec95f2a5
7 изменённых файлов: 169 добавлений и 171 удалений

Просмотреть файл

@ -13,16 +13,16 @@ client = appcenter.AppCenterClient(access_token="abc123def456")
# 3. Check some error groups # 3. Check some error groups
start = datetime.datetime.now() - datetime.timedelta(days=10) 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): for group in client.crashes.get_error_groups(org_name="org", app_name="myapp", start_time=start):
print(group.errorGroupId) print(group.errorGroupId)
# 4. Get recent versions # 4. Get recent versions
for version in client.versions.all(owner_name="owner", app_name="myapp"): for version in client.versions.all(org_name="org", app_name="myapp"):
print(version) print(version)
# 5. Create a new release # 5. Create a new release
client.versions.upload_and_release( client.versions.upload_and_release(
owner_name="owner", org_name="org",
app_name="myapp", app_name="myapp",
version="0.1", version="0.1",
build_number="123", build_number="123",
@ -37,7 +37,7 @@ client.versions.upload_and_release(
## Contributing ## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a 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 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. the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

Просмотреть файл

@ -29,69 +29,69 @@ class AppCenterAccountClient(AppCenterDerivedClient):
def __init__(self, token: str, parent_logger: logging.Logger) -> None: def __init__(self, token: str, parent_logger: logging.Logger) -> None:
super().__init__("account", token, parent_logger) super().__init__("account", token, parent_logger)
def users(self, *, owner_name: str, app_name: str) -> list[User]: def users(self, *, org_name: str, app_name: str) -> list[User]:
"""Get the users for an app. """Get the users for an app.
:param owner_name: The name of the app account owner :param org_name: The name of the organization
:param app_name: The name of the app. If not set, will get for org. :param app_name: The name of the app. If not set, will get for org.
:returns: A list of User :returns: A list of User
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += "/users" request_url += "/users"
response = self.get(request_url) response = self.get(request_url)
return deserialize.deserialize(list[User], response.json()) return deserialize.deserialize(list[User], response.json())
def org_users(self, *, owner_name: str) -> list[OrganizationUserResponse]: def org_users(self, *, org_name: str) -> list[OrganizationUserResponse]:
"""Get the users in an org. """Get the users in an org.
:param owner_name: The name of the app account owner :param org_name: The name of the organization
:returns: A list of OrganizationUserResponse :returns: A list of OrganizationUserResponse
""" """
request_url = self.generate_org_url(owner_name=owner_name) request_url = self.generate_org_url(org_name=org_name)
request_url += "/users" request_url += "/users"
response = self.get(request_url) response = self.get(request_url)
return deserialize.deserialize(list[OrganizationUserResponse], response.json()) return deserialize.deserialize(list[OrganizationUserResponse], response.json())
def delete_user(self, *, owner_name: str, user_name: str) -> None: def delete_user(self, *, org_name: str, user_name: str) -> None:
"""Delete a user from an org.""" """Delete a user from an org."""
request_url = self.generate_org_url(owner_name=owner_name) + f"/users/{user_name}" request_url = self.generate_org_url(org_name=org_name) + f"/users/{user_name}"
_ = self.delete(request_url) _ = self.delete(request_url)
def teams(self, *, owner_name: str) -> list[TeamResponse]: def teams(self, *, org_name: str) -> list[TeamResponse]:
"""Get the teams in an org. """Get the teams in an org.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:returns: A TeamResponse :returns: A TeamResponse
""" """
request_url = self.generate_org_url(owner_name=owner_name) request_url = self.generate_org_url(org_name=org_name)
request_url += "/teams" request_url += "/teams"
response = self.get(request_url) response = self.get(request_url)
return deserialize.deserialize(list[TeamResponse], response.json()) return deserialize.deserialize(list[TeamResponse], response.json())
def team_users(self, *, owner_name: str, team_name: str) -> list[OrganizationUserResponse]: def team_users(self, *, org_name: str, team_name: str) -> list[OrganizationUserResponse]:
"""Get the users in a team in an org. """Get the users in a team in an org.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str team_name: The name of the team :param str team_name: The name of the team
:returns: A TeamResponse :returns: A TeamResponse
""" """
request_url = self.generate_org_url(owner_name=owner_name) request_url = self.generate_org_url(org_name=org_name)
request_url += f"/teams/{team_name}/users" request_url += f"/teams/{team_name}/users"
response = self.get(request_url) response = self.get(request_url)
@ -101,7 +101,7 @@ class AppCenterAccountClient(AppCenterDerivedClient):
def add_collaborator( def add_collaborator(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
user_email: str, user_email: str,
role: Role | None = None, role: Role | None = None,
@ -111,7 +111,7 @@ class AppCenterAccountClient(AppCenterDerivedClient):
If they are a new collaborator, they will be invited. If that is the If they are a new collaborator, they will be invited. If that is the
case, the role must be specified. case, the role must be specified.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str user_email: The email of the user :param str user_email: The email of the user
:param Role | None role: The role the user should have (this is required for new users) :param Role | None role: The role the user should have (this is required for new users)
@ -119,9 +119,9 @@ class AppCenterAccountClient(AppCenterDerivedClient):
:returns: The list of users :returns: The list of users
""" """
self.log.info(f"Adding user {user_email} as collaborator on: {owner_name}/{app_name}") self.log.info(f"Adding user {user_email} as collaborator on: {org_name}/{app_name}")
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += "/invitations" request_url += "/invitations"
data = {"user_email": user_email} data = {"user_email": user_email}
@ -131,27 +131,27 @@ class AppCenterAccountClient(AppCenterDerivedClient):
self.post(request_url, data=data) self.post(request_url, data=data)
def delete_collaborator(self, *, owner_name: str, app_name: str, user_email: str) -> None: def delete_collaborator(self, *, org_name: str, app_name: str, user_email: str) -> None:
"""Remove a user as a collaborator from an app. """Remove a user as a collaborator from an app.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str user_email: The email of the user to remove :param str user_email: The email of the user to remove
""" """
self.log.info(f"Deleting user {user_email} from: {owner_name}/{app_name}") self.log.info(f"Deleting user {user_email} from: {org_name}/{app_name}")
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/users/{urllib.parse.quote(user_email)}" request_url += f"/users/{urllib.parse.quote(user_email)}"
self.delete(request_url) self.delete(request_url)
def set_collaborator_permissions( def set_collaborator_permissions(
self, *, owner_name: str, app_name: str, user_email: str, permission: Permission self, *, org_name: str, app_name: str, user_email: str, permission: Permission
) -> None: ) -> None:
"""Set a users collaborator permissions on an app. """Set a users collaborator permissions on an app.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str user_email: The email of the user :param str user_email: The email of the user
:param Permission permission: The permission level to grant :param Permission permission: The permission level to grant
@ -161,23 +161,23 @@ class AppCenterAccountClient(AppCenterDerivedClient):
self.log.info( self.log.info(
f"Setting user {user_email} as collaborator with permission " f"Setting user {user_email} as collaborator with permission "
+ f"{permission.value} on: {owner_name}/{app_name}" + f"{permission.value} on: {org_name}/{app_name}"
) )
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/users/{urllib.parse.quote(user_email)}" request_url += f"/users/{urllib.parse.quote(user_email)}"
self.patch(request_url, data={"permissions": [permission.value]}) self.patch(request_url, data={"permissions": [permission.value]})
def apps(self, *, owner_name: str) -> list[AppResponse]: def apps(self, *, org_name: str) -> list[AppResponse]:
"""Get the apps in an org. """Get the apps in an org.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:returns: A list of AppResponse :returns: A list of AppResponse
""" """
request_url = self.generate_org_url(owner_name=owner_name) request_url = self.generate_org_url(org_name=org_name)
request_url += "/apps" request_url += "/apps"
response = self.get(request_url) response = self.get(request_url)

Просмотреть файл

@ -24,22 +24,22 @@ class AppCenterAnalyticsClient(AppCenterDerivedClient):
def release_counts( def release_counts(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
releases: list[ReleaseWithDistributionGroup], releases: list[ReleaseWithDistributionGroup],
) -> ReleaseCounts: ) -> ReleaseCounts:
"""Get the release counts for an app """Get the release counts for an app
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param list[ReleaseWithDistributionGroup] releases: The list of releases to get the counts for :param list[ReleaseWithDistributionGroup] releases: The list of releases to get the counts for
:returns: The release counts :returns: The release counts
""" """
self.log.info(f"Getting release counts for: {owner_name}/{app_name}") self.log.info(f"Getting release counts for: {org_name}/{app_name}")
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += "/analytics/distribution/release_counts" request_url += "/analytics/distribution/release_counts"
data = [] data = []

Просмотреть файл

@ -39,17 +39,17 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
def __init__(self, token: str, parent_logger: logging.Logger) -> None: def __init__(self, token: str, parent_logger: logging.Logger) -> None:
super().__init__("crashes", token, parent_logger) super().__init__("crashes", token, parent_logger)
def group_details(self, *, owner_name: str, app_name: str, error_group_id: str) -> ErrorGroup: def group_details(self, *, org_name: str, app_name: str, error_group_id: str) -> ErrorGroup:
"""Get the error group details. """Get the error group details.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str error_group_id: The ID of the error group to get the details for :param str error_group_id: The ID of the error group to get the details for
:returns: An ErrorGroup :returns: An ErrorGroup
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/errors/errorGroups/{error_group_id}" request_url += f"/errors/errorGroups/{error_group_id}"
response = self.get(request_url) response = self.get(request_url)
@ -57,11 +57,11 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
return deserialize.deserialize(ErrorGroup, response.json()) return deserialize.deserialize(ErrorGroup, response.json())
def error_details( def error_details(
self, *, owner_name: str, app_name: str, error_group_id: str, error_id: str self, *, org_name: str, app_name: str, error_group_id: str, error_id: str
) -> HandledErrorDetails: ) -> HandledErrorDetails:
"""Get the error details. """Get the error details.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str error_group_id: The ID of the error group to get the details for :param str error_group_id: The ID of the error group to get the details for
:param str error_id: The ID of the error to get the details for :param str error_id: The ID of the error to get the details for
@ -69,7 +69,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
:returns: A HandledErrorDetails :returns: A HandledErrorDetails
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/errors/errorGroups/{error_group_id}/errors/{error_id}" request_url += f"/errors/errorGroups/{error_group_id}/errors/{error_id}"
response = self.get(request_url) response = self.get(request_url)
@ -77,14 +77,14 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
return deserialize.deserialize(HandledErrorDetails, response.json()) return deserialize.deserialize(HandledErrorDetails, response.json())
def error_info_dictionary( def error_info_dictionary(
self, *, owner_name: str, app_name: str, error_group_id: str, error_id: str self, *, org_name: str, app_name: str, error_group_id: str, error_id: str
) -> HandledErrorDetails: ) -> HandledErrorDetails:
"""Get the full error info dictionary. """Get the full error info dictionary.
This is the full details that App Center has on a crash. It is not This is the full details that App Center has on a crash. It is not
parsed due to being different per platform. parsed due to being different per platform.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str error_group_id: The ID of the error group to get the details for :param str error_group_id: The ID of the error group to get the details for
:param str error_id: The ID of the error to get the details for :param str error_id: The ID of the error to get the details for
@ -92,7 +92,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
:returns: The raw full error info dictionary :returns: The raw full error info dictionary
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/errors/errorGroups/{error_group_id}/errors/{error_id}/download" request_url += f"/errors/errorGroups/{error_group_id}/errors/{error_id}/download"
response = self.get(request_url) response = self.get(request_url)
@ -102,7 +102,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
def set_annotation( def set_annotation(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
error_group_id: str, error_group_id: str,
annotation: str, annotation: str,
@ -110,7 +110,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
) -> None: ) -> None:
"""Get the error group details. """Get the error group details.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str error_group_id: The ID of the error group to set the annotation on :param str error_group_id: The ID of the error group to set the annotation on
:param str annotation: The annotation text :param str annotation: The annotation text
@ -124,7 +124,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
""" """
if state is None: if state is None:
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/errors/errorGroups/{error_group_id}" request_url += f"/errors/errorGroups/{error_group_id}"
response = self.get(request_url) response = self.get(request_url)
@ -132,7 +132,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
group = deserialize.deserialize(ErrorGroup, response.json()) group = deserialize.deserialize(ErrorGroup, response.json())
state = group.state state = group.state
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/errors/errorGroups/{error_group_id}" request_url += f"/errors/errorGroups/{error_group_id}"
self.patch(request_url, data={"state": state.value, "annotation": annotation}) self.patch(request_url, data={"state": state.value, "annotation": annotation})
@ -141,7 +141,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
def get_error_groups( def get_error_groups(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
start_time: datetime.datetime, start_time: datetime.datetime,
end_time: datetime.datetime | None = None, end_time: datetime.datetime | None = None,
@ -154,7 +154,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
) -> Iterator[ErrorGroupListItem]: ) -> Iterator[ErrorGroupListItem]:
"""Get the error groups for an app. """Get the error groups for an app.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param datetime.datetime start_time: The time to start getting error groups from :param datetime.datetime start_time: The time to start getting error groups from
:param datetime.datetime | None end_time: The end time to get error groups from :param datetime.datetime | None end_time: The end time to get error groups from
@ -170,7 +170,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
# pylint: disable=too-many-locals # pylint: disable=too-many-locals
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += "/errors/errorGroups?" request_url += "/errors/errorGroups?"
parameters = {"start": start_time.replace(microsecond=0).isoformat()} parameters = {"start": start_time.replace(microsecond=0).isoformat()}
@ -215,7 +215,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
break break
request_url = appcenter.constants.API_BASE_URL + self._next_link_polished( request_url = appcenter.constants.API_BASE_URL + self._next_link_polished(
error_groups.nextLink, owner_name, app_name error_groups.nextLink, org_name, app_name
) )
# pylint: disable=too-many-locals # pylint: disable=too-many-locals
@ -225,7 +225,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
def errors_in_group( def errors_in_group(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
error_group_id: str, error_group_id: str,
start_time: datetime.datetime | None = None, start_time: datetime.datetime | None = None,
@ -235,7 +235,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
) -> Iterator[HandledError]: ) -> Iterator[HandledError]:
"""Get the errors in a group. """Get the errors in a group.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str error_group_id: The ID of the group to get the errors from :param str error_group_id: The ID of the group to get the errors from
:param datetime.datetime | None start_time: The time to start getting error groups from :param datetime.datetime | None start_time: The time to start getting error groups from
@ -246,7 +246,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
:returns: An iterator of HandledError :returns: An iterator of HandledError
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/errors/errorGroups/{error_group_id}/errors?" request_url += f"/errors/errorGroups/{error_group_id}/errors?"
parameters: dict[str, str] = {} parameters: dict[str, str] = {}
@ -282,13 +282,13 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
break break
request_url = appcenter.constants.API_BASE_URL + self._next_link_polished( request_url = appcenter.constants.API_BASE_URL + self._next_link_polished(
errors.nextLink, owner_name, app_name errors.nextLink, org_name, app_name
) )
def begin_symbol_upload( def begin_symbol_upload(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
symbols_name: str, symbols_name: str,
symbol_type: SymbolType, symbol_type: SymbolType,
@ -297,7 +297,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
) -> SymbolUploadBeginResponse: ) -> SymbolUploadBeginResponse:
"""Upload debug symbols """Upload debug symbols
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str symbols_path: The path to the symbols :param str symbols_path: The path to the symbols
:param str symbol_type: The type of symbols being uploaded :param str symbol_type: The type of symbols being uploaded
@ -316,7 +316,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
if version is None: if version is None:
raise ValueError("The version is required for Android") raise ValueError("The version is required for Android")
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += "/symbol_uploads" request_url += "/symbol_uploads"
data = {"symbol_type": symbol_type.value, "file_name": symbols_name} data = {"symbol_type": symbol_type.value, "file_name": symbols_name}
@ -332,18 +332,18 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
return deserialize.deserialize(SymbolUploadBeginResponse, response.json()) return deserialize.deserialize(SymbolUploadBeginResponse, response.json())
def commit_symbol_upload( def commit_symbol_upload(
self, *, owner_name: str, app_name: str, upload_id: str self, *, org_name: str, app_name: str, upload_id: str
) -> SymbolUploadEndRequest: ) -> SymbolUploadEndRequest:
"""Commit a symbol upload operation """Commit a symbol upload operation
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str upload_id: The ID of the symbols upload to commit :param str upload_id: The ID of the symbols upload to commit
:returns: The App Center symbol upload end response :returns: The App Center symbol upload end response
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/symbol_uploads/{upload_id}" request_url += f"/symbol_uploads/{upload_id}"
data = {"status": "committed"} data = {"status": "committed"}
@ -356,7 +356,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
def upload_symbols( def upload_symbols(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
symbols_path: str, symbols_path: str,
symbols_name: str | None = None, symbols_name: str | None = None,
@ -367,7 +367,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
) -> None: ) -> None:
"""Upload debug symbols """Upload debug symbols
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str symbols_path: The path to the symbols :param str symbols_path: The path to the symbols
:param str symbols_name: The name to use for the symbols (defaults to file basename) :param str symbols_name: The name to use for the symbols (defaults to file basename)
@ -391,7 +391,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
symbols_name = os.path.basename(symbols_path) symbols_name = os.path.basename(symbols_path)
begin_upload_response = self.begin_symbol_upload( begin_upload_response = self.begin_symbol_upload(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
symbols_name=symbols_name, symbols_name=symbols_name,
symbol_type=symbol_type, symbol_type=symbol_type,
@ -411,7 +411,7 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
) )
commit_response = self.commit_symbol_upload( commit_response = self.commit_symbol_upload(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
upload_id=begin_upload_response.symbol_upload_id, upload_id=begin_upload_response.symbol_upload_id,
) )
@ -421,11 +421,11 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
# pylint: enable=too-many-arguments # pylint: enable=too-many-arguments
def _next_link_polished(self, next_link: str, owner_name: str, app_name: str) -> str: def _next_link_polished(self, next_link: str, org_name: str, app_name: str) -> str:
"""Polish nextLink string gotten from AppCenter service """Polish nextLink string gotten from AppCenter service
:param str next_link: The nextLink property from a service response when items are queried in batches :param str next_link: The nextLink property from a service response when items are queried in batches
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:returns: A polished next link to use on next batch :returns: A polished next link to use on next batch
@ -433,9 +433,9 @@ class AppCenterCrashesClient(AppCenterDerivedClient):
_ = self _ = self
if f"{owner_name}/{app_name}" not in next_link: if f"{org_name}/{app_name}" not in next_link:
# For some apps, AppCenter is returning invalid nextLinks without app name and owner, just a // instead. # For some apps, AppCenter is returning invalid nextLinks without app name and org, just a // instead.
next_link = next_link.replace("//", f"/{owner_name}/{app_name}/", 1) next_link = next_link.replace("//", f"/{org_name}/{app_name}/", 1)
# AppCenter is returning a nextLink with a /api on the URL which causes the request to fail. # AppCenter is returning a nextLink with a /api on the URL which causes the request to fail.
return next_link.replace("/api", "", 1) return next_link.replace("/api", "", 1)

Просмотреть файл

@ -148,30 +148,30 @@ class AppCenterDerivedClient:
""" """
return f"{API_BASE_URL}/v{version}" return f"{API_BASE_URL}/v{version}"
def generate_app_url(self, *, version: str = "0.1", owner_name: str, app_name: str) -> str: def generate_app_url(self, *, version: str = "0.1", org_name: str, app_name: str) -> str:
"""Generate a URL to use for querying the API for app info. """Generate a URL to use for querying the API for app info.
:param str version: The API version to hit :param str version: The API version to hit
:param str owner_name: The name of the owner of the app :param str org_name: The name of the org
:param str app_name: The name of the app :param str app_name: The name of the app
:returns: A generated URL base :returns: A generated URL base
""" """
url = self.base_url(version=version) + f"/apps/{owner_name}/{app_name}" url = self.base_url(version=version) + f"/apps/{org_name}/{app_name}"
self.log.debug(f"Generated URL: {url}") self.log.debug(f"Generated URL: {url}")
return url return url
def generate_org_url(self, *, version: str = "0.1", owner_name: str) -> str: def generate_org_url(self, *, version: str = "0.1", org_name: str) -> str:
"""Generate a URL to use for querying the API for org info. """Generate a URL to use for querying the API for org info.
:param str version: The API version to hit :param str version: The API version to hit
:param str owner_name: The name of the org owner :param str org_name: The name of the org
:returns: A generated URL base :returns: A generated URL base
""" """
url = self.base_url(version=version) + f"/orgs/{owner_name}" url = self.base_url(version=version) + f"/orgs/{org_name}"
self.log.debug(f"Generated URL: {url}") self.log.debug(f"Generated URL: {url}")
return url return url

Просмотреть файл

@ -56,18 +56,18 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
def __init__(self, token: str, parent_logger: logging.Logger) -> None: def __init__(self, token: str, parent_logger: logging.Logger) -> None:
super().__init__("versions", token, parent_logger) super().__init__("versions", token, parent_logger)
def recent(self, *, owner_name: str, app_name: str) -> list[BasicReleaseDetailsResponse]: def recent(self, *, org_name: str, app_name: str) -> list[BasicReleaseDetailsResponse]:
"""Get the recent version for each distribution group. """Get the recent version for each distribution group.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:returns: A list of BasicReleaseDetailsResponse :returns: A list of BasicReleaseDetailsResponse
""" """
self.log.info(f"Getting recent versions of app: {owner_name}/{app_name}") self.log.info(f"Getting recent versions of app: {org_name}/{app_name}")
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += "/recent_releases" request_url += "/recent_releases"
response = self.get(request_url) response = self.get(request_url)
@ -77,14 +77,14 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
def all( def all(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
published_only: bool = False, published_only: bool = False,
scope: str | None = None, scope: str | None = None,
) -> Iterator[BasicReleaseDetailsResponse]: ) -> Iterator[BasicReleaseDetailsResponse]:
"""Get all (the 100 latest) versions. """Get all (the 100 latest) versions.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param bool published_only: Return only the published releases (defaults to false) :param bool published_only: Return only the published releases (defaults to false)
:param str | None scope: When the scope is 'tester', only includes :param str | None scope: When the scope is 'tester', only includes
@ -94,9 +94,9 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
:returns: An iterator of BasicReleaseDetailsResponse :returns: An iterator of BasicReleaseDetailsResponse
""" """
self.log.info(f"Getting versions of app: {owner_name}/{app_name}") self.log.info(f"Getting versions of app: {org_name}/{app_name}")
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += "/releases?" request_url += "/releases?"
parameters = {"published_only": str(published_only).lower()} parameters = {"published_only": str(published_only).lower()}
@ -111,56 +111,56 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
return deserialize.deserialize(list[BasicReleaseDetailsResponse], response.json()) return deserialize.deserialize(list[BasicReleaseDetailsResponse], response.json())
def release_details( def release_details(
self, *, owner_name: str, app_name: str, release_id: int self, *, org_name: str, app_name: str, release_id: int
) -> ReleaseDetailsResponse: ) -> ReleaseDetailsResponse:
"""Get the full release details for a given version. """Get the full release details for a given version.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param int release_id: The ID of the release to get the details for :param int release_id: The ID of the release to get the details for
:returns: The full details for a release :returns: The full details for a release
""" """
self.log.info(f"Getting details for: {owner_name}/{app_name} - {release_id}") self.log.info(f"Getting details for: {org_name}/{app_name} - {release_id}")
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/releases/{release_id}?" request_url += f"/releases/{release_id}?"
response = self.get(request_url) response = self.get(request_url)
return deserialize.deserialize(ReleaseDetailsResponse, response.json()) return deserialize.deserialize(ReleaseDetailsResponse, response.json())
def release_id_for_version(self, *, owner_name: str, app_name: str, version: str) -> int | None: def release_id_for_version(self, *, org_name: str, app_name: str, version: str) -> int | None:
"""Get the App Center release identifier for the app version (usually build number). """Get the App Center release identifier for the app version (usually build number).
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param bool version: The app version (usually build number) :param bool version: The app version (usually build number)
:returns: The App Center release identifier :returns: The App Center release identifier
""" """
for app_version in self.all(owner_name=owner_name, app_name=app_name): for app_version in self.all(org_name=org_name, app_name=app_name):
if app_version.version == version: if app_version.version == version:
return app_version.identifier return app_version.identifier
return None return None
def latest_commit(self, *, owner_name: str, app_name: str) -> str | None: def latest_commit(self, *, org_name: str, app_name: str) -> str | None:
"""Find the most recent release which has an available commit in it and return the commit hash. """Find the most recent release which has an available commit in it and return the commit hash.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:returns: The latest commit available on App Center :returns: The latest commit available on App Center
""" """
self.log.info(f"Getting latest commit for app: {owner_name}/{app_name}") self.log.info(f"Getting latest commit for app: {org_name}/{app_name}")
for version in self.all(owner_name=owner_name, app_name=app_name): for version in self.all(org_name=org_name, app_name=app_name):
full_details = self.release_details( full_details = self.release_details(
owner_name=owner_name, app_name=app_name, release_id=version.identifier org_name=org_name, app_name=app_name, release_id=version.identifier
) )
if full_details.build is None: if full_details.build is None:
@ -171,16 +171,16 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
return None return None
def get_upload_url(self, *, owner_name: str, app_name: str) -> CreateReleaseUploadResponse: def get_upload_url(self, *, org_name: str, app_name: str) -> CreateReleaseUploadResponse:
"""Get the App Center release identifier for the app version (usually build number). """Get the App Center release identifier for the app version (usually build number).
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:returns: The App Center release identifier :returns: The App Center release identifier
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += "/uploads/releases" request_url += "/uploads/releases"
for attempt in range(3): for attempt in range(3):
@ -380,18 +380,18 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
return True return True
def commit_upload( def commit_upload(
self, *, owner_name: str, app_name: str, upload_id: str self, *, org_name: str, app_name: str, upload_id: str
) -> CommitUploadResponse: ) -> CommitUploadResponse:
"""Get the App Center release identifier for the app version (usually build number). """Get the App Center release identifier for the app version (usually build number).
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str upload_id: The ID of the upload to commit :param str upload_id: The ID of the upload to commit
:returns: The App Center release end response :returns: The App Center release end response
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/uploads/releases/{upload_id}" request_url += f"/uploads/releases/{upload_id}"
data = {"upload_status": "uploadFinished"} data = {"upload_status": "uploadFinished"}
@ -413,16 +413,16 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
return deserialize.deserialize(CommitUploadResponse, response.json()) return deserialize.deserialize(CommitUploadResponse, response.json())
def _wait_for_upload( def _wait_for_upload(
self, *, owner_name: str, app_name: str, upload_id: str self, *, org_name: str, app_name: str, upload_id: str
) -> CommitUploadResponse: ) -> CommitUploadResponse:
"""Wait for an upload to finish processing """Wait for an upload to finish processing
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str upload_id: The ID of the upload to wait for :param str upload_id: The ID of the upload to wait for
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/uploads/releases/{upload_id}" request_url += f"/uploads/releases/{upload_id}"
def wait(): def wait():
@ -468,7 +468,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
def release( def release(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
release_id: int, release_id: int,
group_id: str, group_id: str,
@ -477,7 +477,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
) -> ReleaseDestinationResponse: ) -> ReleaseDestinationResponse:
"""Release a build to a group. """Release a build to a group.
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param int release_id: The release ID of the app :param int release_id: The release ID of the app
:param str group_id: The release ID of the group to release to :param str group_id: The release ID of the group to release to
@ -487,7 +487,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
:returns: The App Center release identifier :returns: The App Center release identifier
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/releases/{release_id}/groups" request_url += f"/releases/{release_id}/groups"
data = { data = {
@ -515,14 +515,14 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
def update_release( def update_release(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
release_id: int, release_id: int,
release_update_request: ReleaseUpdateRequest, release_update_request: ReleaseUpdateRequest,
) -> None: ) -> None:
"""Update a release with new details """Update a release with new details
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param int release_id: The release ID of the app :param int release_id: The release ID of the app
:param ReleaseUpdateRequest release_update_request: The release ID of the group to release to :param ReleaseUpdateRequest release_update_request: The release ID of the group to release to
@ -530,7 +530,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
:returns: The App Center release identifier :returns: The App Center release identifier
""" """
request_url = self.generate_app_url(owner_name=owner_name, app_name=app_name) request_url = self.generate_app_url(org_name=org_name, app_name=app_name)
request_url += f"/releases/{release_id}" request_url += f"/releases/{release_id}"
for attempt in range(3): for attempt in range(3):
@ -550,7 +550,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
def upload_build( def upload_build(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
binary_path: str, binary_path: str,
release_notes: str, release_notes: str,
@ -560,7 +560,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
) -> int | None: ) -> int | None:
"""Get the App Center release identifier for the app version (usually build number). """Get the App Center release identifier for the app version (usually build number).
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str binary_path: The path to the binary to upload :param str binary_path: The path to the binary to upload
:param str release_notes: The release notes for the release :param str release_notes: The release notes for the release
@ -577,9 +577,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
if not os.path.exists(binary_path): if not os.path.exists(binary_path):
raise FileNotFoundError(f"Could not find binary: {binary_path}") raise FileNotFoundError(f"Could not find binary: {binary_path}")
create_release_upload_response = self.get_upload_url( create_release_upload_response = self.get_upload_url(org_name=org_name, app_name=app_name)
owner_name=owner_name, app_name=app_name
)
success = self.upload_binary( success = self.upload_binary(
create_release_upload_response=create_release_upload_response, create_release_upload_response=create_release_upload_response,
@ -590,13 +588,13 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
raise Exception("Failed to upload binary") raise Exception("Failed to upload binary")
self.commit_upload( self.commit_upload(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
upload_id=create_release_upload_response.identifier, upload_id=create_release_upload_response.identifier,
) )
upload_end_response = self._wait_for_upload( upload_end_response = self._wait_for_upload(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
upload_id=create_release_upload_response.identifier, upload_id=create_release_upload_response.identifier,
) )
@ -612,7 +610,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
update_request = ReleaseUpdateRequest(release_notes=release_notes, build=build_info) update_request = ReleaseUpdateRequest(release_notes=release_notes, build=build_info)
self.update_release( self.update_release(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
release_id=upload_end_response.release_distinct_id, release_id=upload_end_response.release_distinct_id,
release_update_request=update_request, release_update_request=update_request,
@ -624,7 +622,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
def upload_and_release( def upload_and_release(
self, self,
*, *,
owner_name: str, org_name: str,
app_name: str, app_name: str,
binary_path: str, binary_path: str,
group_id: str, group_id: str,
@ -636,7 +634,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
) -> ReleaseDetailsResponse: ) -> ReleaseDetailsResponse:
"""Get the App Center release identifier for the app version (usually build number). """Get the App Center release identifier for the app version (usually build number).
:param str owner_name: The name of the app account owner :param str org_name: The name of the organization
:param str app_name: The name of the app :param str app_name: The name of the app
:param str binary_path: The path to the binary to upload :param str binary_path: The path to the binary to upload
:param str group_id: The ID of the group to release to :param str group_id: The ID of the group to release to
@ -653,7 +651,7 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
""" """
release_id = self.upload_build( release_id = self.upload_build(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
binary_path=binary_path, binary_path=binary_path,
release_notes=release_notes, release_notes=release_notes,
@ -666,13 +664,13 @@ class AppCenterVersionsClient(AppCenterDerivedClient):
raise Exception("Did not get release ID after upload") raise Exception("Did not get release ID after upload")
self.release( self.release(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
release_id=release_id, release_id=release_id,
group_id=group_id, group_id=group_id,
notify_testers=notify_testers if notify_testers else False, notify_testers=notify_testers if notify_testers else False,
) )
return self.release_details(owner_name=owner_name, app_name=app_name, release_id=release_id) return self.release_details(org_name=org_name, app_name=app_name, release_id=release_id)
# pylint: enable=too-many-arguments # pylint: enable=too-many-arguments

Просмотреть файл

@ -71,7 +71,7 @@ def get_from_keychain() -> str | None:
def get_tokens() -> list[str]: def get_tokens() -> list[str]:
"""Get the tokens for authentication. """Get the tokens for authentication.
:returns: The owner name, app name and token as a tuple. :returns: The org name, app name and token as a tuple.
""" """
details = get_from_keychain() details = get_from_keychain()
@ -82,10 +82,10 @@ def get_tokens() -> list[str]:
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def owner_name() -> str: def org_name() -> str:
"""Get the owner name. """Get the org name.
:returns: The owner name :returns: The org name
""" """
return get_tokens()[0] return get_tokens()[0]
@ -108,7 +108,7 @@ def token() -> str:
return get_tokens()[2] return get_tokens()[2]
def test_construction(owner_name: str, app_name: str, token: str): def test_construction(org_name: str, app_name: str, token: str):
"""Test construction.""" """Test construction."""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
start_time = datetime.datetime.now() - datetime.timedelta(days=10) start_time = datetime.datetime.now() - datetime.timedelta(days=10)
@ -117,14 +117,14 @@ def test_construction(owner_name: str, app_name: str, token: str):
error_group_batch_count = 0 error_group_batch_count = 0
for group in client.crashes.get_error_groups( for group in client.crashes.get_error_groups(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
start_time=start_time, start_time=start_time,
order_by="count desc", order_by="count desc",
limit=1, limit=1,
): ):
group_details = client.crashes.group_details( group_details = client.crashes.group_details(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
error_group_id=group.errorGroupId, error_group_id=group.errorGroupId,
) )
@ -132,7 +132,7 @@ def test_construction(owner_name: str, app_name: str, token: str):
assert group_details is not None assert group_details is not None
errors = client.crashes.errors_in_group( errors = client.crashes.errors_in_group(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
start_time=start_time, start_time=start_time,
error_group_id=group.errorGroupId, error_group_id=group.errorGroupId,
@ -142,7 +142,7 @@ def test_construction(owner_name: str, app_name: str, token: str):
for error in errors: for error in errors:
assert error.errorId is not None assert error.errorId is not None
error_details = client.crashes.error_details( error_details = client.crashes.error_details(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
error_group_id=group.errorGroupId, error_group_id=group.errorGroupId,
error_id=error.errorId, error_id=error.errorId,
@ -150,7 +150,7 @@ def test_construction(owner_name: str, app_name: str, token: str):
assert error_details is not None assert error_details is not None
full_details = client.crashes.error_info_dictionary( full_details = client.crashes.error_info_dictionary(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
error_group_id=group.errorGroupId, error_group_id=group.errorGroupId,
error_id=error.errorId, error_id=error.errorId,
@ -168,64 +168,64 @@ def test_construction(owner_name: str, app_name: str, token: str):
break break
def test_recent(owner_name: str, app_name: str, token: str): def test_recent(org_name: str, app_name: str, token: str):
"""Test recent.""" """Test recent."""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
recent_builds = client.versions.recent(owner_name=owner_name, app_name=app_name) recent_builds = client.versions.recent(org_name=org_name, app_name=app_name)
for build in recent_builds: for build in recent_builds:
print(build) print(build)
def test_versions(owner_name: str, app_name: str, token: str): def test_versions(org_name: str, app_name: str, token: str):
"""Test recent.""" """Test recent."""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
builds = client.versions.all(owner_name=owner_name, app_name=app_name) builds = client.versions.all(org_name=org_name, app_name=app_name)
for build in builds: for build in builds:
print(build) print(build)
def test_release_id(owner_name: str, app_name: str, token: str): def test_release_id(org_name: str, app_name: str, token: str):
"""Test release id check.""" """Test release id check."""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
release_id = client.versions.release_id_for_version( release_id = client.versions.release_id_for_version(
owner_name=owner_name, app_name=app_name, version="2917241" org_name=org_name, app_name=app_name, version="2917241"
) )
print(release_id) print(release_id)
def test_release_details(owner_name: str, app_name: str, token: str): def test_release_details(org_name: str, app_name: str, token: str):
"""Test release details.""" """Test release details."""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
recent_builds = client.versions.recent(owner_name=owner_name, app_name=app_name) recent_builds = client.versions.recent(org_name=org_name, app_name=app_name)
build = recent_builds[0] build = recent_builds[0]
full_details = client.versions.release_details( full_details = client.versions.release_details(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
release_id=build.identifier, release_id=build.identifier,
) )
print(full_details) print(full_details)
def test_latest_commit(owner_name: str, app_name: str, token: str): def test_latest_commit(org_name: str, app_name: str, token: str):
"""Test release details.""" """Test release details."""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
commit_hash = client.versions.latest_commit(owner_name=owner_name, app_name=app_name) commit_hash = client.versions.latest_commit(org_name=org_name, app_name=app_name)
assert commit_hash is not None assert commit_hash is not None
def test_release_counts(owner_name: str, app_name: str, token: str): def test_release_counts(org_name: str, app_name: str, token: str):
"""Test release details.""" """Test release details."""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
recent_builds = client.versions.recent(owner_name=owner_name, app_name=app_name) recent_builds = client.versions.recent(org_name=org_name, app_name=app_name)
build = recent_builds[0] build = recent_builds[0]
full_details = client.versions.release_details( full_details = client.versions.release_details(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
release_id=build.identifier, release_id=build.identifier,
) )
assert full_details.destinations is not None assert full_details.destinations is not None
counts = client.analytics.release_counts( counts = client.analytics.release_counts(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
releases=[ releases=[
appcenter.models.ReleaseWithDistributionGroup( appcenter.models.ReleaseWithDistributionGroup(
@ -236,14 +236,14 @@ def test_release_counts(owner_name: str, app_name: str, token: str):
print(counts) print(counts)
def test_upload(owner_name: str, token: str): def test_upload(org_name: str, token: str):
"""Test upload.""" """Test upload."""
ipa_path = "/path/to/some.ipa" ipa_path = "/path/to/some.ipa"
if not os.path.exists(ipa_path): if not os.path.exists(ipa_path):
return return
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
release_id = client.versions.upload_build( release_id = client.versions.upload_build(
owner_name=owner_name, org_name=org_name,
app_name="UploadTestApp", app_name="UploadTestApp",
binary_path=ipa_path, binary_path=ipa_path,
release_notes="These are some release notes", release_notes="These are some release notes",
@ -254,7 +254,7 @@ def test_upload(owner_name: str, token: str):
assert release_id is not None assert release_id is not None
def test_symbol_upload(owner_name: str, token: str): def test_symbol_upload(org_name: str, token: str):
"""Test symbol.""" """Test symbol."""
symbols_path = "/path/to/some.dSYM.zip" symbols_path = "/path/to/some.dSYM.zip"
@ -263,7 +263,7 @@ def test_symbol_upload(owner_name: str, token: str):
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
client.crashes.upload_symbols( client.crashes.upload_symbols(
owner_name=owner_name, org_name=org_name,
app_name="UploadTestApp", app_name="UploadTestApp",
version="0.1", version="0.1",
build_number="123", build_number="123",
@ -272,7 +272,7 @@ def test_symbol_upload(owner_name: str, token: str):
) )
def test_annotations(owner_name: str, app_name: str, token: str): def test_annotations(org_name: str, app_name: str, token: str):
"""Test construction.""" """Test construction."""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
@ -280,7 +280,7 @@ def test_annotations(owner_name: str, app_name: str, token: str):
annotation = str(uuid.uuid4()) annotation = str(uuid.uuid4())
for result in client.crashes.get_error_groups( for result in client.crashes.get_error_groups(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
start_time=datetime.datetime.now() - datetime.timedelta(days=14), start_time=datetime.datetime.now() - datetime.timedelta(days=14),
order_by="count desc", order_by="count desc",
@ -292,14 +292,14 @@ def test_annotations(owner_name: str, app_name: str, token: str):
assert group_id is not None assert group_id is not None
client.crashes.set_annotation( client.crashes.set_annotation(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
error_group_id=group_id, error_group_id=group_id,
annotation=annotation, annotation=annotation,
) )
details = client.crashes.group_details( details = client.crashes.group_details(
owner_name=owner_name, org_name=org_name,
app_name=app_name, app_name=app_name,
error_group_id=group_id, error_group_id=group_id,
) )
@ -307,10 +307,10 @@ def test_annotations(owner_name: str, app_name: str, token: str):
assert details.annotation == annotation assert details.annotation == annotation
def test_users(owner_name: str, app_name: str, token: str): def test_users(org_name: str, app_name: str, token: str):
"""Test construction.""" """Test construction."""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
users = client.account.users(owner_name=owner_name, app_name=app_name) users = client.account.users(org_name=org_name, app_name=app_name)
assert len(users) > 0 assert len(users) > 0
@ -366,24 +366,24 @@ def test_create_delete_tokens(token: str):
client.tokens.delete_user_token(new_token) client.tokens.delete_user_token(new_token)
def test_get_teams(owner_name: str, token: str): def test_get_teams(org_name: str, token: str):
"""Test get teams""" """Test get teams"""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
teams = client.account.teams(owner_name=owner_name) teams = client.account.teams(org_name=org_name)
assert len(teams) != 0 assert len(teams) != 0
def test_get_team_users(owner_name: str, token: str): def test_get_team_users(org_name: str, token: str):
"""Test get teams""" """Test get teams"""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
teams = client.account.teams(owner_name=owner_name) teams = client.account.teams(org_name=org_name)
team = teams[0] team = teams[0]
users = client.account.team_users(owner_name=owner_name, team_name=team.name) users = client.account.team_users(org_name=org_name, team_name=team.name)
assert len(users) != 0 assert len(users) != 0
def test_get_apps(owner_name: str, token: str): def test_get_apps(org_name: str, token: str):
"""Test get apps""" """Test get apps"""
client = appcenter.AppCenterClient(access_token=token) client = appcenter.AppCenterClient(access_token=token)
apps = client.account.apps(owner_name=owner_name) apps = client.account.apps(org_name=org_name)
assert len(apps) != 0 assert len(apps) != 0