|
| 1 | +from office365.directory.tenantinformation.information import TenantInformation |
| 2 | +from office365.directory.tenantinformation.multi_organization import ( |
| 3 | + MultiTenantOrganization, |
| 4 | +) |
| 5 | +from office365.entity import Entity |
| 6 | +from office365.runtime.client_result import ClientResult |
| 7 | +from office365.runtime.paths.resource_path import ResourcePath |
| 8 | +from office365.runtime.queries.function import FunctionQuery |
| 9 | + |
| 10 | + |
| 11 | +class TenantRelationship(Entity): |
| 12 | + """Represent the various type of tenant relationships.""" |
| 13 | + |
| 14 | + def find_tenant_information_by_domain_name(self, domain_name): |
| 15 | + """Given a domain name, search for a tenant and read its tenantInformation. You can use this API to |
| 16 | + validate tenant information and use their tenantId to configure cross-tenant access settings between you |
| 17 | + and the tenant. |
| 18 | +
|
| 19 | + :param str domain_name: Primary domain name of an Azure AD tenant. |
| 20 | + """ |
| 21 | + return_type = ClientResult(self.context, TenantInformation()) |
| 22 | + params = {"domainName": domain_name} |
| 23 | + qry = FunctionQuery( |
| 24 | + self, "findTenantInformationByDomainName", params, return_type |
| 25 | + ) |
| 26 | + self.context.add_query(qry) |
| 27 | + return return_type |
| 28 | + |
| 29 | + def find_tenant_information_by_tenant_id(self, tenant_id): |
| 30 | + """Given a tenant ID, search for a tenant and read its tenantInformation. You can use this API to validate |
| 31 | + tenant information and use the tenantId to configure cross-tenant cross-tenant access settings between you |
| 32 | + and the tenant. |
| 33 | +
|
| 34 | + :param str tenant_id: Unique tenant identifier of a Microsoft Entra tenant. |
| 35 | + """ |
| 36 | + return_type = ClientResult(self.context, TenantInformation()) |
| 37 | + params = {"tenantId": tenant_id} |
| 38 | + qry = FunctionQuery( |
| 39 | + self, "findTenantInformationByTenantId", params, return_type |
| 40 | + ) |
| 41 | + self.context.add_query(qry) |
| 42 | + return return_type |
| 43 | + |
| 44 | + @property |
| 45 | + def multi_tenant_organization(self): |
| 46 | + """Represents a setting to control people-related admin settings in the tenant.""" |
| 47 | + return self.properties.get( |
| 48 | + "multiTenantOrganization", |
| 49 | + MultiTenantOrganization( |
| 50 | + self.context, |
| 51 | + ResourcePath("multiTenantOrganization", self.resource_path), |
| 52 | + ), |
| 53 | + ) |
| 54 | + |
| 55 | + def get_property(self, name, default_value=None): |
| 56 | + if default_value is None: |
| 57 | + property_mapping = { |
| 58 | + "multiTenantOrganization": self.multi_tenant_organization, |
| 59 | + } |
| 60 | + default_value = property_mapping.get(name, None) |
| 61 | + return super(TenantRelationship, self).get_property(name, default_value) |
0 commit comments