-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow full control of configuring cdn values of backend bucket resources
- Loading branch information
1 parent
c383bee
commit 2f3ecfc
Showing
4 changed files
with
421 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/main/java/gyro/google/compute/BackendBucketCdnBypassCacheOnRequestHeader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2023, Brightspot. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package gyro.google.compute; | ||
|
||
import com.google.cloud.compute.v1.BackendBucketCdnPolicyBypassCacheOnRequestHeader; | ||
import gyro.core.resource.Diffable; | ||
import gyro.core.validation.Required; | ||
import gyro.google.Copyable; | ||
|
||
public class BackendBucketCdnBypassCacheOnRequestHeader extends Diffable implements Copyable<BackendBucketCdnPolicyBypassCacheOnRequestHeader> { | ||
|
||
private String headerName; | ||
|
||
/** | ||
* The header name to match on when bypassing cache. | ||
*/ | ||
@Required | ||
public String getHeaderName() { | ||
return headerName; | ||
} | ||
|
||
public void setHeaderName(String headerName) { | ||
this.headerName = headerName; | ||
} | ||
|
||
@Override | ||
public void copyFrom(BackendBucketCdnPolicyBypassCacheOnRequestHeader model) { | ||
setHeaderName(model.getHeaderName()); | ||
} | ||
|
||
@Override | ||
public String primaryKey() { | ||
return headerName != null ? getHeaderName() : ""; | ||
} | ||
|
||
BackendBucketCdnPolicyBypassCacheOnRequestHeader toBackendBucketCdnPolicyBypassCacheOnRequestHeader() { | ||
return BackendBucketCdnPolicyBypassCacheOnRequestHeader.newBuilder() | ||
.setHeaderName(getHeaderName()) | ||
.build(); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/main/java/gyro/google/compute/BackendBucketCdnCacheKeyPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright 2023, Brightspot. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package gyro.google.compute; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.google.cloud.compute.v1.BackendBucketCdnPolicyCacheKeyPolicy; | ||
import gyro.core.resource.Diffable; | ||
import gyro.core.resource.Updatable; | ||
import gyro.google.Copyable; | ||
|
||
public class BackendBucketCdnCacheKeyPolicy extends Diffable implements Copyable<BackendBucketCdnPolicyCacheKeyPolicy> { | ||
|
||
private List<String> includeHttpHeaders; | ||
private List<String> queryStringWhitelist; | ||
|
||
/** | ||
* Headers to include in cache keys according to include_http_headers. | ||
*/ | ||
@Updatable | ||
public List<String> getIncludeHttpHeaders() { | ||
if (includeHttpHeaders == null) { | ||
includeHttpHeaders = new ArrayList<>(); | ||
} | ||
|
||
return includeHttpHeaders; | ||
} | ||
|
||
public void setIncludeHttpHeaders(List<String> includeHttpHeaders) { | ||
this.includeHttpHeaders = includeHttpHeaders; | ||
} | ||
|
||
/** | ||
* Names of query string parameters to include in cache keys. | ||
*/ | ||
@Updatable | ||
public List<String> getQueryStringWhitelist() { | ||
if (queryStringWhitelist == null) { | ||
queryStringWhitelist = new ArrayList<>(); | ||
} | ||
|
||
return queryStringWhitelist; | ||
} | ||
|
||
public void setQueryStringWhitelist(List<String> queryStringWhitelist) { | ||
this.queryStringWhitelist = queryStringWhitelist; | ||
} | ||
|
||
@Override | ||
public void copyFrom(BackendBucketCdnPolicyCacheKeyPolicy model) { | ||
setIncludeHttpHeaders(model.getIncludeHttpHeadersList()); | ||
setQueryStringWhitelist(model.getQueryStringWhitelistList()); | ||
} | ||
|
||
BackendBucketCdnPolicyCacheKeyPolicy toBackendBucketCdnPolicyCacheKeyPolicy() { | ||
BackendBucketCdnPolicyCacheKeyPolicy.Builder builder = BackendBucketCdnPolicyCacheKeyPolicy.newBuilder(); | ||
builder.addAllIncludeHttpHeaders(getIncludeHttpHeaders()); | ||
builder.addAllQueryStringWhitelist(getQueryStringWhitelist()); | ||
return builder.build(); | ||
} | ||
|
||
@Override | ||
public String primaryKey() { | ||
return ""; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/gyro/google/compute/BackendBucketCdnNegativeCachingPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2023, Brightspot. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package gyro.google.compute; | ||
|
||
import com.google.cloud.compute.v1.BackendBucketCdnPolicyNegativeCachingPolicy; | ||
import gyro.core.resource.Diffable; | ||
import gyro.core.validation.Required; | ||
import gyro.google.Copyable; | ||
|
||
public class BackendBucketCdnNegativeCachingPolicy extends Diffable implements Copyable<BackendBucketCdnPolicyNegativeCachingPolicy> { | ||
|
||
private Integer code; | ||
private Integer ttl; | ||
|
||
/** | ||
* The HTTP status code to define custom set of rules. | ||
*/ | ||
@Required | ||
public Integer getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(Integer code) { | ||
this.code = code; | ||
} | ||
|
||
/** | ||
* The TTL for the negative response. | ||
*/ | ||
@Required | ||
public Integer getTtl() { | ||
return ttl; | ||
} | ||
|
||
public void setTtl(Integer ttl) { | ||
this.ttl = ttl; | ||
} | ||
|
||
@Override | ||
public void copyFrom(BackendBucketCdnPolicyNegativeCachingPolicy model) { | ||
setCode(model.getCode()); | ||
setTtl(model.getTtl()); | ||
} | ||
|
||
@Override | ||
public String primaryKey() { | ||
return String.format("Code: %s, TTL: %s", getCode() != null ? getCode() : 0, getTtl() != null ? getTtl() : 0); | ||
} | ||
|
||
BackendBucketCdnPolicyNegativeCachingPolicy toBackendBucketCdnPolicyNegativeCachingPolicy() { | ||
return BackendBucketCdnPolicyNegativeCachingPolicy.newBuilder() | ||
.setCode(getCode()) | ||
.setTtl(getTtl()) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.