internal static Query CreateEnrollmentGroupQuery(
            ServiceConnectionString provisioningConnectionString,
            QuerySpecification querySpecification,
            HttpTransportSettings httpTransportSettings,
            CancellationToken cancellationToken,
            string enrollmentGroupId,
            int pageSize = 0)
        {
            if (querySpecification == null)
            {
                throw new ArgumentNullException(nameof(querySpecification));
            }

            if (pageSize < 0)
            {
                throw new ArgumentException($"{nameof(pageSize)} cannot be negative");
            }

            return(new Query(
                       provisioningConnectionString,
                       GetGetDeviceRegistrationStatus(enrollmentGroupId),
                       querySpecification,
                       httpTransportSettings,
                       pageSize,
                       cancellationToken));
        }
Exemple #2
0
        internal static Query CreateEnrollmentGroupQuery(
            ServiceConnectionString provisioningConnectionString,
            QuerySpecification querySpecification,
            CancellationToken cancellationToken,
            string enrollmentGroupId,
            int pageSize = 0)
        {
            /* SRS_REGISTRATION_STATUS_MANAGER_28_008: [The CreateQuery shall throw ArgumentException if the provided querySpecification is null.] */
            if (querySpecification == null)
            {
                throw new ArgumentNullException(nameof(querySpecification));
            }

            if (pageSize < 0)
            {
                throw new ArgumentException($"{nameof(pageSize)} cannot be negative");
            }

            /* SRS_REGISTRATION_STATUS_MANAGER_28_009: [The CreateQuery shall throw ArgumentException if the provided enrollmentGroupId is not valid.]] */
            ParserUtils.EnsureRegistrationId(enrollmentGroupId);

            /* SRS_REGISTRATION_STATUS_MANAGER_28_010: [The CreateQuery shall return a new Query for DeviceRegistrationState.] */
            return(new Query(
                       provisioningConnectionString,
                       GetGetDeviceRegistrationStatus(enrollmentGroupId),
                       querySpecification,
                       pageSize,
                       cancellationToken));
        }
        internal Query(
            ServiceConnectionString serviceConnectionString,
            string serviceName,
            QuerySpecification querySpecification,
            HttpTransportSettings httpTransportSettings,
            int pageSize,
            CancellationToken cancellationToken)
        {
            /* SRS_QUERY_21_001: [The constructor shall throw ArgumentNullException if the provided serviceConnectionString is null.] */
            if (serviceConnectionString == null)
            {
                throw new ArgumentNullException(nameof(serviceConnectionString));
            }

            /* SRS_QUERY_21_002: [The constructor shall throw ArgumentException if the provided serviceName is null or empty.] */
            if (string.IsNullOrWhiteSpace(serviceName ?? throw new ArgumentNullException(nameof(serviceName))))
            {
                throw new ArgumentException($"{nameof(serviceName)} cannot be an empty string");
            }

            /* SRS_QUERY_21_003: [The constructor shall throw ArgumentException if the provided querySpecification is null.] */
            if (querySpecification == null)
            {
                throw new ArgumentNullException(nameof(querySpecification));
            }

            /* SRS_QUERY_21_004: [The constructor shall throw ArgumentException if the provided pageSize is negative.] */
            if (pageSize < 0)
            {
                throw new ArgumentException($"{nameof(pageSize)} cannot be negative.");
            }

            // TODO: Refactor ContractApiHttp being created again
            /* SRS_QUERY_21_005: [The constructor shall create and store a `contractApiHttp` using the provided Service Connection String.] */
            _contractApiHttp = new ContractApiHttp(
                serviceConnectionString.HttpsEndpoint,
                serviceConnectionString, httpTransportSettings);

            /* SRS_QUERY_21_006: [The constructor shall store the provided  `pageSize`, and `cancelationToken`.] */
            PageSize           = pageSize;
            _cancellationToken = cancellationToken;

            /* SRS_QUERY_21_007: [The constructor shall create and store a JSON from the provided querySpecification.] */
            _querySpecificationJson = JsonConvert.SerializeObject(querySpecification);

            /* SRS_QUERY_21_008: [The constructor shall create and store a queryPath adding `/query` to the provided `targetPath`.] */
            _queryPath = GetQueryUri(serviceName);

            /* SRS_QUERY_21_009: [The constructor shall set continuationToken and current as null.] */
            ContinuationToken = null;

            /* SRS_QUERY_21_010: [The constructor shall set hasNext as true.] */
            _hasNext = true;
        }
Exemple #4
0
        internal Query(
            ServiceConnectionString serviceConnectionString,
            string serviceName,
            QuerySpecification querySpecification,
            HttpTransportSettings httpTransportSettings,
            int pageSize,
            CancellationToken cancellationToken)
        {
            if (serviceConnectionString == null)
            {
                throw new ArgumentNullException(nameof(serviceConnectionString));
            }

            if (string.IsNullOrWhiteSpace(serviceName ?? throw new ArgumentNullException(nameof(serviceName))))
            {
                throw new ArgumentException($"{nameof(serviceName)} cannot be an empty string");
            }

            if (querySpecification == null)
            {
                throw new ArgumentNullException(nameof(querySpecification));
            }

            if (pageSize < 0)
            {
                throw new ArgumentException($"{nameof(pageSize)} cannot be negative.");
            }

            // TODO: Refactor ContractApiHttp being created again
            _contractApiHttp = new ContractApiHttp(
                serviceConnectionString.HttpsEndpoint,
                serviceConnectionString, httpTransportSettings);

            PageSize           = pageSize;
            _cancellationToken = cancellationToken;

            _querySpecificationJson = JsonConvert.SerializeObject(querySpecification);

            _queryPath = GetQueryUri(serviceName);

            ContinuationToken = null;

            _hasNext = true;
        }
        internal static Query CreateQuery(
            ServiceConnectionString provisioningConnectionString,
            QuerySpecification querySpecification,
            HttpTransportSettings httpTransportSettings,
            CancellationToken cancellationToken,
            int pageSize = 0)
        {
            if (querySpecification == null)
            {
                throw new ArgumentNullException(nameof(querySpecification));
            }

            if (pageSize < 0)
            {
                throw new ArgumentException($"{nameof(pageSize)} cannot be negative");
            }

            return(new Query(provisioningConnectionString, ServiceName, querySpecification, httpTransportSettings, pageSize, cancellationToken));
        }
        /// <summary>
        /// Create a new individualEnrollment query.
        /// </summary>
        /// <see cref="ProvisioningServiceClient.CreateIndividualEnrollmentQuery(QuerySpecification)"/>
        /// <see cref="ProvisioningServiceClient.CreateIndividualEnrollmentQuery(QuerySpecification, int)"/>
        ///
        /// <param name="querySpecification">is a <code>string</code> with the SQL query specification. It cannot be <code>null</code>.</param>
        /// <param name="pageSize">the <code>int</code> with the maximum number of items per iteration. It can be 0 for default, but not negative.</param>
        /// <returns>A <see cref="Query"/> iterator.</returns>
        /// <exception cref="ArgumentException">if the provided parameter is not correct.</exception>
        internal static Query CreateQuery(
            ServiceConnectionString provisioningConnectionString,
            QuerySpecification querySpecification,
            CancellationToken cancellationToken,
            int pageSize = 0)
        {
            /* SRS_INDIVIDUAL_ENROLLMENT_MANAGER_21_014: [The CreateQuery shall throw ArgumentException if the provided querySpecification is null.] */
            if (querySpecification == null)
            {
                throw new ArgumentNullException(nameof(querySpecification));
            }

            if (pageSize < 0)
            {
                throw new ArgumentException($"{nameof(pageSize)} cannot be negative");
            }

            /* SRS_INDIVIDUAL_ENROLLMENT_MANAGER_21_015: [The CreateQuery shall return a new Query for IndividualEnrollments.] */
            return(new Query(provisioningConnectionString, ServiceName, querySpecification, pageSize, cancellationToken));
        }
        internal static Query CreateQuery(
            ServiceConnectionString provisioningConnectionString,
            QuerySpecification querySpecification,
            HttpTransportSettings httpTransportSettings,
            CancellationToken cancellationToken,
            int pageSize = 0)
        {
            /* SRS_ENROLLMENT_GROUP_MANAGER_28_014: [The CreateQuery shall throw ArgumentException if the provided querySpecification is null.] */
            if (querySpecification == null)
            {
                throw new ArgumentNullException(nameof(querySpecification));
            }

            if (pageSize < 0)
            {
                throw new ArgumentException($"{nameof(pageSize)} cannot be negative");
            }

            /* SRS_ENROLLMENT_GROUP_MANAGER_28_015: [The CreateQuery shall return a new Query for EnrollmentGroup.] */

            return(new Query(provisioningConnectionString, ServiceName, querySpecification, httpTransportSettings, pageSize, cancellationToken));
        }