Skip to content

Commit

Permalink
feat(client-cloudfront): CloudFront now supports the Server-Timing he…
Browse files Browse the repository at this point in the history
…ader in HTTP responses sent from CloudFront. You can use this header to view metrics that help you gain insights about the behavior and performance of CloudFront. To use this header, enable it in a response headers policy.
  • Loading branch information
awstools committed Apr 26, 2022
1 parent 85a8b9d commit c70378d
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import {
} from "@aws-sdk/types";

import { CloudFrontClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../CloudFrontClient";
import { DeleteMonitoringSubscriptionRequest } from "../models/models_0";
import { DeleteMonitoringSubscriptionResult } from "../models/models_1";
import { DeleteMonitoringSubscriptionRequest, DeleteMonitoringSubscriptionResult } from "../models/models_1";
import {
deserializeAws_restXmlDeleteMonitoringSubscriptionCommand,
serializeAws_restXmlDeleteMonitoringSubscriptionCommand,
Expand Down
63 changes: 47 additions & 16 deletions clients/client-cloudfront/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7855,6 +7855,47 @@ export namespace ResponseHeadersPolicySecurityHeadersConfig {
});
}

/**
* <p>A configuration for enabling the <code>Server-Timing</code> header in HTTP responses sent
* from CloudFront. CloudFront adds this header to HTTP responses that it sends in response to requests
* that match a cache behavior that's associated with this response headers policy.</p>
* <p>You can use the <code>Server-Timing</code> header to view metrics that can help you gain
* insights about the behavior and performance of CloudFront. For example, you can see which
* cache layer served a cache hit, or the first byte latency from the origin when there was
* a cache miss. You can use the metrics in the <code>Server-Timing</code> header to
* troubleshoot issues or test the efficiency of your CloudFront configuration. For more
* information, see <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/understanding-response-headers-policies.html#server-timing-header">Server-Timing header</a> in the
* <i>Amazon CloudFront Developer Guide</i>.</p>
*/
export interface ResponseHeadersPolicyServerTimingHeadersConfig {
/**
* <p>A Boolean that determines whether CloudFront adds the <code>Server-Timing</code> header to HTTP
* responses that it sends in response to requests that match a cache behavior that's
* associated with this response headers policy.</p>
*/
Enabled: boolean | undefined;

/**
* <p>A number 0–100 (inclusive) that specifies the percentage of responses that you want CloudFront to
* add the <code>Server-Timing</code> header to. When you set the sampling rate to 100,
* CloudFront adds the <code>Server-Timing</code> header to the HTTP response for every request
* that matches the cache behavior that this response headers policy is attached to. When
* you set it to 50, CloudFront adds the header to 50% of the responses for requests that match
* the cache behavior. You can set the sampling rate to any number 0–100 with up to four
* decimal places.</p>
*/
SamplingRate?: number;
}

export namespace ResponseHeadersPolicyServerTimingHeadersConfig {
/**
* @internal
*/
export const filterSensitiveLog = (obj: ResponseHeadersPolicyServerTimingHeadersConfig): any => ({
...obj,
});
}

/**
* <p>A response headers policy configuration.</p>
* <p>A response headers policy configuration contains metadata about the response headers policy,
Expand Down Expand Up @@ -7890,6 +7931,12 @@ export interface ResponseHeadersPolicyConfig {
* <p>A configuration for a set of custom HTTP response headers.</p>
*/
CustomHeadersConfig?: ResponseHeadersPolicyCustomHeadersConfig;

/**
* <p>A configuration for enabling the <code>Server-Timing</code> header in HTTP responses
* sent from CloudFront.</p>
*/
ServerTimingHeadersConfig?: ResponseHeadersPolicyServerTimingHeadersConfig;
}

export namespace ResponseHeadersPolicyConfig {
Expand Down Expand Up @@ -8909,19 +8956,3 @@ export class ResourceInUse extends __BaseException {
this.Message = opts.Message;
}
}

export interface DeleteMonitoringSubscriptionRequest {
/**
* <p>The ID of the distribution that you are disabling metrics for.</p>
*/
DistributionId: string | undefined;
}

export namespace DeleteMonitoringSubscriptionRequest {
/**
* @internal
*/
export const filterSensitiveLog = (obj: DeleteMonitoringSubscriptionRequest): any => ({
...obj,
});
}
16 changes: 16 additions & 0 deletions clients/client-cloudfront/src/models/models_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ import {
ViewerCertificate,
} from "./models_0";

export interface DeleteMonitoringSubscriptionRequest {
/**
* <p>The ID of the distribution that you are disabling metrics for.</p>
*/
DistributionId: string | undefined;
}

export namespace DeleteMonitoringSubscriptionRequest {
/**
* @internal
*/
export const filterSensitiveLog = (obj: DeleteMonitoringSubscriptionRequest): any => ({
...obj,
});
}

export interface DeleteMonitoringSubscriptionResult {}

export namespace DeleteMonitoringSubscriptionResult {
Expand Down
51 changes: 51 additions & 0 deletions clients/client-cloudfront/src/protocols/Aws_restXml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getValueFromTextNode as __getValueFromTextNode,
parseBoolean as __parseBoolean,
parseRfc3339DateTime as __parseRfc3339DateTime,
strictParseFloat as __strictParseFloat,
strictParseInt32 as __strictParseInt32,
strictParseLong as __strictParseLong,
} from "@aws-sdk/smithy-client";
Expand Down Expand Up @@ -450,6 +451,7 @@ import {
ResponseHeadersPolicyFrameOptions,
ResponseHeadersPolicyReferrerPolicy,
ResponseHeadersPolicySecurityHeadersConfig,
ResponseHeadersPolicyServerTimingHeadersConfig,
ResponseHeadersPolicyStrictTransportSecurity,
ResponseHeadersPolicyXSSProtection,
Restrictions,
Expand Down Expand Up @@ -13041,6 +13043,13 @@ const serializeAws_restXmlResponseHeadersPolicyConfig = (
).withName("CustomHeadersConfig");
bodyNode.addChildNode(node);
}
if (input.ServerTimingHeadersConfig !== undefined && input.ServerTimingHeadersConfig !== null) {
const node = serializeAws_restXmlResponseHeadersPolicyServerTimingHeadersConfig(
input.ServerTimingHeadersConfig,
context
).withName("ServerTimingHeadersConfig");
bodyNode.addChildNode(node);
}
return bodyNode;
};

Expand Down Expand Up @@ -13266,6 +13275,24 @@ const serializeAws_restXmlResponseHeadersPolicySecurityHeadersConfig = (
return bodyNode;
};

const serializeAws_restXmlResponseHeadersPolicyServerTimingHeadersConfig = (
input: ResponseHeadersPolicyServerTimingHeadersConfig,
context: __SerdeContext
): any => {
const bodyNode = new __XmlNode("ResponseHeadersPolicyServerTimingHeadersConfig");
if (input.Enabled !== undefined && input.Enabled !== null) {
const node = new __XmlNode("boolean").addChildNode(new __XmlText(String(input.Enabled))).withName("Enabled");
bodyNode.addChildNode(node);
}
if (input.SamplingRate !== undefined && input.SamplingRate !== null) {
const node = new __XmlNode("SamplingRate")
.addChildNode(new __XmlText(String(input.SamplingRate)))
.withName("SamplingRate");
bodyNode.addChildNode(node);
}
return bodyNode;
};

const serializeAws_restXmlResponseHeadersPolicyStrictTransportSecurity = (
input: ResponseHeadersPolicyStrictTransportSecurity,
context: __SerdeContext
Expand Down Expand Up @@ -16753,6 +16780,7 @@ const deserializeAws_restXmlResponseHeadersPolicyConfig = (
CorsConfig: undefined,
SecurityHeadersConfig: undefined,
CustomHeadersConfig: undefined,
ServerTimingHeadersConfig: undefined,
};
if (output["Comment"] !== undefined) {
contents.Comment = __expectString(output["Comment"]);
Expand All @@ -16775,6 +16803,12 @@ const deserializeAws_restXmlResponseHeadersPolicyConfig = (
context
);
}
if (output["ServerTimingHeadersConfig"] !== undefined) {
contents.ServerTimingHeadersConfig = deserializeAws_restXmlResponseHeadersPolicyServerTimingHeadersConfig(
output["ServerTimingHeadersConfig"],
context
);
}
return contents;
};

Expand Down Expand Up @@ -17025,6 +17059,23 @@ const deserializeAws_restXmlResponseHeadersPolicySecurityHeadersConfig = (
return contents;
};

const deserializeAws_restXmlResponseHeadersPolicyServerTimingHeadersConfig = (
output: any,
context: __SerdeContext
): ResponseHeadersPolicyServerTimingHeadersConfig => {
const contents: any = {
Enabled: undefined,
SamplingRate: undefined,
};
if (output["Enabled"] !== undefined) {
contents.Enabled = __parseBoolean(output["Enabled"]);
}
if (output["SamplingRate"] !== undefined) {
contents.SamplingRate = __strictParseFloat(output["SamplingRate"]) as number;
}
return contents;
};

const deserializeAws_restXmlResponseHeadersPolicyStrictTransportSecurity = (
output: any,
context: __SerdeContext
Expand Down
Loading

0 comments on commit c70378d

Please sign in to comment.