/// <summary>
        /// Initializes a new instance of the <see cref="ManagementApiClient"/> class.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="baseUri">The base URI.</param>
        /// <param name="diagnostics">The diagnostics.</param>
        /// <param name="handler">The <see cref="HttpMessageHandler"/> which is used for HTTP requests</param>
        public ManagementApiClient(string token, Uri baseUri, DiagnosticsHeader diagnostics, HttpMessageHandler handler)
        {
            // If no diagnostics header structure was specified, then revert to the default one
            if (diagnostics == null)
            {
                diagnostics = DiagnosticsHeader.Default;
            }

            apiConnection = new ApiConnection(token, baseUri.AbsoluteUri, diagnostics, handler);

            BlacklistedTokens = new BlacklistedTokensClient(apiConnection);
            ClientGrants      = new ClientGrantsClient(apiConnection);
            Clients           = new ClientsClient(apiConnection);
            Connections       = new ConnectionsClient(apiConnection);
            DeviceCredentials = new DeviceCredentialsClient(apiConnection);
            EmailProvider     = new EmailProviderClient(apiConnection);
            Jobs            = new JobsClient(apiConnection);
            Logs            = new LogsClient(apiConnection);
            ResourceServers = new ResourceServersClient(apiConnection);
            Rules           = new RulesClient(apiConnection);
            Stats           = new StatsClient(apiConnection);
            TenantSettings  = new TentantSettingsClient(apiConnection);
            Tickets         = new TicketsClient(apiConnection);
            UserBlocks      = new UserBlocksClient(apiConnection);
            Users           = new UsersClient(apiConnection);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ManagementApiClient"/> class.
        /// </summary>
        /// <param name="token">A valid Auth0 Management API v2 token.</param>
        /// <param name="baseUri"><see cref="Uri"/> of the tenant to manage.</param>
        /// <param name="managementConnection"><see cref="IManagementConnection"/> to facilitate communication with server.</param>
        public ManagementApiClient(string token, Uri baseUri, IManagementConnection managementConnection = null)
        {
            if (managementConnection == null)
            {
                var ownedManagementConnection = new HttpClientManagementConnection();
                managementConnection = ownedManagementConnection;
                connectionToDispose  = ownedManagementConnection;
            }

            var defaultHeaders = CreateDefaultHeaders(token);

            BlacklistedTokens = new BlacklistedTokensClient(managementConnection, baseUri, defaultHeaders);
            ClientGrants      = new ClientGrantsClient(managementConnection, baseUri, defaultHeaders);
            Clients           = new ClientsClient(managementConnection, baseUri, defaultHeaders);
            Connections       = new ConnectionsClient(managementConnection, baseUri, defaultHeaders);
            CustomDomains     = new CustomDomainsClient(managementConnection, baseUri, defaultHeaders);
            DeviceCredentials = new DeviceCredentialsClient(managementConnection, baseUri, defaultHeaders);
            EmailProvider     = new EmailProviderClient(managementConnection, baseUri, defaultHeaders);
            EmailTemplates    = new EmailTemplatesClient(managementConnection, baseUri, defaultHeaders);
            Guardian          = new GuardianClient(managementConnection, baseUri, defaultHeaders);
            Jobs            = new JobsClient(managementConnection, baseUri, defaultHeaders);
            Logs            = new LogsClient(managementConnection, baseUri, defaultHeaders);
            ResourceServers = new ResourceServersClient(managementConnection, baseUri, defaultHeaders);
            Roles           = new RolesClient(managementConnection, baseUri, defaultHeaders);
            Rules           = new RulesClient(managementConnection, baseUri, defaultHeaders);
            Stats           = new StatsClient(managementConnection, baseUri, defaultHeaders);
            TenantSettings  = new TenantSettingsClient(managementConnection, baseUri, defaultHeaders);
            Tickets         = new TicketsClient(managementConnection, baseUri, defaultHeaders);
            UserBlocks      = new UserBlocksClient(managementConnection, baseUri, defaultHeaders);
            Users           = new UsersClient(managementConnection, baseUri, defaultHeaders);
        }
Esempio n. 3
0
        private ManagementApiClient(string token, Uri baseUri, DiagnosticsHeader diagnostics,
                                    ApiConnection apiConnection)
        {
            _apiConnection = apiConnection;

            BlacklistedTokens = new BlacklistedTokensClient(_apiConnection);
            ClientGrants      = new ClientGrantsClient(_apiConnection);
            Clients           = new ClientsClient(_apiConnection);
            Connections       = new ConnectionsClient(_apiConnection);
            DeviceCredentials = new DeviceCredentialsClient(_apiConnection);
            EmailProvider     = new EmailProviderClient(_apiConnection);
            EmailTemplates    = new EmailTemplatesClient(_apiConnection);
            Jobs            = new JobsClient(_apiConnection);
            Logs            = new LogsClient(_apiConnection);
            ResourceServers = new ResourceServersClient(_apiConnection);
            Rules           = new RulesClient(_apiConnection);
            Stats           = new StatsClient(_apiConnection);
            TenantSettings  = new TenantSettingsClient(_apiConnection);
            Tickets         = new TicketsClient(_apiConnection);
            UserBlocks      = new UserBlocksClient(_apiConnection);
            Users           = new UsersClient(_apiConnection);
        }
Esempio n. 4
0
        private ManagementApiClient(ApiConnection apiConnection)
        {
            _apiConnection = apiConnection;

            BlacklistedTokens = new BlacklistedTokensClient(_apiConnection);
            ClientGrants      = new ClientGrantsClient(_apiConnection);
            Clients           = new ClientsClient(_apiConnection);
            Connections       = new ConnectionsClient(_apiConnection);
            CustomDomains     = new CustomDomainsClient(_apiConnection);
            DeviceCredentials = new DeviceCredentialsClient(_apiConnection);
            EmailProvider     = new EmailProviderClient(_apiConnection);
            EmailTemplates    = new EmailTemplatesClient(_apiConnection);
            Guardian          = new GuardianClient(_apiConnection);
            Jobs            = new JobsClient(_apiConnection);
            Logs            = new LogsClient(_apiConnection);
            ResourceServers = new ResourceServersClient(_apiConnection);
            Roles           = new RolesClient(_apiConnection);
            Rules           = new RulesClient(_apiConnection);
            Stats           = new StatsClient(_apiConnection);
            TenantSettings  = new TenantSettingsClient(_apiConnection);
            Tickets         = new TicketsClient(_apiConnection);
            UserBlocks      = new UserBlocksClient(_apiConnection);
            Users           = new UsersClient(_apiConnection);
        }