コード例 #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)
        {
            ListLayerVersionsResponse response = new ListLayerVersionsResponse();

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

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

            return(response);
        }
コード例 #2
0
        protected override async Task <bool> PerformActionAsync()
        {
            var layerName = this.GetStringValueOrDefault(this.LayerName, LambdaDefinedCommandOptions.ARGUMENT_LAYER_NAME, true);

            this.Logger.WriteLine("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_DESCRIPTION_WIDTH)} {new string('-', LAYER_COMPATIBLE_RUNTIMES_WIDTH)} {new string('-', TIMESTAMP_WIDTH)} {new string('-', LAYER_ARN_WIDTH)}");

            var request = new ListLayerVersionsRequest {
                LayerName = layerName
            };
            ListLayerVersionsResponse response = null;

            do
            {
                request.Marker = response?.NextMarker;

                try
                {
                    response = await this.LambdaClient.ListLayerVersionsAsync(request);
                }
                catch (Exception e)
                {
                    throw new LambdaToolsException("Error listing versions for Lambda layer: " + e.Message, LambdaToolsException.LambdaErrorCode.LambdaListLayerVersions, e);
                }

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

            return(true);
        }