client.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. package client
  13. import (
  14. "context"
  15. "time"
  16. "github.com/yandex-cloud/go-genproto/yandex/cloud/lockbox/v1"
  17. "github.com/yandex-cloud/go-sdk/iamkey"
  18. )
  19. // Creates Lockbox clients and Yandex.Cloud IAM tokens.
  20. type YandexCloudCreator interface {
  21. CreateLockboxClient(ctx context.Context, apiEndpoint string, authorizedKey *iamkey.Key) (LockboxClient, error)
  22. CreateIamToken(ctx context.Context, apiEndpoint string, authorizedKey *iamkey.Key) (*IamToken, error)
  23. Now() time.Time
  24. }
  25. type IamToken struct {
  26. Token string
  27. ExpiresAt time.Time
  28. }
  29. // Responsible for accessing Lockbox secrets.
  30. type LockboxClient interface {
  31. GetPayloadEntries(ctx context.Context, iamToken, secretID, versionID string) ([]*lockbox.Payload_Entry, error)
  32. }