Esempio n. 1
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)
        {
            ListLayersResponse response = new ListLayersResponse();

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

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Layers", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <LayersListItem, LayersListItemUnmarshaller>(LayersListItemUnmarshaller.Instance);
                    response.Layers = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("NextMarker", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextMarker = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonLambdaConfig config = new AmazonLambdaConfig();

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

            ListLayersResponse resp = new ListLayersResponse();

            do
            {
                ListLayersRequest req = new ListLayersRequest
                {
                    Marker = resp.NextMarker
                    ,
                    MaxItems = maxItems
                };

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

                foreach (var obj in resp.Layers)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextMarker));
        }
Esempio n. 3
0
        protected override async Task <bool> PerformActionAsync()
        {
            this.Logger.WriteLine("Name".PadRight(LAYER_NAME_WIDTH) + " " +
                                  "Description".PadRight(LAYER_DESCRIPTION_WIDTH) + " " +
                                  "Compatible Runtimes".PadRight(LAYER_COMPATIBLE_RUNTIMES_WIDTH) + " " +
                                  "Created".PadRight(TIMESTAMP_WIDTH) + " " +
                                  "Latest Version ARN".PadRight(LAYER_ARN_WIDTH)
                                  );
            this.Logger.WriteLine($"{new string('-', LAYER_NAME_WIDTH)} {new string('-', LAYER_DESCRIPTION_WIDTH)} {new string('-', LAYER_COMPATIBLE_RUNTIMES_WIDTH)} {new string('-', TIMESTAMP_WIDTH)} {new string('-', LAYER_ARN_WIDTH)}");

            var request = new ListLayersRequest();
            ListLayersResponse response = null;

            do
            {
                if (response != null)
                {
                    request.Marker = response.NextMarker;
                }

                try
                {
                    response = await this.LambdaClient.ListLayersAsync(request);
                }
                catch (Exception e)
                {
                    throw new LambdaToolsException("Error listing Lambda layers: " + e.Message, LambdaToolsException.LambdaErrorCode.LambdaListLayers, e);
                }

                foreach (var layer in response.Layers)
                {
                    var latestVersion = layer.LatestMatchingVersion;
                    this.Logger.WriteLine(layer.LayerName.PadRight(LAYER_NAME_WIDTH) + " " +
                                          LambdaUtilities.DetermineListDisplayLayerDescription(latestVersion.Description, LAYER_DESCRIPTION_WIDTH).PadRight(LAYER_DESCRIPTION_WIDTH) + " " +
                                          string.Join(", ", latestVersion.CompatibleRuntimes.ToArray()).PadRight(LAYER_COMPATIBLE_RUNTIMES_WIDTH) + " " +
                                          DateTime.Parse(latestVersion.CreatedDate).ToString("g").PadRight(TIMESTAMP_WIDTH) + " " +
                                          latestVersion.LayerVersionArn
                                          );
                }
            } while (!string.IsNullOrEmpty(response.NextMarker));

            return(true);
        }