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)); }
/// <summary> /// 返回全部层的列表,其中包含了每个层最新版本的信息,可以通过适配运行时进行过滤。 /// </summary> /// <param name="req"><see cref="ListLayersRequest"/></param> /// <returns><see cref="ListLayersResponse"/></returns> public ListLayersResponse ListLayersSync(ListLayersRequest req) { JsonResponseModel <ListLayersResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "ListLayers"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <ListLayersResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
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); }