viam.app.app_client =================== .. py:module:: viam.app.app_client Attributes ---------- .. autoapisummary:: viam.app.app_client.LOGGER Classes ------- .. autoapisummary:: viam.app.app_client.RobotPart viam.app.app_client.LogEntry viam.app.app_client.Fragment viam.app.app_client.FragmentHistoryEntry viam.app.app_client.RobotPartHistoryEntry viam.app.app_client.APIKeyAuthorization viam.app.app_client.AppClient Module Contents --------------- .. py:data:: LOGGER .. py:class:: RobotPart A class that mirrors the `RobotPart` proto message. Use this class to make the attributes of a `viam.proto.app.RobotPart` more accessible and easier to read/interpret. .. py:method:: from_proto(robot_part: viam.proto.app.RobotPart) -> typing_extensions.Self :classmethod: Create a `RobotPart` from the .proto defined `RobotPart`. :param robot_part: The object to copy from. :type robot_part: viam.proto.app.RobotPart :returns: The `RobotPart`. :rtype: RobotPart .. py:attribute:: id :type: str .. py:attribute:: name :type: str .. py:attribute:: dns_name :type: str .. py:attribute:: secret :type: str .. py:attribute:: robot :type: str .. py:attribute:: location_id :type: str .. py:attribute:: robot_config :type: Optional[Mapping[str, Any]] .. py:attribute:: last_access :type: Optional[datetime.datetime] .. py:attribute:: user_supplied_info :type: Optional[Mapping[str, Any]] .. py:attribute:: main_part :type: bool .. py:attribute:: fqdn :type: str .. py:attribute:: local_fqdn :type: str .. py:attribute:: created_on :type: Optional[datetime.datetime] .. py:attribute:: secrets :type: Optional[List[viam.proto.app.SharedSecret]] .. py:attribute:: last_updated :type: Optional[datetime.datetime] .. py:property:: proto :type: viam.proto.app.RobotPart .. py:class:: LogEntry A class that mirrors the `LogEntry` proto message. Use this class to make the attributes of a `viam.proto.app.LogEntry` more accessible and easier to read/interpret. .. py:method:: from_proto(log_entry: viam.proto.common.LogEntry) -> typing_extensions.Self :classmethod: Create a `LogEntry` from the .proto defined `LogEntry`. :param log_entry: The object to copy from. :type log_entry: viam.proto.app.LogEntry :returns: The `LogEntry`. :rtype: LogEntry .. py:attribute:: host :type: str .. py:attribute:: level :type: str .. py:attribute:: time :type: Optional[datetime.datetime] .. py:attribute:: logger_name :type: str .. py:attribute:: message :type: str .. py:attribute:: caller :type: Optional[Mapping[str, Any]] .. py:attribute:: stack :type: str .. py:attribute:: fields :type: Optional[List[Mapping[str, Any]]] .. py:property:: proto :type: viam.proto.common.LogEntry .. py:class:: Fragment A class that mirrors the `Fragment` proto message. Use this class to make the attributes of a `viam.proto.app.RobotPart` more accessible and easier to read/interpret. .. py:class:: Visibility Bases: :py:obj:`str`, :py:obj:`enum.Enum` FragmentVisibility specifies who is permitted to view the fragment. .. py:attribute:: PRIVATE :value: 'private' Only visible to members in the fragment's organization. .. py:attribute:: PUBLIC :value: 'public' Visible to anyone and appears on the fragments page. .. py:attribute:: PUBLIC_UNLISTED :value: 'public_unlisted' Visible to anyone but does not appear on the fragments page. .. py:attribute:: UNSPECIFIED :value: 'unspecified' Uninitialized visibility. .. py:method:: from_proto(visibility: viam.proto.app.FragmentVisibility.ValueType) -> Fragment :classmethod: .. py:method:: to_proto() -> viam.proto.app.FragmentVisibility.ValueType .. py:method:: from_proto(fragment: viam.proto.app.Fragment) -> typing_extensions.Self :classmethod: Create a `Fragment` from the .proto defined `Fragment`. :param fragment: The object to copy from. :type fragment: viam.proto.app.Fragment :returns: The `Fragment`. :rtype: Fragment .. py:attribute:: id :type: str .. py:attribute:: name :type: str .. py:attribute:: fragment :type: Optional[Mapping[str, Any]] .. py:attribute:: organization_owner :type: str .. py:attribute:: public :type: bool .. py:attribute:: created_on :type: Optional[datetime.datetime] .. py:attribute:: organization_name :type: str .. py:attribute:: robot_part_count :type: int .. py:attribute:: organization_count :type: int .. py:attribute:: only_used_by_owner :type: bool .. py:attribute:: visibility :type: Fragment.Visibility .. py:attribute:: last_updated :type: Optional[datetime.datetime] .. py:property:: proto :type: viam.proto.app.Fragment .. py:class:: FragmentHistoryEntry A class that mirrors the `FragmentHistoryEntry` proto message. Use this class to make the attributes of a `viam.proto.app.FragmentHistoryEntry` more accessible and easier to read/interpret. .. py:method:: from_proto(fragment_history_entry: viam.proto.app.FragmentHistoryEntry) -> typing_extensions.Self :classmethod: Create a `FragmentHistoryEntry` from the .proto defined `FragmentHistoryEntry`. :param fragment_history_entry: The object to copy from. :type fragment_history_entry: viam.proto.app.FragmentHistoryEntry :returns: The `FragmentHistoryEntry`. :rtype: FragmentHistoryEntry .. py:attribute:: fragment :type: str .. py:attribute:: edited_on :type: datetime.datetime .. py:attribute:: old :type: Fragment .. py:attribute:: edited_by :type: viam.proto.app.AuthenticatorInfo .. py:property:: proto :type: viam.proto.app.FragmentHistoryEntry .. py:class:: RobotPartHistoryEntry A class that mirrors the `RobotPartHistoryEntry` proto message. Use this class to make the attributes of a `viam.proto.app.RobotPartHistoryEntry` more accessible and easier to read/interpret. .. py:method:: from_proto(robot_part_history_entry: viam.proto.app.RobotPartHistoryEntry) -> typing_extensions.Self :classmethod: Create a `RobotPartHistoryEntry` from the .proto defined `RobotPartHistoryEntry`. :param robot_part_history_entry: The object to copy from. :type robot_part_history_entry: viam.proto.app.RobotPartHistoryEntry :returns: The `RobotPartHistoryEntry`. :rtype: RobotPartHistoryEntry .. py:attribute:: part :type: str .. py:attribute:: robot :type: str .. py:attribute:: when :type: Optional[datetime.datetime] .. py:attribute:: old :type: Optional[RobotPart] .. py:property:: proto :type: viam.proto.app.RobotPartHistoryEntry .. py:class:: APIKeyAuthorization(role: Union[Literal['owner'], Literal['operator']], resource_type: Union[Literal['organization'], Literal['location'], Literal['robot']], resource_id: str) A class with the necessary authorization data for creating an API key. Use this class when constructing API key authorizations to minimize the risk of malformed or missing data. .. py:class:: AppClient(channel: grpclib.client.Channel, metadata: Mapping[str, str], location_id: Optional[str] = None) gRPC client for method calls to app. Constructor is used by `ViamClient` to instantiate relevant service stub. Calls to `AppClient` methods should be made through `ViamClient`. Establish a Connection:: import asyncio from viam.rpc.dial import DialOptions, Credentials from viam.app.viam_client import ViamClient async def connect() -> ViamClient: # Replace "" (including brackets) with your API key and "" with your API key ID dial_options = DialOptions.with_api_key("", "") return await ViamClient.create_from_dial_options(dial_options) async def main(): # Make a ViamClient viam_client = await connect() # Instantiate an AppClient called "cloud" to run cloud app API methods on cloud = viam_client.app_client viam_client.close() if __name__ == '__main__': asyncio.run(main()) For more information, see `Fleet Management API `_. .. py:method:: get_user_id_by_email(email: str) -> str :async: Get the ID of a user by email. :: id = await cloud.get_user_id_by_email("youremail@email.com") :param email: The email of the user. :type email: str :returns: The ID of the user. :rtype: str For more information, see `Fleet Management API `_. .. py:method:: create_organization(name: str) -> viam.proto.app.Organization :async: Create an organization. :: organization = await cloud.create_organization("name") :param name: The name of the organization. :type name: str :returns: The created organization. :rtype: Organization For more information, see `Fleet Management API `_. .. py:method:: list_organizations() -> List[viam.proto.app.Organization] :async: List the organization(s) the user is an authorized owner of. :: org_list = await cloud.list_organizations() :returns: The list of organizations. :rtype: List[viam.proto.app.Organization] For more information, see `Fleet Management API `_. .. py:method:: get_organizations_with_access_to_location(location_id: str) -> List[viam.proto.app.OrganizationIdentity] :async: Get all organizations that have access to a location. :: org_list = await cloud.get_organizations_with_access_to_location("location-id") :param location_id: The ID of the location. :type location_id: str :returns: The list of organizations. :rtype: List[viam.proto.app.OrganizationIdentity] For more information, see `Fleet Management API `_. .. py:method:: list_organizations_by_user(user_id: str) -> List[viam.proto.app.OrgDetails] :async: List the organizations a user belongs to. :: org_list = await cloud.list_organizations_by_user("") :param user_id: The ID of the user. You can retrieve this with the get_user_id_by_email() method. :type user_id: str :returns: The list of organizations. :rtype: List[OrgDetails] For more information, see `Fleet Management API `_. .. py:method:: get_organization(org_id: str) -> viam.proto.app.Organization :async: Retrieve the organization object for the requested organization containing the organization's ID, name, public namespace, and more. :: org = await cloud.get_organization("") :param org_id: The ID of the organization to query. You can retrieve this from the organization settings page. :type org_id: str :raises GRPCError: If the provided org_id is invalid, or not currently authed to. :returns: The requested organization. :rtype: viam.proto.app.Organization For more information, see `Fleet Management API `_. .. py:method:: get_organization_namespace_availability(public_namespace: str) -> bool :async: Check the availability of an organization namespace. :: available = await cloud.get_organization_namespace_availability( public_namespace="my-cool-organization") :param public_namespace: Organization namespace to check. Namespaces can only contain lowercase alphanumeric and dash characters. :type public_namespace: str :raises GRPCError: If an invalid namespace (for example, "") is provided. :returns: True if the provided namespace is available. :rtype: bool For more information, see `Fleet Management API `_. .. py:method:: update_organization(org_id: str, name: Optional[str] = None, public_namespace: Optional[str] = None, region: Optional[str] = None, cid: Optional[str] = None) -> viam.proto.app.Organization :async: Updates organization details. :: organization = await cloud.update_organization( org_id="", name="Artoo's Org", public_namespace="artoo" ) :param org_id: The ID of the organization to update. :type org_id: str :param name: If provided, updates the org's name. :type name: Optional[str] :param public_namespace: If provided, sets the org's namespace if it hasn't already been set. :type public_namespace: Optional[str] :param region: If provided, updates the org's region. :type region: Optional[str] :param cid: If provided, update's the org's CRM ID. :type cid: Optional[str] :raises GRPCError: If the org's namespace has already been set, or if the provided namespace is already taken. :returns: The updated organization. :rtype: viam.proto.app.Organization For more information, see `Fleet Management API `_. .. py:method:: delete_organization(org_id: str) -> None :async: Delete an organization :: await cloud.delete_organization("") :param org_id: The ID of the organization. You can obtain your organization ID from the organization settings page. :type org_id: str For more information, see `Fleet Management API `_. .. py:method:: list_organization_members(org_id: str) -> Tuple[List[viam.proto.app.OrganizationMember], List[viam.proto.app.OrganizationInvite]] :async: List the members and invites of the currently authed-to organization. :: member_list, invite_list = await cloud.list_organization_members("") :param org_id: The ID of the organization to list members of. You can obtain your organization ID from the organization settings page. :type org_id: str :returns: A tuple containing two lists; the first [0] of organization members, and the second [1] of organization invites. :rtype: Tuple[List[viam.proto.app.OrganizationMember], List[viam.proto.app.OrganizationInvite]] For more information, see `Fleet Management API `_. .. py:method:: create_organization_invite(org_id: str, email: str, authorizations: Optional[List[viam.proto.app.Authorization]] = None, send_email_invite: bool = True) -> viam.proto.app.OrganizationInvite :async: Creates an organization invite and sends it via email. :: await cloud.create_organization_invite("", "youremail@email.com") :param org_id: The ID of the organization to create an invite for. You can obtain your organization ID from the organization settings page. :type org_id: str :param email: The email address to send the invite to. :type email: str :param authorizations: Specifications of the authorizations to include in the invite. If not provided, full owner permissions will be granted. :type authorizations: Optional[List[viam.proto.app.Authorization]] :param send_email_invite: Whether or not an email should be sent to the recipient of an invite. The user must accept the email to be added to the associated authorizations. When set to false, the user automatically receives the associated authorization on the next login of the user with the associated email address. :type send_email_invite: Optional[bool] :raises GRPCError: if an invalid email is provided, or if the user is already a member of the org. :returns: The organization invite. :rtype: OrganizationInvite For more information, see `Fleet Management API `_. .. py:method:: update_organization_invite_authorizations(org_id: str, email: str, add_authorizations: Optional[List[viam.proto.app.Authorization]] = None, remove_authorizations: Optional[List[viam.proto.app.Authorization]] = None) -> viam.proto.app.OrganizationInvite :async: Update the authorizations attached to an organization invite that has already been created. Note that an invite can only have one authorization at each resource (for example, organization, location, robot, etc.) level and must have at least one authorization overall. :: from viam.proto.app import Authorization auth = Authorization( authorization_type="role", authorization_id="location_owner", resource_type="location", # "robot", "location", or "organization" resource_id="012456lni0", # machine id, location id or org id identity_id="", organization_id="", identity_type="" ) update_invite = await cloud.update_organization_invite_authorizations( org_id="", email="notarealemail@viam.com", add_authorizations=[auth] ) :param org_id: The ID of the organization that the invite is for. You can obtain your organization ID from the organization settings page. :type org_id: str :param email: Email of the user the invite was sent to. :type email: str :param add_authorizations: Optional list of authorizations to add to the invite. :type add_authorizations: Optional[List[viam.proto.app.Authorization]] :param remove_authorizations: Optional list of authorizations to remove from the invite. :type remove_authorizations: Optional[List[viam.proto.app.Authorization]] :raises GRPCError: If no authorizations are passed or if an invalid combination of authorizations is passed (for example an authorization to remove when the invite only contains one authorization). :returns: The updated invite. :rtype: viam.proto.app.OrganizationInvite For more information, see `Fleet Management API `_. .. py:method:: delete_organization_member(org_id: str, user_id: str) -> None :async: Remove a member from the organization. :: member_list, invite_list = await cloud.list_organization_members(org_id="") first_user_id = member_list[0].user_id await cloud.delete_organization_member(org_id="org_id", user_id=first_user_id) :param org_id: The ID of the org to remove the user from. You can obtain your organization ID from the organization settings page. :type org_id: str :param user_id: The ID of the user to remove. :type user_id: str For more information, see `Fleet Management API `_. .. py:method:: delete_organization_invite(org_id: str, email: str) -> None :async: Deletes a pending organization invite. :: await cloud.delete_organization_invite("", "youremail@email.com") :param org_id: The ID of the organization that the invite to delete was for. You can obtain your organization ID from the organization settings page. :type org_id: str :param email: The email address the pending invite was sent to. :type email: str :raises GRPCError: If no pending invite is associated with the provided email address. For more information, see `Fleet Management API `_. .. py:method:: resend_organization_invite(org_id: str, email: str) -> viam.proto.app.OrganizationInvite :async: Re-sends a pending organization invite email. :: org_invite = await cloud.resend_organization_invite("", "youremail@email.com") :param org_id: The ID of the organization that the invite to resend was for. You can obtain your organization ID from the organization settings page. :type org_id: str :param email: The email address associated with the invite. :type email: str :raises GRPCError: If no pending invite is associated with the provided email address. :returns: The organization invite sent. :rtype: viam.proto.app.OrganizationInvite For more information, see `Fleet Management API `_. .. py:method:: create_location(org_id: str, name: str, parent_location_id: Optional[str] = None) -> viam.proto.app.Location :async: Create and name a location under the currently authed-to organization and the specified parent location. :: my_new_location = await cloud.create_location(org_id="", name="Robotville", parent_location_id="111ab12345") :param org_id: The ID of the organization to create the location under. You can obtain your organization ID from the organization settings page. :type org_id: str :param name: Name of the location. :type name: str :param parent_location_id: Optional parent location to put the location under. Defaults to a root-level location if no location ID is provided. :type parent_location_id: Optional[str] :raises GRPCError: If either an invalid name (for example, ""), or parent location ID (for example, a nonexistent ID) is passed. :returns: The newly created location. :rtype: viam.proto.app.Location For more information, see `Fleet Management API `_. .. py:method:: get_location(location_id: Optional[str] = None) -> viam.proto.app.Location :async: Get a location. :: location = await cloud.get_location(location_id="123ab12345") :param location_id: ID of the location to get. Defaults to the location ID provided at `AppClient` instantiation. :type location_id: Optional[str] :raises GRPCError: If an invalid location ID is passed or if one isn't passed and there was no location ID provided at `AppClient` instantiation. :returns: The location. :rtype: viam.proto.app.Location For more information, see `Fleet Management API `_. .. py:method:: update_location(location_id: str, name: Optional[str] = None, parent_location_id: Optional[str] = None) -> viam.proto.app.Location :async: Change the name of a location and/or assign it a new parent location. :: # The following line takes the location with ID "abc12abcde" and moves it to be a # sub-location of the location with ID "xyz34xxxxx" my_updated_location = await cloud.update_location( location_id="abc12abcde", name="", parent_location_id="xyz34xxxxx", ) # The following line changes the name of the location without changing its parent location my_updated_location = await cloud.update_location( location_id="abc12abcde", name="Land Before Robots" ) # The following line moves the location back up to be a top level location without changing its name my_updated_location = await cloud.update_location( location_id="abc12abcde", name="", parent_location_id="" ) :param location_id: ID of the location to update. Must be specified. :type location_id: str :param name: Optional new name to be updated on the location. Defaults to the empty string "" (that is, the name doesn't change). :type name: Optional[str] :param parent_location_id: Optional ID of new parent location to move the location under. Defaults to the empty string "" (that is, no new parent location is assigned). :type parent_location_id: Optional[str] :raises GRPCError: If either an invalid location ID, name, or parent location ID is passed. :returns: The newly updated location. :rtype: viam.proto.app.Location For more information, see `Fleet Management API `_. .. py:method:: delete_location(location_id: str) -> None :async: Delete a location. :: await cloud.delete_location(location_id="abc12abcde") :param location_id: ID of the location to delete. Must be specified. :type location_id: str :raises GRPCError: If an invalid location ID is passed. For more information, see `Fleet Management API `_. .. py:method:: list_locations(org_id: str) -> List[viam.proto.app.Location] :async: Get a list of all locations under the currently authed-to organization. :: locations = await cloud.list_locations("") :param org_id: The ID of the org to list locations for. You can obtain your organization ID from the organization settings page. :type org_id: str :returns: The list of locations. :rtype: List[viam.proto.app.Location] For more information, see `Fleet Management API `_. .. py:method:: share_location(organization_id: str, location_id: str) -> None :async: Share a location with an organization. :: await cloud.share_location("", "") :param organization_id: The ID of the organization. :type organization_id: str :param location_id: The ID of the location. :type location_id: str For more information, see `Fleet Management API `_. .. py:method:: unshare_location(organization_id: str, location_id: str) -> None :async: Stop sharing a location with an organization. :: await cloud.unshare_location("", "") :param organization_id: The ID of the organization. :type organization_id: str :param location_id: The ID of the location. :type location_id: str For more information, see `Fleet Management API `_. .. py:method:: location_auth(location_id: Optional[str] = None) -> viam.proto.app.LocationAuth :async: Get a location's `LocationAuth` (location secret(s)). :: loc_auth = await cloud.location_auth(location_id="123xy12345") :param location_id: ID of the location to retrieve `LocationAuth` from. Defaults to the location ID provided at `AppClient` instantiation. :type location_id: str :raises GRPCError: If an invalid location ID is passed or if one isn't passed and there was no location ID provided at `AppClient` instantiation. :returns: The `LocationAuth` containing location secrets. :rtype: viam.proto.app.LocationAuth For more information, see `Fleet Management API `_. .. py:method:: create_location_secret(location_id: Optional[str] = None) -> viam.proto.app.LocationAuth :async: Create a new location secret. :: new_loc_auth = await cloud.create_location_secret(location_id="123xy12345") :param location_id: ID of the location to generate a new secret for. Defaults to the location ID provided at `AppClient` instantiation. :type location_id: Optional[str] :raises GRPCError: If an invalid location ID is passed or one isn't passed and there was no location ID provided at `AppClient` instantiation. :returns: The specified location's `LocationAuth` containing the newly created secret. :rtype: viam.proto.app.LocationAuth For more information, see `Fleet Management API `_. .. py:method:: delete_location_secret(secret_id: str, location_id: Optional[str] = None) -> None :async: Delete a location secret. :: await cloud.delete_location_secret( secret_id="abcd123-456-7890ab-cxyz98-989898xyzxyz", location_id="123xy12345" ) :param location_id: ID of the location to delete secret from. Defaults to the location ID provided at `AppClient` instantiation. :type location_id: str :param secret_id: ID of the secret to delete. :type secret_id: str :raises GRPCError: If either an invalid location ID or secret ID is passed or a location ID isn't passed and there was no location ID provided at `AppClient` instantiation. For more information, see `Fleet Management API `_. .. py:method:: get_robot(robot_id: str) -> viam.proto.app.Robot :async: Get a machine. :: machine = await cloud.get_robot(robot_id="1a123456-x1yz-0ab0-a12xyzabc") :param robot_id: ID of the machine to get. You can copy this value from the URL of the machine's page. :type robot_id: str :raises GRPCError: If an invalid machine ID is passed. :returns: The machine. :rtype: viam.proto.app.Robot For more information, see `Fleet Management API `_. .. py:method:: get_rover_rental_robots(org_id: str) -> List[viam.proto.app.RoverRentalRobot] :async: Returns a list of rover rental robots within an org. :: rental_robots = await cloud.get_rover_rental_robots() :param org_id: The ID of the organization to list rover rental robots for. You can obtain your organization ID from the organization settings page. :type org_id: str :returns: The list of rover rental robots. :rtype: List[viam.proto.app.RoverRentalRobot] For more information, see `Fleet Management API `_. .. py:method:: get_robot_parts(robot_id: str) -> List[RobotPart] :async: Get a list of all the parts under a specific machine. :: list_of_parts = await cloud.get_robot_parts( robot_id="1a123456-x1yz-0ab0-a12xyzabc" ) :param robot_id: ID of the machine to get parts from. :type robot_id: str :raises GRPCError: If an invalid machine ID is passed. :returns: The list of machine parts. :rtype: List[viam.app.app_client.RobotPart] For more information, see `Fleet Management API `_. .. py:method:: get_robot_part(robot_part_id: str, dest: Optional[str] = None, indent: int = 4) -> RobotPart :async: Get a machine part. :: my_robot_part = await cloud.get_robot_part( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22" ) # Get the part's address address = my_robot_part.fqdn # Check if machine is live (last access time less than 10 sec ago) if (time.time() - my_robot_part.last_access.timestamp()) <= 10000: print("Machine is live.") :param robot_part_id: ID of the machine part to get. You can retrieve this value by navigating to the machine's page, clicking on the part status dropdown, and clicking the copy icon next to Part ID. :type robot_part_id: str :param dest: Optional filepath to write the machine part's config file in JSON format to. :type dest: Optional[str] :param indent: Size (in number of spaces) of indent when writing config to `dest`. Defaults to 4. :type indent: int :raises GRPCError: If an invalid machine part ID is passed. :returns: The machine part. :rtype: viam.app.app_client.RobotPart For more information, see `Fleet Management API `_. .. py:method:: get_robot_part_logs(robot_part_id: str, filter: Optional[str] = None, dest: Optional[str] = None, log_levels: List[str] = [], num_log_entries: int = 100) -> List[LogEntry] :async: Get the logs associated with a robot part. :: part_logs = await cloud.get_robot_part_logs( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22", num_log_entries=20 ) :param robot_part_id: ID of the machine part to get logs from. :type robot_part_id: str :param filter: Only include logs with messages that contain the string `filter`. Defaults to empty string "" (that is, no filter). :type filter: Optional[str] :param dest: Optional filepath to write the log entries to. :type dest: Optional[str] :param log_levels: List of log levels for which entries should be returned. Defaults to empty list, which returns all logs. :type log_levels: List[str] :param num_log_entries: Number of log entries to return. Passing 0 returns all logs. Defaults to 100. All logs or the first `num_log_entries` logs will be returned, whichever comes first. :type num_log_entries: int :raises GRPCError: If an invalid robot part ID is passed. :returns: The list of log entries. :rtype: List[viam.app.app_client.LogEntry] For more information, see `Fleet Management API `_. .. py:method:: tail_robot_part_logs(robot_part_id: str, errors_only: bool = True, filter: Optional[str] = None) -> viam.app._logs._LogsStream[List[LogEntry]] :async: Get an asynchronous iterator that receives live machine part logs. :: logs_stream = await cloud.tail_robot_part_logs( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22" ) :param robot_part_id: ID of the machine part to retrieve logs from. :type robot_part_id: str :param errors_only: Boolean specifying whether or not to only include error logs. Defaults to True. :type errors_only: bool :param filter: Only include logs with messages that contain the string `filter`. Defaults to empty string "" (that is, no filter). :type filter: Optional[str] :returns: The asynchronous iterator receiving live machine part logs. :rtype: _LogsStream[List[LogEntry]] .. py:method:: get_robot_part_history(robot_part_id: str) -> List[RobotPartHistoryEntry] :async: Get a list containing the history of a machine part. :: part_history = await cloud.get_robot_part_history( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22" ) :param robot_part_id: ID of the machine part to retrieve history from. :type robot_part_id: str :raises GRPCError: If an invalid machine part ID is provided. :returns: The list of the machine part's history. :rtype: List[viam.app.app_client.RobotPartHistoryEntry] For more information, see `Fleet Management API `_. .. py:method:: update_robot_part(robot_part_id: str, name: str, robot_config: Optional[Mapping[str, Any]] = None, last_known_update: Optional[datetime.datetime] = None) -> RobotPart :async: Change the name and assign an optional new configuration to a machine part. :: my_machine_part = await cloud.update_robot_part( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22" ) :param robot_part_id: ID of the robot part to update. :type robot_part_id: str :param name: New name to be updated on the robot part. :type name: str :param robot_config: Optional new config represented as a dictionary to be updated on the machine part. The machine part's config will remain as is (no change) if one isn't passed. :type robot_config: Mapping[str, Any] :param last_known_update: Optional time of the last known update to this part's config. If provided, this will result in a GRPCError if the upstream config has changed since this time, indicating that the local config is out of date. Omitting this parameter will result in an overwrite of the upstream config. :type last_known_update: datetime :raises GRPCError: If either an invalid machine part ID, name, or config is passed, or if the upstream config has changed since last_known_update. :returns: The newly updated robot part. :rtype: viam.app.app_client.RobotPart For more information, see `Fleet Management API `_. .. py:method:: new_robot_part(robot_id: str, part_name: str) -> str :async: Create a new machine part. :: new_part_id = await cloud.new_robot_part( robot_id="1a123456-x1yz-0ab0-a12xyzabc", part_name="myNewSubPart" ) :param robot_id: ID of the machine to create a new part for. :type robot_id: str :param part_name: Name of the new part. :type part_name: str :raises GRPCError: If either an invalid machine ID or name is passed. :returns: The new machine part's ID. :rtype: str For more information, see `Fleet Management API `_. .. py:method:: delete_robot_part(robot_part_id: str) -> None :async: Delete the specified machine part. :: await cloud.delete_robot_part( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22" ) :param robot_part_id: ID of the machine part to delete. Must be specified. :type robot_part_id: str :raises GRPCError: If an invalid machine part ID is passed. For more information, see `Fleet Management API `_. .. py:method:: get_robot_api_keys(robot_id: str) -> List[viam.proto.app.APIKeyWithAuthorizations] :async: Gets the API Keys for the machine. :: api_keys = await cloud.get_robot_api_keys(robot_id="robot-id") :param robot_id: The ID of the machine. :type robot_id: str :returns: The list of API keys. :rtype: List[APIKeyWithAuthorizations] For more information, see `Fleet Management API `_. .. py:method:: mark_part_as_main(robot_part_id: str) -> None :async: Mark a machine part as the main part of a machine. :: await cloud.mark_part_as_main( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22") :param robot_part_id: ID of the machine part to mark as main. :type robot_part_id: str :raises GRPCError: If an invalid machine part ID is passed. For more information, see `Fleet Management API `_. .. py:method:: mark_part_for_restart(robot_part_id: str) -> None :async: Mark the specified machine part for restart. :: await cloud.mark_part_for_restart( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22") :param robot_part_id: ID of the machine part to mark for restart. :type robot_part_id: str :raises GRPCError: If an invalid machine part ID is passed. For more information, see `Fleet Management API `_. .. py:method:: create_robot_part_secret(robot_part_id: str) -> RobotPart :async: Create a machine part secret. :: part_with_new_secret = await cloud.create_robot_part_secret( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22") :param robot_part_id: ID of the machine part to create a secret for. :type robot_part_id: str :raises GRPCError: If an invalid machine part ID is passed. :returns: The machine part the new secret was generated for. :rtype: viam.app.app_client.RobotPart For more information, see `Fleet Management API `_. .. py:method:: delete_robot_part_secret(robot_part_id: str, secret_id: str) -> None :async: Delete a machine part secret. :: await cloud.delete_robot_part_secret( robot_part_id="abc12345-1a23-1234-ab12-a22a22a2aa22", secret_id="123xyz12-abcd-4321-12ab-12xy1xyz12xy") :param robot_part_id: ID of the machine part to delete the secret from. :type robot_part_id: str :param secret_id: ID of the secret to delete. :type secret_id: str :raises GRPCError: If an invalid machine part ID or secret ID is passed. For more information, see `Fleet Management API `_. .. py:method:: list_robots(location_id: Optional[str] = None) -> List[viam.proto.app.Robot] :async: Get a list of all machines under the specified location. :: list_of_machines = await cloud.list_robots(location_id="123ab12345") :param location_id: ID of the location to retrieve the machines from. Defaults to the location ID provided at `AppClient` instantiation. :type location_id: Optional[str] :raises GRPCError: If an invalid location ID is passed or one isn't passed and there was no location ID provided at `AppClient` instantiation. :returns: The list of robots. :rtype: List[viam.proto.app.Robot] For more information, see `Fleet Management API `_. .. py:method:: new_robot(name: str, location_id: Optional[str] = None) -> str :async: Create a new machine. :: new_machine_id = await cloud.new_robot(name="beepboop", location_id="my-location-id") :param name: Name of the new machine. :type name: str :param location_id: ID of the location under which to create the machine. Defaults to the current authorized location. :type location_id: Optional[str] :raises GRPCError: If an invalid location ID is passed or one isn't passed and there was no location ID provided at `AppClient` instantiation. :returns: The new robot's ID. :rtype: str For more information, see `Fleet Management API `_. .. py:method:: update_robot(robot_id: str, name: str, location_id: Optional[str] = None) -> viam.proto.app.Robot :async: Change the name of an existing machine. :: updated_robot = await cloud.update_robot( robot_id="1a123456-x1yz-0ab0-a12xyzabc", name="Orange-Robot", location_id="23ab12345" ) :param robot_id: ID of the machine to update. :type robot_id: str :param name: New name to be updated on the machine. :type name: str :param location_id: ID of the location under which the machine exists. Defaults to the location ID provided at `AppClient` instantiation :type location_id: Optional[str] :raises GRPCError: If either an invalid machine ID, name, or location ID is passed or a location ID isn't passed and there was no location ID provided at `AppClient` instantiation. :returns: The newly updated machine. :rtype: viam.proto.app.Robot For more information, see `Fleet Management API `_. .. py:method:: delete_robot(robot_id: str) -> None :async: Delete the specified machine. :: await cloud.delete_robot(robot_id="1a123456-x1yz-0ab0-a12xyzabc") :param robot_id: ID of the machine to delete. :type robot_id: str :raises GRPCError: If an invalid machine ID is passed. For more information, see `Fleet Management API `_. .. py:method:: list_fragments(org_id: str, show_public: bool = True, visibilities: Optional[List[Fragment]] = None) -> List[Fragment] :async: Get a list of fragments under the currently authed-to organization. :: fragments_list = await cloud.list_fragments(org_id="org-id", visibilities=[]) :param org_id: The ID of the organization to list fragments for. You can obtain your organization ID from the organization settings page. :type org_id: str :param show_public: Optional boolean specifying whether or not to only show public fragments. If True, only public fragments will return. If False, only private fragments will return. Defaults to True. .. deprecated:: 0.25.0 Use ``visibilities`` instead. :type show_public: bool :param visibilities: List of FragmentVisibilities specifying which types of fragments to include in the results. If empty, by default only public fragments will be returned. :type visibilities: Optional[List[Fragment.Visibility]] :returns: The list of fragments. :rtype: List[viam.app.app_client.Fragment] For more information, see `Fleet Management API `_. .. py:method:: get_fragment(fragment_id: str) -> Fragment :async: Get a fragment. :: # Get a fragment and print its name and when it was created. the_fragment = await cloud.get_fragment( fragment_id="12a12ab1-1234-5678-abcd-abcd01234567") print("Name: ", the_fragment.name, "\nCreated on: ", the_fragment.created_on) :param fragment_id: ID of the fragment to get. :type fragment_id: str :raises GRPCError: If an invalid fragment ID is passed. :returns: The fragment. :rtype: viam.app.app_client.Fragment For more information, see `Fleet Management API `_. .. py:method:: create_fragment(org_id: str, name: str, config: Optional[Mapping[str, Any]] = None) -> Fragment :async: Create a new private fragment. :: new_fragment = await cloud.create_fragment(org_id="org-id", name="cool_smart_machine_to_configure_several_of") :param org_id: The ID of the organization to create the fragment within. You can obtain your organization ID from the organization settings page. :type org_id: str :param name: Name of the fragment. :type name: str :param config: Optional Dictionary representation of new config to assign to specified fragment. Can be assigned by updating the fragment. :type config: Optional[Mapping[str, Any]] :raises GRPCError: If an invalid name is passed. :returns: The newly created fragment. :rtype: viam.app.app_client.Fragment For more information, see `Fleet Management API `_. .. py:method:: update_fragment(fragment_id: str, name: str, config: Optional[Mapping[str, Any]] = None, public: Optional[bool] = None, visibility: Optional[Fragment] = None, last_known_update: Optional[datetime.datetime] = None) -> Fragment :async: Update a fragment name AND its config and/or visibility. :: updated_fragment = await cloud.update_fragment( fragment_id="12a12ab1-1234-5678-abcd-abcd01234567", name="better_name") :param fragment_id: ID of the fragment to update. :type fragment_id: str :param name: New name to associate with the fragment. :type name: str :param config: Optional Dictionary representation of new config to assign to specified fragment. Not passing this parameter will leave the fragment's config unchanged. :type config: Optional[Mapping[str, Any]] :param public: Boolean specifying whether the fragment is public. Not passing this parameter will leave the fragment's visibility unchanged. A fragment is private by default when created. .. deprecated:: 0.25.0 Use ``visibility`` instead. :type public: bool :param visibility: Optional FragmentVisibility list specifying who should be allowed to view the fragment. Not passing this parameter will leave the fragment's visibility unchanged. A fragment is private by default when created. :type visibility: Optional[FragmentVisibility] :param last_known_update: Optional time of the last known update to this fragment's config. If provided, this will result in a GRPCError if the upstream config has changed since this time, indicating that the local config is out of date. Omitting this parameter will result in an overwrite of the upstream config. :type last_known_update: datetime :raises GRPCError: if an invalid ID, name, or config is passed, or if the upstream fragment config has changed since last_known_update. :returns: The newly updated fragment. :rtype: viam.app.app_client.Fragment For more information, see `Fleet Management API `_. .. py:method:: delete_fragment(fragment_id: str) -> None :async: Delete a fragment. :: await cloud.delete_fragment( fragment_id="12a12ab1-1234-5678-abcd-abcd01234567") :param fragment_id: ID of the fragment to delete. :type fragment_id: str :raises GRPCError: If an invalid fragment ID is passed. For more information, see `Fleet Management API `_. .. py:method:: get_fragment_history(id: str, page_token: Optional[str] = '', page_limit: Optional[int] = 10) -> List[FragmentHistoryEntry] :async: Get fragment history. :: fragment_history = await cloud.get_fragment_history( id = "12a12ab1-1234-5678-abcd-abcd01234567", page_token = "pg-token", page_limit = 10 ) :param id: ID of the fragment to fetch history for. :type id: str :param page_token: the page token for the fragment history collection :type page_token: Optional[str] :param page_limit: the number of fragment history documents to return in the result. The default page limit is 10. :type page_limit: Optional[int] :raises GRPCError: if an invalid fragment id, page token or page limit is passed. :returns: A list of documents with the fragment history. :rtype: viam.app.app_client.FragmentHistoryResponse For more information, see `Fleet Management API `_. .. py:method:: add_role(org_id: str, identity_id: str, role: Union[Literal['owner'], Literal['operator']], resource_type: Union[Literal['organization'], Literal['location'], Literal['robot']], resource_id: str) -> None :async: Add a role under the currently authed-to organization. :: await cloud.add_role( org_id="", identity_id="abc01234-0123-4567-ab12-a11a00a2aa22", role="owner", resource_type="location", resource_id="111ab12345" ) :param org_id: The ID of the organization to create the role in. You can obtain your organization ID from the organization settings page. :type org_id: str :param identity_id: ID of the entity the role belongs to (for example, a user ID). :type identity_id: str :param role: The role to add. :type role: Union[Literal["owner"], Literal["operator"]] :param resource_type: Type of the resource to add role to. Must match `resource_id`. :type resource_type: Union[Literal["organization"], Literal["location"], Literal["robot"]] :param resource_id: ID of the resource the role applies to (that is, either an organization, location, or robot ID). :type resource_id: str :raises GRPCError: If either an invalid identity ID, role ID, resource type, or resource ID is passed. For more information, see `Fleet Management API `_. .. py:method:: remove_role(org_id: str, identity_id: str, role: Union[Literal['owner'], Literal['operator']], resource_type: Union[Literal['organization'], Literal['location'], Literal['robot']], resource_id: str) -> None :async: Remove a role under the currently authed-to organization. :: await cloud.remove_role( org_id="", identity_id="abc01234-0123-4567-ab12-a11a00a2aa22", role="owner", resource_type="location", resource_id="111ab12345" ) :param org_id: The ID of the organization the role exists in. You can obtain your organization ID from the organization settings page. :type org_id: str :param identity_id: ID of the entity the role belongs to (for example, a user ID). :type identity_id: str :param role: The role to remove. :type role: Union[Literal["owner"], Literal["operator"]] :param resource_type: Type of the resource the role is being removed from. Must match `resource_id`. :type resource_type: Union[Literal["organization"], Literal["location"], Literal["robot"]] :param resource_id: ID of the resource the role applies to (that is, either an organization, location, or robot ID). :type resource_id: str :raises GRPCError: If either an invalid identity ID, role ID, resource type, or resource ID or is passed. For more information, see `Fleet Management API `_. .. py:method:: change_role(organization_id: str, old_identity_id: str, old_role: Union[Literal['owner'], Literal['operator']], old_resource_type: Union[Literal['organization'], Literal['location'], Literal['robot']], old_resource_id: str, new_identity_id: str, new_role: Union[Literal['owner'], Literal['operator']], new_resource_type: Union[Literal['organization'], Literal['location'], Literal['robot']], new_resource_id: str) -> None :async: Changes a role to a new role. :: await cloud.change_role( organization_id="", old_identity_id="abc01234-0123-4567-ab12-a11a00a2aa22", old_role="operator", old_resource_type="location", old_resource_id="111ab12345", new_identity_id="abc01234-0123-4567-ab12-a11a00a2aa22", new_role="owner", new_resource_type="organization", new_resource_id="abc12345" ) :param organization_id: ID of the organization :type organization_id: str :param old_identity_id: ID of the entity the role belongs to (for example, a user ID). :type old_identity_id: str :param old_role: The role to be changed. :type old_role: Union[Literal["owner"], Literal["operator"]] :param old_resource_type: Type of the resource the role is added to. Must match `old_resource_id`. :type old_resource_type: Union[Literal["organization"], Literal["location"], Literal["robot"]] :param old_resource_id: ID of the resource the role applies to (that is, either an organization, location, or robot ID). :type old_resource_id: str :param new_identity_id: New ID of the entity the role belongs to (for example, a user ID). :type new_identity_id: str :param new_role: The new role. :type new_role: Union[Literal["owner"], Literal["operator"]] :param new_resource_type: Type of the resource to add role to. Must match `new_resource_id`. :type new_resource_type: Union[Literal["organization"], Literal["location"], Literal["robot"]] :param new_resource_id: New ID of the resource the role applies to (that is, either an organization, location, or robot ID). :type new_resource_id: str For more information, see `Fleet Management API `_. .. py:method:: list_authorizations(org_id: str, resource_ids: Optional[List[str]] = None) -> List[viam.proto.app.Authorization] :async: List all authorizations under a specific resource (or resources) within the currently authed-to organization. If no resource IDs are provided, all resource authorizations within the organizations are returned. :: list_of_auths = await cloud.list_authorizations( org_id="", resource_ids=["1a123456-x1yz-0ab0-a12xyzabc"]) :param org_id: The ID of the organization to list authorizations for. :param resource_ids: IDs of the resources to retrieve authorizations from. If None, defaults to all resources. :type resource_ids: Optional[List[str]] :raises GRPCError: If an invalid resource ID is passed. :returns: The list of authorizations. :rtype: List[viam.proto.app.Authorization] For more information, see `Fleet Management API `_. .. py:method:: check_permissions(permissions: List[viam.proto.app.AuthorizedPermissions]) -> List[viam.proto.app.AuthorizedPermissions] :async: Checks validity of a list of permissions. :: from viam.proto.app import AuthorizedPermissions # Check whether the entity you're currently authenticated to has permission to control and/or # read logs from robots in the "organization-identifier123" org permissions = [AuthorizedPermissions(resource_type="organization", resource_id="", permissions=["control_robot", "read_robot_logs"])] filtered_permissions = await cloud.check_permissions(permissions) :param permissions: the permissions to validate (for example, "read_organization", "control_robot") :type permissions: List[viam.proto.app.AuthorizedPermissions] :raises GRPCError: If the list of permissions to validate is empty. :returns: The permissions argument, with invalid permissions filtered out. :rtype: List[viam.proto.app.AuthorizedPermissions] For more information, see `Fleet Management API `_. .. py:method:: get_registry_item(item_id: str, include_markdown_documentation: bool = False) -> viam.proto.app.RegistryItem :async: Get registry item by ID. :: item = await cloud.get_registry_item("item-id") :param item_id: The ID of the registry item. This is the namespace and name of the item in the form `namespace:name`. For example, `Viam's csi-cam-pi module's `_ item ID would be `viam:csi-cam-pi`. You can also use `org-id:name`. For example, `abc01234-0123-4567-ab12-a11a00a2aa22:training-script`. :type item_id: str :returns: The registry item. :rtype: RegistryItem For more information, see `Fleet Management API `_. .. py:method:: create_registry_item(organization_id: str, name: str, type: viam.proto.app.packages.PackageType.ValueType) -> None :async: Create a registry item :: from viam.proto.app.packages import PackageType await cloud.create_registry_item("", "name", PackageType.PACKAGE_TYPE_ML_MODEL) :param organization_id: The organization to create the registry item under. :type organization_id: str :param name: The name of the registry item, which must be unique within your org. :type name: str :param type: The type of the item in the registry. :type type: PackageType.ValueType For more information, see `Fleet Management API `_. .. py:method:: update_registry_item(item_id: str, type: viam.proto.app.packages.PackageType.ValueType, description: str, visibility: viam.proto.app.Visibility.ValueType) -> None :async: Update a registry item. :: from viam.proto.app.packages import PackageType from viam.proto.app import Visibility await cloud.update_registry_item( "your-namespace:your-name", PackageType.PACKAGE_TYPE_ML_TRAINING, "description", Visibility.VISIBILITY_PUBLIC ) :param item_id: The ID of the registry item, containing either the namespace and module name (for example, `my-org:my-module`) or organization ID and module name (`org-id:my-module`). :type item_id: str :param type: The type of the item in the registry. :type type: PackageType.ValueType :param description: The description of the registry item. :type description: str :param visibility: The visibility of the registry item. :type visibility: Visibility.ValueType For more information, see `Fleet Management API `_. .. py:method:: list_registry_items(organization_id: str, types: List[viam.proto.app.packages.PackageType.ValueType], visibilities: List[viam.proto.app.Visibility.ValueType], platforms: List[str], statuses: List[viam.proto.app.RegistryItemStatus.ValueType], search_term: Optional[str] = None, page_token: Optional[str] = None) -> List[viam.proto.app.RegistryItem] :async: List the registry items in an organization. :: from viam.proto.app.packages import PackageType from viam.proto.app import Visibility, RegistryItemStatus # List private, published ml training scripts in your organization registry_items = await cloud.list_registry_items( organization_id="", types=[PackageType.PACKAGE_TYPE_ML_TRAINING], visibilities=[Visibility.VISIBILITY_PRIVATE], platforms=[""], statuses=[RegistryItemStatus.REGISTRY_ITEM_STATUS_PUBLISHED] ) # List public, published linux modules in all organizations registry_items = await cloud.list_registry_items( organization_id="", types=[PackageType.PACKAGE_TYPE_MODULE], visibilities=[Visibility.VISIBILITY_PUBLIC], platforms=["linux/any"], statuses=[RegistryItemStatus.REGISTRY_ITEM_STATUS_PUBLISHED] ) :param organization_id: The ID of the organization to return registry items for. :type organization_id: str :param types: The types of registry items. :type types: List[PackageType.ValueType] :param visibilities: The visibilities of registry items. :type visibilities: List[Visibility.ValueType] :param platforms: The platforms of registry items. :type platforms: List[str] :param statuses: The types of the items in the registry. :type statuses: List[RegistryItemStatus.ValueType] :param search_term: The search term of the registry items. :type search_term: Optional[str] :param page_token: The page token of the registry items. :type page_token: Optional[str] :returns: The list of registry items. :rtype: List[RegistryItem] For more information, see `Fleet Management API `_. .. py:method:: delete_registry_item(item_id: str) -> None :async: Delete a registry item :: await cloud.delete_registry_item("your-namespace:your-name") :param item_id: The ID of the deleted registry item, containing either the namespace and module name (for example, `my-org:my-module`) or organization ID and module name (`org-id:my-module`). :type item_id: str For more information, see `Fleet Management API `_. .. py:method:: create_module(org_id: str, name: str) -> Tuple[str, str] :async: Create a module under the currently authed-to organization. :: new_module = await cloud.create_module(org_id="org-id", name="cool_new_hoverboard_module") print("Module ID:", new_module[0]) :param org_id: The ID of the organization to create the module under. You can obtain your organization ID from the organization settings page. :type org_id: str :param name: The name of the module. Must be unique within your organization. :type name: str :raises GRPCError: If an invalid name (for example, "") is passed. :returns: A tuple containing the ID [0] of the new module and its URL [1]. :rtype: Tuple[str, str] For more information, see `Fleet Management API `_. .. py:method:: update_module(module_id: str, url: str, description: str, models: Optional[List[viam.proto.app.Model]], entrypoint: str, public: bool = False) -> str :async: Update the documentation URL, description, models, entrypoint, and/or the visibility of a module. :: from viam.proto.app import Model model = Model( api="rdk:component:base", model="my-group:cool_new_hoverboard_module:wheeled" ) url_of_my_module = await cloud.update_module( module_id="my-group:cool_new_hoverboard_module", url="https://docsformymodule.viam.com", models=[model], description="A base to support hoverboards.", entrypoint="exec" ) :param module_id: ID of the module being updated, containing either the namespace and module name (for example, `my-org:my-module`) or organization ID and module name (`org-id:my-module`). :type module_id: str :param url: The url to reference for documentation and code (NOT the url of the module itself). :type url: str :param description: A short description of the module that explains its purpose. :type description: str :param models: list of models that are available in the module. :type models: List[viam.proto.app.Model] :param entrypoint: The executable to run to start the module program. :type entrypoint: str :param public: The visibility that should be set for the module. Defaults to False (private). :type public: bool :raises GRPCError: If either an invalid module ID, URL, list of models, or organization ID is passed. :returns: The URL of the newly updated module. :rtype: str For more information, see `Fleet Management API `_. .. py:method:: upload_module_file(module_file_info: Optional[viam.proto.app.ModuleFileInfo], file: bytes) -> str :async: Upload a module file :: from viam.proto.app import ModuleFileInfo module_file_info = ModuleFileInfo( module_id = "sierra:cool_new_hoverboard_module", version = "1.0.0", platform = "darwin/arm64" ) file_id = await cloud.upload_module_file( module_file_info=module_file_info, file=b"" ) :param module_file_info: Relevant metadata. :type module_file_info: Optional[viam.proto.app.ModuleFileInfo] :param file: Bytes of file to upload. :type file: bytes :returns: URL of uploaded file. :rtype: str For more information, see `Fleet Management API `_. .. py:method:: get_module(module_id: str) -> viam.proto.app.Module :async: Get a module. :: the_module = await cloud.get_module(module_id="my-group:my-cool-modular-base") :param module_id: ID of the module being retrieved, containing either the namespace and module name (for example, `my-org:my-module`) or organization ID and module name (`org-id:my-module`). :type module_id: str :raises GRPCError: If an invalid module ID is passed. :returns: The module. :rtype: viam.proto.app.Module For more information, see `Fleet Management API `_. .. py:method:: list_modules(org_id: str) -> List[viam.proto.app.Module] :async: List the modules under the currently authed-to organization. :: modules_list = await cloud.list_modules("") :param org_id: The ID of the organization to list modules for. You can obtain your organization ID from the organization settings page. :type org_id: str :returns: The list of modules. :rtype: List[viam.proto.app.Module] For more information, see `Fleet Management API `_. .. py:method:: create_key(org_id: str, authorizations: List[APIKeyAuthorization], name: Optional[str] = None) -> Tuple[str, str] :async: Creates a new API key. :: from viam.app.app_client import APIKeyAuthorization auth = APIKeyAuthorization( role="owner", resource_type="robot", resource_id="your-machine-id123" ) api_key, api_key_id = cloud.create_key( org_id="", authorizations=[auth], name="my_key" ) :param org_id: The ID of the organization to create the key for. You can obtain your organization ID from the organization settings page. :type org_id: str :param authorizations: A list of authorizations to associate with the key. :type authorizations: List[viam.proto.app.Authorization] :param name: A name for the key. If None, defaults to the current timestamp. :type name: Optional[str] :raises GRPCError: If the authorizations list is empty. :returns: The api key and api key ID. :rtype: Tuple[str, str] For more information, see `Fleet Management API `_. .. py:method:: delete_key(id: str) -> None :async: Delete a API key. :: await cloud.delete_key("key-id") :param id: The ID of the API key. :type id: str For more information, see `Fleet Management API `_. .. py:method:: create_key_from_existing_key_authorizations(id: str) -> Tuple[str, str] :async: Creates a new API key with an existing key's authorizations :: api_key, api_key_id = await cloud.create_key_from_existing_key_authorizations( id="INSERT YOUR API KEY ID") :param id: the ID of the API key to duplication authorizations from :type id: str :returns: The API key and API key id :rtype: Tuple[str, str] For more information, see `Fleet Management API `_. .. py:method:: list_keys(org_id: str) -> List[viam.proto.app.APIKeyWithAuthorizations] :async: Lists all keys for the currently-authed-to org. :: keys = await cloud.list_keys(org_id="") :param org_id: The ID of the organization to list API keys for. You can obtain your organization ID from the organization settings page. :type org_id: str :returns: The existing API keys and authorizations. :rtype: List[viam.proto.app.APIKeyWithAuthorizations] For more information, see `Fleet Management API `_. .. py:method:: rotate_key(id: str) -> Tuple[str, str] :async: Rotate an API key. :: id, key = await cloud.rotate_key("key-id") :param id: The ID of the key to be rotated. :type id: str :returns: The API key and API key id :rtype: Tuple[str, str] For more information, see `Fleet Management API `_. .. py:method:: get_organization_metadata(org_id: str) -> Mapping[str, Any] :async: Get an organization's user-defined metadata. :: metadata = await cloud.get_organization_metadata(org_id="") :param org_id: The ID of the organization with which the user-defined metadata is associated. You can obtain your organization ID from the organization settings page. :type org_id: str :returns: The user-defined metadata converted from JSON to a Python dictionary :rtype: Mapping[str, Any] .. py:method:: update_organization_metadata(org_id: str, metadata: Mapping[str, Any]) -> None :async: Update an organization's user-defined metadata. :: await cloud.update_organization_metadata(org_id="", metadata=) :param organization_id: The ID of the organization with which to associate the user-defined metadata. You can obtain your organization ID from the organization settings page. :type organization_id: str :param metadata: The user-defined metadata to upload as a Python dictionary. :type metadata: Mapping[str, Any] .. py:method:: get_location_metadata(location_id: str) -> Mapping[str, Any] :async: Get a location's user-defined metadata. :: metadata = await cloud.get_location_metadata(location_id="") :param location_id: The ID of the location with which the user-defined metadata is associated. You can obtain your location ID from the locations page. :type location_id: str :returns: The user-defined metadata converted from JSON to a Python dictionary. :rtype: Mapping[str, Any] .. py:method:: update_location_metadata(location_id: str, metadata: Mapping[str, Any]) -> None :async: Update a location's user-defined metadata. :: await cloud.update_location_metadata(location_id="", metadata=) :param location_id: The ID of the location with which to associate the user-defined metadata. You can obtain your location ID from the locations page. :type location_id: str :param metadata: The user-defined metadata converted from JSON to a Python dictionary. :type metadata: Mapping[str, Any] .. py:method:: get_robot_metadata(robot_id: str) -> Mapping[str, Any] :async: Get a robot's user-defined metadata. :: metadata = await cloud.get_robot_metadata(robot_id="") :param robot_id: The ID of the robot with which the user-defined metadata is associated. You can obtain your robot ID from the machine page. :type robot_id: str :returns: The user-defined metadata converted from JSON to a Python dictionary. :rtype: Mapping[str, Any] .. py:method:: update_robot_metadata(robot_id: str, metadata: Mapping[str, Any]) -> None :async: Update a robot's user-defined metadata. :: await cloud.update_robot_metadata(robot_id="", metadata=) :param robot_id: The ID of the robot with which to associate the user-defined metadata. You can obtain your robot ID from the machine page. :type robot_id: str :param metadata: The user-defined metadata converted from JSON to a Python dictionary. :type metadata: Mapping[str, Any] .. py:method:: get_robot_part_metadata(robot_part_id: str) -> Mapping[str, Any] :async: Get a robot part's user-defined metadata. :: metadata = await cloud.get_robot_part_metadata(robot_part_id="") :param robot_part_id: The ID of the robot part with which the user-defined metadata is associated. You can obtain your robot part ID from the machine page. :type robot_part_id: str :returns: The user-defined metadata converted from JSON to a Python dictionary. :rtype: Mapping[str, Any] .. py:method:: update_robot_part_metadata(robot_part_id: str, metadata: Mapping[str, Any]) -> None :async: Update a robot part's user-defined metadata. :: await cloud.update_robot_part_metadata(robot_part_id="", metadata=) :param robot_id: The ID of the robot part with which to associate the user-defined metadata. You can obtain your robot part ID from the machine page. :type robot_id: str :param metadata: The user-defined metadata converted from JSON to a Python dictionary. :type metadata: Mapping[str, Any]