class OrgNewsSiteApi
A SharePoint API client class for managing organizational news site operations, providing access to organizational news site details and configuration.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/orgnewssite/api.py
8 - 24
moderate
Purpose
OrgNewsSiteApi is a specialized Entity class that interfaces with SharePoint's organizational news site API. It provides methods to retrieve details about organizational news sites, which are special SharePoint sites designated for organization-wide news distribution. This class is part of the Office 365 SharePoint client library and handles communication with the Microsoft.SharePoint.OrgNewsSite.OrgNewsSiteApi service endpoint.
Source Code
class OrgNewsSiteApi(Entity):
def __init__(self, context, resource_path=None):
if resource_path is None:
resource_path = ResourcePath(
"Microsoft.SharePoint.OrgNewsSite.OrgNewsSiteApi"
)
super(OrgNewsSiteApi, self).__init__(context, resource_path)
def details(self):
return_type = ClientResult(self.context, OrgNewsSiteInfo())
qry = ServiceOperationQuery(self, "Details", None, None, None, return_type)
self.context.add_query(qry)
return return_type
@property
def entity_type_name(self):
return "Microsoft.SharePoint.OrgNewsSite.OrgNewsSiteApi"
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
Entity | - |
Parameter Details
context: The client context object that manages the connection to SharePoint and handles authentication, request queuing, and execution. This is required for all API operations and is inherited from the Entity base class.
resource_path: Optional ResourcePath object specifying the API endpoint path. If None, defaults to 'Microsoft.SharePoint.OrgNewsSite.OrgNewsSiteApi'. This parameter allows for custom resource path specification if needed for advanced scenarios.
Return Value
The constructor returns an instance of OrgNewsSiteApi. The details() method returns a ClientResult object containing an OrgNewsSiteInfo instance, which provides information about the organizational news site configuration. The ClientResult is a deferred result that will be populated when the context executes pending queries.
Class Interface
Methods
__init__(self, context, resource_path=None)
Purpose: Initializes a new instance of OrgNewsSiteApi with the provided context and optional resource path
Parameters:
context: The client context object for SharePoint communicationresource_path: Optional ResourcePath object, defaults to 'Microsoft.SharePoint.OrgNewsSite.OrgNewsSiteApi' if None
Returns: None (constructor)
details(self) -> ClientResult
Purpose: Retrieves detailed information about the organizational news site configuration
Returns: ClientResult object containing an OrgNewsSiteInfo instance with news site details. The result is populated after context.execute_query() is called.
@property entity_type_name(self) -> str
property
Purpose: Returns the fully qualified entity type name for this API endpoint
Returns: String 'Microsoft.SharePoint.OrgNewsSite.OrgNewsSiteApi' representing the entity type
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
context |
ClientContext | The client context object inherited from Entity base class, used for managing API requests and authentication | instance |
resource_path |
ResourcePath | The resource path object inherited from Entity base class, specifying the API endpoint location | instance |
Dependencies
office365
Required Imports
from office365.runtime.client_result import ClientResult
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.sharepoint.entity import Entity
from office365.sharepoint.orgnewssite.info import OrgNewsSiteInfo
Usage Example
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.orgnewssite.api import OrgNewsSiteApi
# Authenticate and create context
ctx = ClientContext(site_url).with_credentials(credentials)
# Create OrgNewsSiteApi instance
org_news_api = OrgNewsSiteApi(ctx)
# Get organizational news site details
details_result = org_news_api.details()
ctx.execute_query()
# Access the news site information
if details_result.value:
news_info = details_result.value
print(f"News site URL: {news_info.url}")
print(f"News site title: {news_info.title}")
Best Practices
- Always call ctx.execute_query() after calling details() to actually execute the deferred query and populate the result
- Reuse the same OrgNewsSiteApi instance for multiple operations within the same context to avoid unnecessary object creation
- Check if the ClientResult.value is not None before accessing properties to handle cases where the organizational news site is not configured
- Ensure the authenticated user has appropriate permissions to access organizational news site information
- The context object should be properly authenticated before instantiating this class
- Handle exceptions that may occur during query execution, such as authentication failures or network issues
- This class follows the deferred execution pattern - queries are queued and executed in batch when execute_query() is called on the context
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class OrganizationNews 83.2% similar
-
class OrgNewsSiteInfo 78.1% similar
-
class OrganizationNewsSiteReference 67.8% similar
-
class SitePageService 63.4% similar
-
class CommunicationSite 61.3% similar