Beispiel #1
0
        protected override async Task <bool> PerformActionAsync()
        {
            var layerVersionArn = this.GetStringValueOrDefault(this.LayerVersionArn,
                                                               LambdaDefinedCommandOptions.ARGUMENT_LAYER_VERSION_ARN, true);

            var result = LambdaUtilities.ParseLayerVersionArn(layerVersionArn);

            var getRequest = new GetLayerVersionRequest
            {
                LayerName     = result.Name,
                VersionNumber = result.VersionNumber
            };


            try
            {
                var response = await this.LambdaClient.GetLayerVersionAsync(getRequest);


                this.Logger.WriteLine("Layer ARN:".PadRight(PAD_SIZE) + response.LayerArn);
                this.Logger.WriteLine("Version Number:".PadRight(PAD_SIZE) + response.Version);
                this.Logger.WriteLine("Created:".PadRight(PAD_SIZE) + DateTime.Parse(response.CreatedDate).ToString("g"));
                this.Logger.WriteLine("License Info:".PadRight(PAD_SIZE) + response.LicenseInfo);
                this.Logger.WriteLine("Compatible Runtimes:".PadRight(PAD_SIZE) + string.Join(", ", response.CompatibleRuntimes.ToArray()));

                LayerDescriptionManifest manifest;
                if (!LambdaUtilities.AttemptToParseLayerDescriptionManifest(response.Description, out manifest))
                {
                    this.Logger.WriteLine("Description:".PadRight(PAD_SIZE) + response.Description);
                }
                else
                {
                    switch (manifest.Nlt)
                    {
                    case LayerDescriptionManifest.ManifestType.RuntimePackageStore:
                        this.Logger.WriteLine("Layer Type:".PadRight(PAD_SIZE) + LambdaConstants.LAYER_TYPE_RUNTIME_PACKAGE_STORE_DISPLAY_NAME);
                        await GetRuntimePackageManifest(manifest);

                        break;

                    default:
                        this.Logger.WriteLine("Layer Type:".PadRight(PAD_SIZE) + manifest.Nlt);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                throw new LambdaToolsException("Error getting layer version details: " + e.Message, LambdaToolsException.LambdaErrorCode.LambdaGetLayerVersionDetails, e);
            }

            return(true);
        }
        /// <summary>
        /// 获取层版本详细信息,包括用于下载层中文件的链接。
        /// </summary>
        /// <param name="req"><see cref="GetLayerVersionRequest"/></param>
        /// <returns><see cref="GetLayerVersionResponse"/></returns>
        public GetLayerVersionResponse GetLayerVersionSync(GetLayerVersionRequest req)
        {
            JsonResponseModel <GetLayerVersionResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "GetLayerVersion");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <GetLayerVersionResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }