🔍 Code Extractor

class TenantAppInstance

Maturity: 35

Represents an instance of a tenant-scoped app for a given host web in SharePoint, inheriting from the Entity base class.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/apps/instance.py
Lines:
4 - 5
Complexity:
simple

Purpose

This class models a tenant app instance in SharePoint Online, which represents an app that has been deployed at the tenant level and instantiated for a specific host web. It provides an object-oriented interface for interacting with tenant-scoped app instances through the SharePoint REST API, allowing developers to manage and query app instances that are available across a SharePoint tenant.

Source Code

class TenantAppInstance(Entity):
    """Represents an instance of a tenant-scoped app for a given host web."""

Parameters

Name Type Default Kind
bases Entity -

Parameter Details

context: The client context object that provides the connection to the SharePoint site and handles authentication and request execution

resource_path: Optional parameter specifying the server-relative path to the tenant app instance resource in SharePoint

properties: Optional dictionary of initial property values to set on the entity instance

Return Value

Instantiation returns a TenantAppInstance object that represents a tenant-scoped app instance. The object inherits all methods and properties from the Entity base class, providing access to SharePoint entity operations like get(), update(), and delete(). Method return values depend on the inherited Entity class methods.

Class Interface

Methods

__init__(context, resource_path=None, properties=None)

Purpose: Initializes a new TenantAppInstance entity object

Parameters:

  • context: The ClientContext object for SharePoint communication
  • resource_path: Optional server-relative path to the resource
  • properties: Optional dictionary of initial property values

Returns: A new TenantAppInstance object

Attributes

Name Type Description Scope
context ClientContext The client context used for communication with SharePoint instance
resource_path ResourcePath The server-relative path to this entity in SharePoint instance
properties dict Dictionary containing the entity's properties loaded from SharePoint instance

Dependencies

  • office365-runtime
  • office365-sharepoint

Required Imports

from office365.sharepoint.tenant.administration.tenant_app_instance import TenantAppInstance

Usage Example

from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.tenant.administration.tenant_app_instance import TenantAppInstance

# Authenticate to SharePoint
site_url = 'https://contoso.sharepoint.com/sites/site1'
credentials = UserCredential('user@contoso.com', 'password')
ctx = ClientContext(site_url).with_credentials(credentials)

# Get a tenant app instance
app_instance = ctx.web.tenant_app_catalog.get_by_id('app-instance-id')
ctx.load(app_instance)
ctx.execute_query()

# Access properties
print(f'App Instance ID: {app_instance.id}')
print(f'App Instance Title: {app_instance.title}')

Best Practices

  • Always authenticate with appropriate tenant or site collection administrator permissions before accessing tenant app instances
  • Use the ClientContext.load() method followed by execute_query() to retrieve entity properties from SharePoint
  • Handle exceptions when accessing app instances as they may not exist or permissions may be insufficient
  • Dispose of the ClientContext properly after operations are complete to release resources
  • Use the inherited Entity methods (get(), update(), delete()) for CRUD operations on the app instance
  • Check if the app instance exists before attempting to access its properties to avoid null reference errors

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class TenantAppUtility 74.0% similar

    TenantAppUtility is a placeholder class that extends Entity from the Office365 SharePoint library, representing a tenant application utility in SharePoint.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/apps/utility.py
  • class TenantAppInformation 67.5% similar

    A data class that represents information about a tenant-scoped application in Office 365, including its principal ID, web URL, and creation timestamp.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/apps/information.py
  • class Tenant 67.4% similar

    Represents a SharePoint tenant.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/tenant/administration/tenant.py
  • class HostedApp 67.0% similar

    A SharePoint entity class representing a hosted application component in the SharePoint client-side component framework.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/clientsidecomponent/hostedapps/app.py
  • class TeamsApp 66.4% similar

    Represents an app in the Microsoft Teams app catalog, providing access to app definitions and metadata for Teams applications.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/teams/apps/app.py
← Back to Browse