public static SearchServiceCounters SearchServiceCounters(
     SearchResourceCounter documentCounter,
     SearchResourceCounter indexCounter,
     SearchResourceCounter indexerCounter,
     SearchResourceCounter dataSourceCounter,
     SearchResourceCounter storageSizeCounter,
     SearchResourceCounter synonymMapCounter) =>
 SearchServiceCounters(documentCounter, indexCounter, indexerCounter, dataSourceCounter, storageSizeCounter, synonymMapCounter, skillsetCounter: null);
 /// <summary> Initializes a new instance of SearchServiceCounters. </summary>
 /// <param name="aliasCounter"> Total number of aliases. </param>
 /// <param name="documentCounter"> Total number of documents across all indexes in the service. </param>
 /// <param name="indexCounter"> Total number of indexes. </param>
 /// <param name="indexerCounter"> Total number of indexers. </param>
 /// <param name="dataSourceCounter"> Total number of data sources. </param>
 /// <param name="storageSizeCounter"> Total size of used storage in bytes. </param>
 /// <param name="synonymMapCounter"> Total number of synonym maps. </param>
 /// <param name="skillsetCounter"> Total number of skillsets. </param>
 /// <returns> A new SearchServiceCounters instance for mocking. </returns>
 public static SearchServiceCounters SearchServiceCounters(
     SearchResourceCounter aliasCounter,
     SearchResourceCounter documentCounter,
     SearchResourceCounter indexCounter,
     SearchResourceCounter indexerCounter,
     SearchResourceCounter dataSourceCounter,
     SearchResourceCounter storageSizeCounter,
     SearchResourceCounter synonymMapCounter,
     SearchResourceCounter skillsetCounter) =>
Exemple #3
0
        internal static SearchServiceCounters DeserializeSearchServiceCounters(JsonElement element)
        {
            SearchResourceCounter documentCount    = default;
            SearchResourceCounter indexesCount     = default;
            SearchResourceCounter indexersCount    = default;
            SearchResourceCounter dataSourcesCount = default;
            SearchResourceCounter storageSize      = default;
            SearchResourceCounter synonymMaps      = default;
            SearchResourceCounter skillsetCount    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("documentCount"))
                {
                    documentCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("indexesCount"))
                {
                    indexesCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("indexersCount"))
                {
                    indexersCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("dataSourcesCount"))
                {
                    dataSourcesCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("storageSize"))
                {
                    storageSize = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("synonymMaps"))
                {
                    synonymMaps = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("skillsetCount"))
                {
                    skillsetCount = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
            }
            return(new SearchServiceCounters(documentCount, indexesCount, indexersCount, dataSourcesCount, storageSize, synonymMaps, skillsetCount));
        }
        internal static SearchServiceCounters DeserializeSearchServiceCounters(JsonElement element)
        {
            SearchServiceCounters result = new SearchServiceCounters();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("documentCount"))
                {
                    result.DocumentCounter = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("indexesCount"))
                {
                    result.IndexCounter = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("indexersCount"))
                {
                    result.IndexerCounter = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("dataSourcesCount"))
                {
                    result.DataSourceCounter = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("storageSize"))
                {
                    result.StorageSizeCounter = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("synonymMaps"))
                {
                    result.SynonymMapCounter = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
                if (property.NameEquals("skillsetCount"))
                {
                    result.SkillsetCounter = SearchResourceCounter.DeserializeSearchResourceCounter(property.Value);
                    continue;
                }
            }
            return(result);
        }
        internal SearchServiceCounters(SearchResourceCounter documentCounter, SearchResourceCounter indexCounter, SearchResourceCounter indexerCounter, SearchResourceCounter dataSourceCounter, SearchResourceCounter storageSizeCounter, SearchResourceCounter synonymMapCounter, SearchResourceCounter skillsetCounter)
        {
            if (documentCounter == null)
            {
                throw new ArgumentNullException(nameof(documentCounter));
            }
            if (indexCounter == null)
            {
                throw new ArgumentNullException(nameof(indexCounter));
            }
            if (indexerCounter == null)
            {
                throw new ArgumentNullException(nameof(indexerCounter));
            }
            if (dataSourceCounter == null)
            {
                throw new ArgumentNullException(nameof(dataSourceCounter));
            }
            if (storageSizeCounter == null)
            {
                throw new ArgumentNullException(nameof(storageSizeCounter));
            }
            if (synonymMapCounter == null)
            {
                throw new ArgumentNullException(nameof(synonymMapCounter));
            }
            if (skillsetCounter == null)
            {
                throw new ArgumentNullException(nameof(skillsetCounter));
            }

            DocumentCounter    = documentCounter;
            IndexCounter       = indexCounter;
            IndexerCounter     = indexerCounter;
            DataSourceCounter  = dataSourceCounter;
            StorageSizeCounter = storageSizeCounter;
            SynonymMapCounter  = synonymMapCounter;
            SkillsetCounter    = skillsetCounter;
        }
        internal static SearchResourceCounter DeserializeSearchResourceCounter(JsonElement element)
        {
            SearchResourceCounter result = new SearchResourceCounter();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("usage"))
                {
                    result.Usage = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("quota"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Quota = property.Value.GetInt64();
                    continue;
                }
            }
            return(result);
        }