Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support overriding some URLSigner.Options default values.
This will allow creating signers from StorageClients.
- Loading branch information
1 parent
adaa7c4
commit 4cc8131
Showing
4 changed files
with
166 additions
and
31 deletions.
There are no files selected for viewing
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
54 changes: 54 additions & 0 deletions
54
apis/Google.Cloud.Storage.V1/Google.Cloud.Storage.V1/UrlSigner.DefaultOptionsOverrides.cs
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,54 @@ | ||
// Copyright 2024 Google LLC | ||
// | ||
// 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 | ||
// | ||
// https://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. | ||
|
||
namespace Google.Cloud.Storage.V1; | ||
public sealed partial class UrlSigner | ||
{ | ||
/// <summary> | ||
/// Overrides for default values for some of the options in <see cref="Options"/>. | ||
/// Useful for creating signers where signing options default to specific values, for instance | ||
/// for creating signers from a <see cref="StorageClient"/> where the scheme, host and port should | ||
/// default to that of the client. | ||
/// </summary> | ||
internal sealed class DefaultOptionsOverrides | ||
{ | ||
internal DefaultOptionsOverrides(string scheme, string host, int? port) | ||
{ | ||
Scheme = scheme; | ||
Host = host; | ||
Port = port; | ||
} | ||
|
||
/// <summary> | ||
/// A scheme to be used by the <see cref="UrlSigner"/> signing operations if | ||
/// <see cref="Options.ExplicitScheme"/> is null. May be null in which case | ||
/// <see cref="Options.DefaultScheme"/> will be used. | ||
/// </summary> | ||
internal string Scheme { get; } | ||
|
||
/// <summary> | ||
/// A host to be used by the <see cref="UrlSigner"/> signing operations if | ||
/// <see cref="Options.ExplicitHost"/> is null. May be null in which case | ||
/// <see cref="Options.DefaultStorageHost"/> will be used. | ||
/// </summary> | ||
internal string Host { get; } | ||
|
||
/// <summary> | ||
/// A port to be used by the <see cref="UrlSigner"/> signing operations if | ||
/// <see cref="Options.ExplicitPort"/> is null. May be null in which case | ||
/// no port will be used. | ||
/// </summary> | ||
internal int? Port { get; } | ||
} | ||
} |
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
Oops, something went wrong.