-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
960efd8
commit d0db3ff
Showing
5 changed files
with
157 additions
and
0 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
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
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,23 @@ | ||
package keys | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
) | ||
|
||
type DeleteCMKImportOpts struct { | ||
KeyId string `json:"key_id" required:"true"` | ||
Sequence string `json:"sequence,omitempty"` | ||
} | ||
|
||
func DeleteCMKImport(client *golangsdk.ServiceClient, opts DeleteCMKImportOpts) error { | ||
b, err := build.RequestBody(opts, "") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = client.Post(client.ServiceURL("kms", "delete-imported-key-material"), b, nil, &golangsdk.RequestOpts{ | ||
OkCodes: []int{200}, | ||
}) | ||
return err | ||
} |
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,39 @@ | ||
package keys | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/extract" | ||
) | ||
|
||
type GetCMKImportOpts struct { | ||
KeyId string `json:"key_id" required:"true"` | ||
WrappingAlgorithm string `json:"wrapping_algorithm" required:"true"` | ||
Sequence string `json:"sequence,omitempty"` | ||
} | ||
|
||
func GetCMKImport(client *golangsdk.ServiceClient, opts GetCMKImportOpts) (*CMKImport, error) { | ||
b, err := build.RequestBody(opts, "") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
raw, err := client.Post(client.ServiceURL("kms", "get-parameters-for-import"), &b, nil, &golangsdk.RequestOpts{ | ||
OkCodes: []int{200}, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var res CMKImport | ||
|
||
err = extract.Into(raw.Body, &res) | ||
return &res, err | ||
} | ||
|
||
type CMKImport struct { | ||
KeyId string `json:"key_id"` | ||
ImportToken string `json:"import_token"` | ||
ExpirationTime int `json:"expiration_time"` | ||
PublicKey string `json:"public_key"` | ||
} |
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,27 @@ | ||
package keys | ||
|
||
import ( | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
"github.com/opentelekomcloud/gophertelekomcloud/internal/build" | ||
) | ||
|
||
type ImportCMKOpts struct { | ||
KeyId string `json:"key_id" required:"true"` | ||
ImportToken string `json:"import_token" required:"true"` | ||
EncryptedKeyMaterial string `json:"encrypted_key_material" required:"true"` | ||
ExpirationTime string `json:"expiration_time,omitempty"` | ||
Sequence string `json:"sequence,omitempty"` | ||
} | ||
|
||
func ImportCMKMaterial(client *golangsdk.ServiceClient, opts ImportCMKOpts) error { | ||
b, err := build.RequestBody(opts, "") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = client.Post(client.ServiceURL("kms", "import-key-material"), b, nil, &golangsdk.RequestOpts{ | ||
OkCodes: []int{200}, | ||
}) | ||
|
||
return err | ||
} |