Skip to content

Commit

Permalink
feat(serverless): remove IssueJWT functions deprecated in favor of Cr…
Browse files Browse the repository at this point in the history
…eateToken (#2195)
  • Loading branch information
scaleway-bot authored Aug 29, 2024
1 parent c4af4f2 commit d62a41a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 94 deletions.
47 changes: 0 additions & 47 deletions api/container/v1beta1/container_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1377,20 +1377,6 @@ type GetTriggerRequest struct {
TriggerID string `json:"-"`
}

// IssueJWTRequest: issue jwt request.
type IssueJWTRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Region scw.Region `json:"-"`

// Precisely one of ContainerID, NamespaceID must be set.
ContainerID *string `json:"container_id,omitempty"`

// Precisely one of ContainerID, NamespaceID must be set.
NamespaceID *string `json:"namespace_id,omitempty"`

ExpiresAt *time.Time `json:"-"`
}

// ListContainersRequest: list containers request.
type ListContainersRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -2524,39 +2510,6 @@ func (s *API) DeleteDomain(req *DeleteDomainRequest, opts ...scw.RequestOption)
return &resp, nil
}

// Deprecated: IssueJWT: Deprecated in favor of CreateToken.
func (s *API) IssueJWT(req *IssueJWTRequest, opts ...scw.RequestOption) (*Token, error) {
var err error

if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}

query := url.Values{}
parameter.AddToQuery(query, "expires_at", req.ExpiresAt)
parameter.AddToQuery(query, "container_id", req.ContainerID)
parameter.AddToQuery(query, "namespace_id", req.NamespaceID)

if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}

scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/issue-jwt",
Query: query,
}

var resp Token

err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}

// CreateToken: Create a new revocable token.
func (s *API) CreateToken(req *CreateTokenRequest, opts ...scw.RequestOption) (*Token, error) {
var err error
Expand Down
47 changes: 0 additions & 47 deletions api/function/v1beta1/function_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1510,20 +1510,6 @@ type GetTriggerRequest struct {
TriggerID string `json:"-"`
}

// IssueJWTRequest: issue jwt request.
type IssueJWTRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Region scw.Region `json:"-"`

// Precisely one of FunctionID, NamespaceID must be set.
FunctionID *string `json:"function_id,omitempty"`

// Precisely one of FunctionID, NamespaceID must be set.
NamespaceID *string `json:"namespace_id,omitempty"`

ExpiresAt *time.Time `json:"-"`
}

// ListCronsRequest: list crons request.
type ListCronsRequest struct {
// Region: region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -2787,39 +2773,6 @@ func (s *API) DeleteDomain(req *DeleteDomainRequest, opts ...scw.RequestOption)
return &resp, nil
}

// Deprecated: IssueJWT: Deprecated in favor of CreateToken.
func (s *API) IssueJWT(req *IssueJWTRequest, opts ...scw.RequestOption) (*Token, error) {
var err error

if req.Region == "" {
defaultRegion, _ := s.client.GetDefaultRegion()
req.Region = defaultRegion
}

query := url.Values{}
parameter.AddToQuery(query, "expires_at", req.ExpiresAt)
parameter.AddToQuery(query, "function_id", req.FunctionID)
parameter.AddToQuery(query, "namespace_id", req.NamespaceID)

if fmt.Sprint(req.Region) == "" {
return nil, errors.New("field Region cannot be empty in request")
}

scwReq := &scw.ScalewayRequest{
Method: "GET",
Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/issue-jwt",
Query: query,
}

var resp Token

err = s.client.Do(scwReq, &resp, opts...)
if err != nil {
return nil, err
}
return &resp, nil
}

// CreateToken: Create a new revocable token.
func (s *API) CreateToken(req *CreateTokenRequest, opts ...scw.RequestOption) (*Token, error) {
var err error
Expand Down

0 comments on commit d62a41a

Please sign in to comment.