🔍 Code Extractor

class Location

Maturity: 58

Represents location information for calendar events in Microsoft Outlook/Office 365, supporting various location types including physical addresses, coordinates, and email-based locations.

File:
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/location.py
Lines:
7 - 46
Complexity:
moderate

Purpose

This class encapsulates all location-related data for calendar events in Office 365. It supports multiple location specification methods including plain text display names, physical addresses with street information, geographic coordinates, email addresses for meeting rooms, and URIs. The class is designed to work with Outlook's calendar API and can represent locations created through REST APIs, Outlook UI, Bing Autosuggest, or Bing local search. It inherits from ClientValue, making it serializable for API communication with Office 365 services.

Source Code

class Location(ClientValue):
    """
    Represents location information of an event.

    There are multiple ways to create events in a calendar, for example, through an app using the create event REST API,
    or manually using the Outlook user interface. When you create an event using the user interface, you can specify
    the location as plain text (for example, "Harry's Bar"), or from the rooms list provided by Outlook,
    Bing Autosuggest, or Bing local search.
    """

    def __init__(
        self,
        address=PhysicalAddress(),
        coordinates=None,
        display_name=None,
        location_email_address=None,
        location_type=None,
        location_uri=None,
        unique_id=None,
        unique_id_type=None,
    ):
        """
        :param PhysicalAddress address: The street address of the location.
        :param list[OutlookGeoCoordinates] coordinates:
        :param str display_name: The name associated with the location.
        :param str location_email_address: Optional email address of the location.
        :param str location_type: The type of location.
        :param str location_uri: Optional URI representing the location.
        :param str unique_id: For internal use only.
        :param str unique_id_type: For internal use only.
        """
        super(Location, self).__init__()
        self.address = address
        self.coordinates = ClientValueCollection(OutlookGeoCoordinates, coordinates)
        self.displayName = display_name
        self.locationEmailAddress = location_email_address
        self.locationType = location_type
        self.locationUri = location_uri
        self.uniqueId = unique_id
        self.uniqueIdType = unique_id_type

Parameters

Name Type Default Kind
bases ClientValue -

Parameter Details

address: A PhysicalAddress object containing the street address details of the location. Defaults to an empty PhysicalAddress() instance if not provided. Used for locations with physical street addresses.

coordinates: A list of OutlookGeoCoordinates objects representing the geographic coordinates (latitude/longitude) of the location. Can be None if coordinates are not available. Useful for mapping and location services integration.

display_name: A string containing the human-readable name of the location (e.g., 'Harry's Bar', 'Conference Room A'). This is the primary identifier shown to users. Can be None if not specified.

location_email_address: Optional string containing the email address associated with the location, typically used for meeting rooms or resources that can be booked via email. Can be None.

location_type: A string indicating the type of location (e.g., 'default', 'conferenceRoom', 'homeAddress', 'businessAddress'). Can be None if type is not specified.

location_uri: Optional string containing a URI that represents or links to the location. Can be used for custom location references or external mapping services. Can be None.

unique_id: Internal identifier for the location. Marked for internal use only. Can be None. Should generally not be set by external code.

unique_id_type: Type classifier for the unique_id field. Marked for internal use only. Can be None. Should generally not be set by external code.

Return Value

Instantiation returns a Location object that inherits from ClientValue. The object contains all location-related properties and can be serialized for use with Office 365 REST APIs. The object maintains state for address, coordinates, display name, email address, location type, URI, and internal identifiers. Methods inherited from ClientValue handle serialization/deserialization for API communication.

Class Interface

Attributes

Name Type Description Scope
address PhysicalAddress The street address of the location, stored as a PhysicalAddress object containing street, city, state, postal code, and country information instance
coordinates ClientValueCollection[OutlookGeoCoordinates] Collection of geographic coordinates (latitude/longitude pairs) representing the location's position on a map instance
displayName str The human-readable name associated with the location that is displayed to users instance
locationEmailAddress str Optional email address of the location, typically used for bookable meeting rooms or resources instance
locationType str The type classification of the location (e.g., 'default', 'conferenceRoom', 'homeAddress', 'businessAddress') instance
locationUri str Optional URI that represents or links to the location, can be used for custom references or external services instance
uniqueId str Internal identifier for the location, reserved for internal use by the Office 365 system instance
uniqueIdType str Type classifier for the uniqueId field, reserved for internal use by the Office 365 system instance

Dependencies

  • office365

Required Imports

from office365.outlook.calendar.location import Location
from office365.outlook.mail.physical_address import PhysicalAddress
from office365.outlook.geo_coordinates import OutlookGeoCoordinates

Usage Example

from office365.outlook.calendar.location import Location
from office365.outlook.mail.physical_address import PhysicalAddress
from office365.outlook.geo_coordinates import OutlookGeoCoordinates

# Simple location with just a display name
location1 = Location(display_name="Harry's Bar")

# Location with physical address
address = PhysicalAddress(
    street="123 Main St",
    city="Seattle",
    state="WA",
    postal_code="98101",
    country_or_region="USA"
)
location2 = Location(
    display_name="Office Building",
    address=address
)

# Location with coordinates
coords = [OutlookGeoCoordinates(latitude=47.6062, longitude=-122.3321)]
location3 = Location(
    display_name="Conference Room A",
    coordinates=coords,
    location_email_address="room-a@company.com",
    location_type="conferenceRoom"
)

# Access location properties
print(location3.displayName)
print(location3.locationEmailAddress)
print(location3.coordinates)

Best Practices

  • Always provide at least a display_name when creating a Location object, as this is the primary user-facing identifier
  • Use PhysicalAddress objects for the address parameter rather than creating them inline for better code organization
  • The coordinates parameter expects a list of OutlookGeoCoordinates objects, even for a single coordinate
  • Do not manually set unique_id or unique_id_type as these are marked for internal use only
  • When creating locations for meeting rooms, include the location_email_address to enable proper room booking
  • Set location_type appropriately to help Outlook categorize and display the location correctly
  • The Location object is immutable after creation in typical usage - create new instances rather than modifying existing ones
  • This class inherits from ClientValue, which handles serialization for Office 365 API calls automatically
  • Coordinates are stored in a ClientValueCollection, which provides collection-like behavior for API serialization

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class OutlookGeoCoordinates 73.0% similar

    A data class representing geographic coordinates, elevation, and their accuracy for a physical location in Microsoft Outlook/Office 365 context.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/geo_coordinates.py
  • class LocationConstraint 67.5% similar

    A class representing location constraints for meeting scheduling, specifying whether locations are required, which locations to consider, and whether to suggest locations.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/location_constraint.py
  • class LocationConstraintItem 66.8% similar

    A class representing the conditions stated by a client for the location of a meeting, inheriting from the Location base class.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/mail/location_constraint_item.py
  • class Event 65.6% similar

    Represents a calendar event in Microsoft 365, providing methods to manage event responses (accept, decline, cancel), reminders, and access to event properties like attendees, attachments, and scheduling details.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/events/event.py
  • class Place 63.5% similar

    Represents a physical location with basic attributes including name, address, and phone number. Serves as a base class for more specialized location types like rooms and room lists.

    From: /tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/outlook/calendar/place.py
← Back to Browse