-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1883 from Krishanx92/pkg
Add missing types to common-go-lib
- Loading branch information
Showing
4 changed files
with
166 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
40 changes: 40 additions & 0 deletions
40
common-go-libs/pkg/apis/dp/v1alpha1/custom_ratelimit_policy.go
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,40 @@ | ||
/* | ||
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* 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 | ||
* | ||
* http://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. | ||
* | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
// CustomRateLimitPolicyDef defines the desired state of CustomPolicy | ||
type CustomRateLimitPolicyDef struct { | ||
Key string `json:"key,omitempty"` | ||
Value string `json:"value,omitempty"` | ||
RequestsPerUnit uint32 `json:"requestsPerUnit,omitempty"` | ||
|
||
Unit string `json:"unit,omitempty"` | ||
// RateLimit RateLimit `json:"rateLimit,omitempty"` | ||
Organization string `json:"organization,omitempty"` | ||
} | ||
|
||
// ParseCustomRateLimitPolicy parses the custom rate limit policy | ||
func ParseCustomRateLimitPolicy(customRateLimitCR RateLimitPolicy) *CustomRateLimitPolicyDef { | ||
return &CustomRateLimitPolicyDef{ | ||
Key: customRateLimitCR.Spec.Override.Custom.Key, | ||
Value: customRateLimitCR.Spec.Override.Custom.Value, | ||
RequestsPerUnit: customRateLimitCR.Spec.Override.Custom.RequestsPerUnit, | ||
Unit: customRateLimitCR.Spec.Override.Custom.Unit, | ||
Organization: customRateLimitCR.Spec.Override.Custom.Organization, | ||
} | ||
} |
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,50 @@ | ||
/* | ||
Copyright 2023. | ||
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 | ||
http://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. | ||
*/ | ||
package v1alpha1 | ||
|
||
import ( | ||
gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" | ||
) | ||
|
||
// ResolveRateLimitAPIPolicy defines the desired state of Policy | ||
type ResolveRateLimitAPIPolicy struct { | ||
API ResolveRateLimit `json:"api,omitempty"` | ||
Resources []ResolveResource `json:"resourceList,omitempty"` | ||
Organization string `json:"organization,omitempty"` | ||
BasePath string `json:"basePath,omitempty"` | ||
UUID string `json:"uuid,omitempty"` | ||
Environment string `json:"environment,omitempty"` | ||
} | ||
|
||
// ResolveRateLimit is the rate limit value for the applied policy | ||
type ResolveRateLimit struct { | ||
// RequestPerUnit is the number of requests allowed per unit time | ||
// | ||
RequestsPerUnit uint32 `json:"requestsPerUnit,omitempty"` | ||
|
||
// Unit is the unit of the requestsPerUnit | ||
// | ||
// +kubebuilder:validation:Enum=Minute;Hour;Day | ||
Unit string `json:"unit,omitempty"` | ||
} | ||
|
||
// ResolveResource defines the desired state of Resource | ||
type ResolveResource struct { | ||
ResourceRatelimit ResolveRateLimit `json:"resourceRatelimit,omitempty"` | ||
Path string `json:"path,omitempty"` | ||
PathMatchType gwapiv1b1.PathMatchType `json:"pathMatchType,omitempty"` | ||
Method string `json:"method,omitempty"` | ||
} |
67 changes: 67 additions & 0 deletions
67
common-go-libs/pkg/apis/dp/v1alpha1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.