Skip to content

Commit

Permalink
adding AIProvider and APIPolicy,Subscription,Ratelimit new CRD v3 ver…
Browse files Browse the repository at this point in the history
…sions
  • Loading branch information
CrowleyRajapakse committed Sep 6, 2024
1 parent f037985 commit 77916c1
Show file tree
Hide file tree
Showing 26 changed files with 2,278 additions and 0 deletions.
16 changes: 16 additions & 0 deletions common-go-libs/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,20 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
domain: wso2.com
group: dp
kind: AIProvider
path: github.com/wso2/apk/common-go-libs/apis/dp/v1alpha3
version: v1alpha3
- api:
crdVersion: v1
namespaced: true
domain: wso2.com
group: cp
kind: Subscription
path: github.com/wso2/apk/common-go-libs/apis/cp/v1alpha3
version: v1alpha3
version: "3"
37 changes: 37 additions & 0 deletions common-go-libs/apis/cp/v1alpha3/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 v1alpha3 contains API Schema definitions for the cp v1alpha3 API group
// +kubebuilder:object:generate=true
// +groupName=cp.wso2.com
package v1alpha3

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "cp.wso2.com", Version: "v1alpha3"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
77 changes: 77 additions & 0 deletions common-go-libs/apis/cp/v1alpha3/subscription_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2024, 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 v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// SubscriptionSpec defines the desired state of Subscription
type SubscriptionSpec struct {
SubscriptionStatus string `json:"subscriptionStatus"`
Organization string `json:"organization"`
API API `json:"api"`
RatelimitRef RatelimitRef `json:"ratelimitRef"`
}

// API defines the API associated with the subscription
type API struct {
Name string `json:"name"`
Version string `json:"version"`
}

// RatelimitRef defines the ratelimit associated with the subscription
type RatelimitRef struct {
Name string `json:"name"`
Level string `json:"level"`
}

// SubscriptionStatus defines the observed state of Subscription
type SubscriptionStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:storageversion

// Subscription is the Schema for the subscriptions API
type Subscription struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec SubscriptionSpec `json:"spec,omitempty"`
Status SubscriptionStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// SubscriptionList contains a list of Subscription
type SubscriptionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Subscription `json:"items"`
}

func init() {
SchemeBuilder.Register(&Subscription{}, &SubscriptionList{})
}
148 changes: 148 additions & 0 deletions common-go-libs/apis/cp/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 81 additions & 0 deletions common-go-libs/apis/dp/v1alpha3/aiprovider_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2024, 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 v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// AIProviderSpec defines the desired state of AIProvider
type AIProviderSpec struct {
// Important: Run "make" to regenerate code after modifying this file

// +kubebuilder:validation:MinLength=1
ProviderName string `json:"providerName"`
ProviderAPIVersion string `json:"providerAPIVersion"`
Organization string `json:"organization"`
Model ValueDetails `json:"model"`
RateLimitFields RateLimitFields `json:"rateLimitFields"`
}

// RateLimitFields defines the Rate Limit fields
type RateLimitFields struct {
PromptTokens ValueDetails `json:"promptTokens"`
CompletionToken ValueDetails `json:"completionToken"`
TotalToken ValueDetails `json:"totalToken"`
}

// ValueDetails defines the value details
type ValueDetails struct {
In string `json:"in"`
Value string `json:"value"`
}

// AIProviderStatus defines the observed state of AIProvider
type AIProviderStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// AIProvider is the Schema for the aiproviders API
type AIProvider struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AIProviderSpec `json:"spec,omitempty"`
Status AIProviderStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// AIProviderList contains a list of AIProvider
type AIProviderList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AIProvider `json:"items"`
}

func init() {
SchemeBuilder.Register(&AIProvider{}, &AIProviderList{})
}
Loading

0 comments on commit 77916c1

Please sign in to comment.