from office365.directory.identities.providers.base import IdentityProviderBase
from office365.entity_collection import EntityCollection
from office365.runtime.client_result import ClientResult
from office365.runtime.queries.service_operation import ServiceOperationQuery
from office365.runtime.types.collections import StringCollection


class IdentityProviderBaseCollection(EntityCollection):

    def __init__(self, context, resource_path=None):
        super(IdentityProviderBaseCollection, self).__init__(context, IdentityProviderBase, resource_path)

    def available_provider_types(self):
        """
        Get all identity providers supported in a directory.

        The identityProvider API is deprecated and will stop returning data on March 2023.
        Please use the new identityProviderBase API.
        """
        return_type = ClientResult(self.context, StringCollection())
        qry = ServiceOperationQuery(self, "availableProviderTypes", None, None, None, return_type)
        self.context.add_query(qry)
        return return_type


