public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonSageMakerConfig config = new AmazonSageMakerConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonSageMakerClient client = new AmazonSageMakerClient(creds, config);

            ListEndpointsResponse resp = new ListEndpointsResponse();

            do
            {
                ListEndpointsRequest req = new ListEndpointsRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.ListEndpoints(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.Endpoints)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
Beispiel #2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListEndpointsResponse response = new ListEndpointsResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("EndpointPropertiesList", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <EndpointProperties, EndpointPropertiesUnmarshaller>(EndpointPropertiesUnmarshaller.Instance);
                    response.EndpointPropertiesList = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Beispiel #3
0
        /// <summary>
        /// Run the example.
        /// </summary>
        /// <param name="parsedArgs">Parsed arguments for the example.</param>
        protected override void Run(Dictionary <string, object> parsedArgs)
        {
            string accountId = (string)parsedArgs["account_id"];
            string parent    = $"bidders/{accountId}";
            string pageToken = null;

            Console.WriteLine(@"Listing endpoints for bidder account ""{0}""", accountId);
            do
            {
                BiddersResource.EndpointsResource.ListRequest request = rtbService.Bidders.Endpoints.List(parent);
                request.PageSize  = (int)parsedArgs["page_size"];
                request.PageToken = pageToken;

                ListEndpointsResponse page = null;

                try
                {
                    page = request.Execute();
                }
                catch (System.Exception exception)
                {
                    throw new ApplicationException(
                              $"Real-time Bidding API returned error response:\n{exception.Message}");
                }

                var endpoints = page.Endpoints;
                pageToken = page.NextPageToken;

                if (endpoints == null)
                {
                    Console.WriteLine("No endpoints found.");
                }
                else
                {
                    foreach (Endpoint endpoint in endpoints)
                    {
                        Utilities.PrintEndpoint(endpoint);
                    }
                }
            }while(pageToken != null);
        }