Beispiel #1
0
 protected override void ProcessRecord()
 {
     base.ProcessRecord();
     try
     {
         client?.Dispose();
         int timeout = GetPreferredTimeout();
         WriteDebug($"Cmdlet Timeout : {timeout} milliseconds.");
         client = new ResourceSearchClient(AuthProvider, new Oci.Common.ClientConfiguration
         {
             RetryConfiguration = retryConfig,
             TimeoutMillis      = timeout,
             ClientUserAgent    = PSUserAgent
         });
         string region = GetPreferredRegion();
         if (region != null)
         {
             WriteDebug("Choosing Region:" + region);
             client.SetRegion(region);
         }
         if (Endpoint != null)
         {
             WriteDebug("Choosing Endpoint:" + Endpoint);
             client.SetEndpoint(Endpoint);
         }
     }
     catch (Exception ex)
     {
         TerminatingErrorDuringExecution(ex);
     }
 }
Beispiel #2
0
        private static async Task ListTypes(ResourceSearchClient client)
        {
            var listResourceTypesRequest  = new ListResourceTypesRequest {
            };
            var listResourceTypesResponse = await client.ListResourceTypes(listResourceTypesRequest);

            foreach (var type in listResourceTypesResponse.Items)
            {
                logger.Info($"Resource: {type.Name}");
            }
        }
Beispiel #3
0
        private static async Task GetTypeDetails(ResourceSearchClient client, string typeName)
        {
            var getResourceTypeRequest = new GetResourceTypeRequest
            {
                Name = typeName
            };
            var getResourceTypeResponse = await client.GetResourceType(getResourceTypeRequest);

            foreach (var field in getResourceTypeResponse.ResourceType.Fields)
            {
                logger.Info($"FieldName: {field.FieldName}");
            }
        }
        public static async Task MainPolymorphicObject()
        {
            logger.Info("Starting example");

            var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");

            var client = new ResourceSearchClient(provider);

            logger.Info("Search for resource by freetext search");
            await FreeTextSearch(client, "admin");

            logger.Info("Search for resource by structed query search");
            await StructuredQuerySearch(client, "query all resources");

            logger.Info("End example");
        }
Beispiel #5
0
        private static async Task StructuredQuerySearch(ResourceSearchClient client, string query)
        {
            var searchResourcesRequest = new SearchResourcesRequest
            {
                SearchDetails = new StructuredSearchDetails
                {
                    MatchingContextType = SearchDetails.MatchingContextTypeEnum.Highlights,
                    Query = query
                }
            };
            var searchResourcesResponse = await client.SearchResources(searchResourcesRequest);

            foreach (var resource in searchResourcesResponse.ResourceSummaryCollection.Items)
            {
                logger.Info($"Resource: {resource.DisplayName}");
            }
        }
Beispiel #6
0
        private static async Task FreeTextSearch(ResourceSearchClient client, string text)
        {
            var searchResourcesRequest = new SearchResourcesRequest
            {
                SearchDetails = new FreeTextSearchDetails
                {
                    Text = text,
                    MatchingContextType = SearchDetails.MatchingContextTypeEnum.Highlights
                }
            };
            var searchResourcesResponse = await client.SearchResources(searchResourcesRequest);

            foreach (var resource in searchResourcesResponse.ResourceSummaryCollection.Items)
            {
                logger.Info($"Resource: {resource.DisplayName}");
            }
        }
Beispiel #7
0
        public static async Task MainResourcesearch()
        {
            logger.Info("Starting example");

            var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT");

            var client = new ResourceSearchClient(provider);

            logger.Info("List all resource types");
            await ListTypes(client);

            logger.Info("Get Group type details");
            await GetTypeDetails(client, "Group");

            logger.Info("Search for resource by freetext search");
            await FreeTextSearch(client, "admin");

            logger.Info("Search for resource by structed query search");
            await StructuredQuerySearch(client, "query all resources");

            logger.Info("End example");
        }