From 2e6fcf5ca915f6b52fa77d827ea5ca076f0b84f0 Mon Sep 17 00:00:00 2001 From: Ilja <47740286+iljaSL@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:32:17 +0200 Subject: [PATCH] feat(1.37.0): add new auhtorizer and secrets manager endpoints and models (#167) Co-authored-by: rsemkin <112624398+rsemkin@users.noreply.github.com> --- api/authorizer/client.go | 20 ++++++++++++++++++++ api/authorizer/model.go | 8 ++++++++ api/secretsmanager/client.go | 11 +++++++++++ api/secretsmanager/model.go | 10 ++++++++++ 4 files changed, 49 insertions(+) diff --git a/api/authorizer/client.go b/api/authorizer/client.go index 25e3f7e..531d642 100644 --- a/api/authorizer/client.go +++ b/api/authorizer/client.go @@ -72,6 +72,26 @@ func (c *Authorizer) DownloadCACertificate(caID, filename string) error { return err } +// CAConfig get authorizers root certificate config by ca type. +func (c *Authorizer) CAConfig(caType string) (ComponentCaConfig, error) { + caConf := ComponentCaConfig{} + + _, err := c.api. + URL("/authorizer/api/v1/%s/cas/config", caType). + Get(&caConf) + + return caConf, err +} + +// UpdateCAConfig update authorizers root certificate config by ca type. +func (c *Authorizer) UpdateCAConfig(caType string, caConf ComponentCaConfig) error { + _, err := c.api. + URL("/authorizer/api/v1/%s/cas/config", caType). + Put(&caConf) + + return err +} + // DownloadCertificateRevocationList fetch authorizer CA certificate revocation list as a download object. func (c *Authorizer) DownloadCertificateRevocationList(caID, filename string) error { err := c.api. diff --git a/api/authorizer/model.go b/api/authorizer/model.go index 05ac292..ab9da35 100644 --- a/api/authorizer/model.go +++ b/api/authorizer/model.go @@ -293,3 +293,11 @@ type Secrets struct { Secret string `json:"secret"` Created time.Time `json:"created"` } + +type ComponentCaConfig struct { + Name string `json:"name"` + CAID string `json:"ca_id"` + PrimaryCAID string `json:"primary_ca_id"` + Updated time.Time `json:"updated"` + UpdatedBy string `json:"updated_by,omitempty"` +} diff --git a/api/secretsmanager/client.go b/api/secretsmanager/client.go index fd142f3..1c6b03f 100644 --- a/api/secretsmanager/client.go +++ b/api/secretsmanager/client.go @@ -271,6 +271,17 @@ func (c *SecretsManager) RefreshTargetDomain(tdID string) error { return err } +// ResolveTargetDomains resolve target domain names to target domain IDs. +func (s *SecretsManager) ResolveTargetDomains(tdNames []string) (TargetDomainsResolveResponse, error) { + resolve := TargetDomainsResolveResponse{} + + _, err := s.api. + URL("/secrets-manager/api/v1/targetdomains/resolve"). + Post(tdNames, &resolve) + + return resolve, err +} + // MARK: Target domain accounts // GetTargetDomainAccounts get accounts in target domain. func (c *SecretsManager) GetTargetDomainAccounts(tdID string, opts ...filters.Option) (*response.ResultSet[ScannedAccount], error) { diff --git a/api/secretsmanager/model.go b/api/secretsmanager/model.go index ee25851..bf91b1f 100644 --- a/api/secretsmanager/model.go +++ b/api/secretsmanager/model.go @@ -323,3 +323,13 @@ type ManagedAccountDeleteBatch struct { type ManagedAccountRotateBatch struct { IDs []string `json:"ids"` } + +type TargetDomainsResolveResponse struct { + Count int `json:"count"` + Items []TargetDomainsResolve `json:"items"` +} + +type TargetDomainsResolve struct { + ID string `json:"id"` + TargetDomainName string `json:"target_domain_name"` +}