From 7ed56011ae04693ab42be06a9586cd6696a01d04 Mon Sep 17 00:00:00 2001 From: Sean Chok Date: Wed, 2 Aug 2023 03:02:39 +0800 Subject: [PATCH] add get method in cloud profile service client (#7) * add get method in service/cloud-profile client * add cloudProfileId scalar in ProjectFragment graphql * regenerate api client methods --- api/generated/client.go | 52 +++++++++++++++++++++++++++++++-- api/generated/models_gen.go | 19 +++++++++++- service/cloud_profile/get.go | 18 ++++++++++++ service/cloud_profile/query.gql | 6 ++++ service/project/query.gql | 1 + 5 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 service/cloud_profile/get.go diff --git a/api/generated/client.go b/api/generated/client.go index dd34457..2283bfd 100644 --- a/api/generated/client.go +++ b/api/generated/client.go @@ -11,6 +11,7 @@ import ( ) type GQLClient interface { + GetCloudProfile(ctx context.Context, where CloudProfileWhereUniqueInput, interceptors ...clientv2.RequestInterceptor) (*GetCloudProfile, error) GetCloudProfiles(ctx context.Context, whereAccount AccountWhereUniqueInput, whereCloudProfile *CloudProfileWhereInput, interceptors ...clientv2.RequestInterceptor) (*GetCloudProfiles, error) CreateCloudProfile(ctx context.Context, whereAccount AccountWhereUniqueInput, data CreateCloudProfileInput, interceptors ...clientv2.RequestInterceptor) (*CreateCloudProfile, error) GetProjects(ctx context.Context, whereAccount AccountWhereUniqueInput, whereProject *ProjectWhereInput, interceptors ...clientv2.RequestInterceptor) (*GetProjects, error) @@ -181,9 +182,10 @@ func (t *CloudProfileFragment) GetProvider() *CloudProvider { } type ProjectFragment struct { - ID string "json:\"id\" graphql:\"id\"" - Name string "json:\"name\" graphql:\"name\"" - CreatedAt time.Time "json:\"createdAt\" graphql:\"createdAt\"" + ID string "json:\"id\" graphql:\"id\"" + Name string "json:\"name\" graphql:\"name\"" + CreatedAt time.Time "json:\"createdAt\" graphql:\"createdAt\"" + CloudProfileID *string "json:\"cloudProfileId,omitempty\" graphql:\"cloudProfileId\"" } func (t *ProjectFragment) GetID() string { @@ -204,6 +206,12 @@ func (t *ProjectFragment) GetCreatedAt() *time.Time { } return &t.CreatedAt } +func (t *ProjectFragment) GetCloudProfileID() *string { + if t == nil { + t = &ProjectFragment{} + } + return t.CloudProfileID +} type AccountFragment struct { ID string "json:\"id\" graphql:\"id\"" @@ -266,6 +274,17 @@ func (t *GetAccounts_Me) GetTeams() []*GetAccounts_Me_Teams { return t.Teams } +type GetCloudProfile struct { + CloudProfile *CloudProfileFragment "json:\"cloudProfile,omitempty\" graphql:\"cloudProfile\"" +} + +func (t *GetCloudProfile) GetCloudProfile() *CloudProfileFragment { + if t == nil { + t = &GetCloudProfile{} + } + return t.CloudProfile +} + type GetCloudProfiles struct { CloudProfiles []*CloudProfileFragment "json:\"cloudProfiles\" graphql:\"cloudProfiles\"" } @@ -321,6 +340,31 @@ func (t *GetAccounts) GetMe() *GetAccounts_Me { return &t.Me } +const GetCloudProfileDocument = `query GetCloudProfile ($where: CloudProfileWhereUniqueInput!) { + cloudProfile(where: $where) { + ... CloudProfileFragment + } +} +fragment CloudProfileFragment on CloudProfile { + id + name + provider +} +` + +func (c *Client) GetCloudProfile(ctx context.Context, where CloudProfileWhereUniqueInput, interceptors ...clientv2.RequestInterceptor) (*GetCloudProfile, error) { + vars := map[string]interface{}{ + "where": where, + } + + var res GetCloudProfile + if err := c.Client.Post(ctx, "GetCloudProfile", GetCloudProfileDocument, &res, vars, interceptors...); err != nil { + return nil, err + } + + return &res, nil +} + const GetCloudProfilesDocument = `query GetCloudProfiles ($whereAccount: AccountWhereUniqueInput!, $whereCloudProfile: CloudProfileWhereInput) { cloudProfiles(whereAccount: $whereAccount, whereCloudProfile: $whereCloudProfile) { ... CloudProfileFragment @@ -382,6 +426,7 @@ fragment ProjectFragment on Project { id name createdAt + cloudProfileId } ` @@ -408,6 +453,7 @@ fragment ProjectFragment on Project { id name createdAt + cloudProfileId } ` diff --git a/api/generated/models_gen.go b/api/generated/models_gen.go index b9cd039..0e3da7d 100644 --- a/api/generated/models_gen.go +++ b/api/generated/models_gen.go @@ -380,6 +380,7 @@ type Application struct { CloudProfileID *string `json:"cloudProfileId"` CloudProviderAppConfigID *string `json:"cloudProviderAppConfigId"` ProjectID *string `json:"projectId"` + ContainerRegistryID *string `json:"containerRegistryId"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` Count *ApplicationCount `json:"_count"` @@ -388,6 +389,7 @@ type Application struct { CloudProviderAppConfig *CloudProviderAppConfig `json:"cloudProviderAppConfig"` Project *Project `json:"project"` VpcAttachment *VPCAttachment `json:"vpcAttachment"` + ContainerRegistry *ContainerRegistry `json:"containerRegistry"` AttachedContainer *ApplicationContainer `json:"attachedContainer"` Containers []*ApplicationContainer `json:"containers"` EnvironmentVariables []*EnvironmentVariable `json:"environmentVariables"` @@ -488,6 +490,7 @@ type ApplicationOrderByWithRelationInput struct { CloudProfileID *SortOrder `json:"cloudProfileId,omitempty"` CloudProviderAppConfigID *SortOrder `json:"cloudProviderAppConfigId,omitempty"` ProjectID *SortOrder `json:"projectId,omitempty"` + ContainerRegistryID *SortOrder `json:"containerRegistryId,omitempty"` CreatedAt *SortOrder `json:"createdAt,omitempty"` UpdatedAt *SortOrder `json:"updatedAt,omitempty"` Account *AccountOrderByWithRelationInput `json:"account,omitempty"` @@ -495,6 +498,7 @@ type ApplicationOrderByWithRelationInput struct { CloudProviderAppConfig *CloudProviderAppConfigOrderByWithRelationInput `json:"cloudProviderAppConfig,omitempty"` Project *ProjectOrderByWithRelationInput `json:"project,omitempty"` VpcAttachment *VPCAttachmentOrderByWithRelationInput `json:"vpcAttachment,omitempty"` + ContainerRegistry *ContainerRegistryOrderByWithRelationInput `json:"containerRegistry,omitempty"` AttachedContainer *ApplicationContainerOrderByWithRelationInput `json:"attachedContainer,omitempty"` Containers *ApplicationContainerOrderByRelationAggregateInput `json:"containers,omitempty"` EnvironmentVariables *EnvironmentVariableOrderByRelationAggregateInput `json:"environmentVariables,omitempty"` @@ -518,6 +522,7 @@ type ApplicationWhereInput struct { CloudProfileID *StringNullableFilter `json:"cloudProfileId,omitempty"` CloudProviderAppConfigID *StringNullableFilter `json:"cloudProviderAppConfigId,omitempty"` ProjectID *StringNullableFilter `json:"projectId,omitempty"` + ContainerRegistryID *StringNullableFilter `json:"containerRegistryId,omitempty"` CreatedAt *DateTimeFilter `json:"createdAt,omitempty"` UpdatedAt *DateTimeFilter `json:"updatedAt,omitempty"` Account *AccountRelationFilter `json:"account,omitempty"` @@ -525,6 +530,7 @@ type ApplicationWhereInput struct { CloudProviderAppConfig *CloudProviderAppConfigRelationFilter `json:"cloudProviderAppConfig,omitempty"` Project *ProjectRelationFilter `json:"project,omitempty"` VpcAttachment *VPCAttachmentRelationFilter `json:"vpcAttachment,omitempty"` + ContainerRegistry *ContainerRegistryRelationFilter `json:"containerRegistry,omitempty"` AttachedContainer *ApplicationContainerRelationFilter `json:"attachedContainer,omitempty"` Containers *ApplicationContainerListRelationFilter `json:"containers,omitempty"` EnvironmentVariables *EnvironmentVariableListRelationFilter `json:"environmentVariables,omitempty"` @@ -1347,13 +1353,19 @@ type ContainerRegistry struct { CloudProviderContainerRegistryConfigID *string `json:"cloudProviderContainerRegistryConfigId"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` + Count *ContainerRegistryCount `json:"_count"` Account Account `json:"account"` CloudProfile *CloudProfile `json:"cloudProfile"` Project *Project `json:"project"` + Applications []*Application `json:"applications"` CloudProviderContainerRegistryConfig *CloudProviderContainerRegistryConfig `json:"cloudProviderContainerRegistryConfig"` Info ContainerRegistryInfo `json:"info"` } +type ContainerRegistryCount struct { + Applications int64 `json:"applications"` +} + type ContainerRegistryInfo struct { ImageURI string `json:"imageUri"` LoginServer string `json:"loginServer"` @@ -1384,6 +1396,7 @@ type ContainerRegistryOrderByWithRelationInput struct { Account *AccountOrderByWithRelationInput `json:"account,omitempty"` CloudProfile *CloudProfileOrderByWithRelationInput `json:"cloudProfile,omitempty"` Project *ProjectOrderByWithRelationInput `json:"project,omitempty"` + Applications *ApplicationOrderByRelationAggregateInput `json:"applications,omitempty"` CloudProviderContainerRegistryConfig *CloudProviderContainerRegistryConfigOrderByWithRelationInput `json:"cloudProviderContainerRegistryConfig,omitempty"` } @@ -1408,6 +1421,7 @@ type ContainerRegistryWhereInput struct { Account *AccountRelationFilter `json:"account,omitempty"` CloudProfile *CloudProfileRelationFilter `json:"cloudProfile,omitempty"` Project *ProjectRelationFilter `json:"project,omitempty"` + Applications *ApplicationListRelationFilter `json:"applications,omitempty"` CloudProviderContainerRegistryConfig *CloudProviderContainerRegistryConfigRelationFilter `json:"cloudProviderContainerRegistryConfig,omitempty"` } @@ -1457,6 +1471,7 @@ type CreateApplicationInput struct { Name string `json:"name"` CloudProfileID string `json:"cloudProfileId"` CloudProviderAppConfig CreateCloudProviderAppConfig `json:"cloudProviderAppConfig"` + ContainerRegistryID *string `json:"containerRegistryId,omitempty"` Container CreateApplicationContainerInput `json:"container"` EnvironmentVariables []*EnvironmentVariableInput `json:"environmentVariables,omitempty"` } @@ -4344,6 +4359,7 @@ const ( ApplicationScalarFieldEnumCloudProfileID ApplicationScalarFieldEnum = "cloudProfileId" ApplicationScalarFieldEnumCloudProviderAppConfigID ApplicationScalarFieldEnum = "cloudProviderAppConfigId" ApplicationScalarFieldEnumProjectID ApplicationScalarFieldEnum = "projectId" + ApplicationScalarFieldEnumContainerRegistryID ApplicationScalarFieldEnum = "containerRegistryId" ApplicationScalarFieldEnumCreatedAt ApplicationScalarFieldEnum = "createdAt" ApplicationScalarFieldEnumUpdatedAt ApplicationScalarFieldEnum = "updatedAt" ) @@ -4356,13 +4372,14 @@ var AllApplicationScalarFieldEnum = []ApplicationScalarFieldEnum{ ApplicationScalarFieldEnumCloudProfileID, ApplicationScalarFieldEnumCloudProviderAppConfigID, ApplicationScalarFieldEnumProjectID, + ApplicationScalarFieldEnumContainerRegistryID, ApplicationScalarFieldEnumCreatedAt, ApplicationScalarFieldEnumUpdatedAt, } func (e ApplicationScalarFieldEnum) IsValid() bool { switch e { - case ApplicationScalarFieldEnumID, ApplicationScalarFieldEnumName, ApplicationScalarFieldEnumStatus, ApplicationScalarFieldEnumAccountID, ApplicationScalarFieldEnumCloudProfileID, ApplicationScalarFieldEnumCloudProviderAppConfigID, ApplicationScalarFieldEnumProjectID, ApplicationScalarFieldEnumCreatedAt, ApplicationScalarFieldEnumUpdatedAt: + case ApplicationScalarFieldEnumID, ApplicationScalarFieldEnumName, ApplicationScalarFieldEnumStatus, ApplicationScalarFieldEnumAccountID, ApplicationScalarFieldEnumCloudProfileID, ApplicationScalarFieldEnumCloudProviderAppConfigID, ApplicationScalarFieldEnumProjectID, ApplicationScalarFieldEnumContainerRegistryID, ApplicationScalarFieldEnumCreatedAt, ApplicationScalarFieldEnumUpdatedAt: return true } return false diff --git a/service/cloud_profile/get.go b/service/cloud_profile/get.go new file mode 100644 index 0000000..6f47d93 --- /dev/null +++ b/service/cloud_profile/get.go @@ -0,0 +1,18 @@ +package cloud_profile + +import ( + "context" + "github.com/deploifai/sdk-go/api/generated" +) + +// Get returns a cloud profile. +func (c *Client) Get(ctx context.Context, where generated.CloudProfileWhereUniqueInput) (cp generated.CloudProfileFragment, err error) { + + data, err := c.options.API.GetGQLClient().GetCloudProfile(ctx, where) + if err != nil { + return cp, c.options.API.ProcessGQLError(err) + } + + return *data.GetCloudProfile(), nil + +} diff --git a/service/cloud_profile/query.gql b/service/cloud_profile/query.gql index 44940e4..39cc005 100644 --- a/service/cloud_profile/query.gql +++ b/service/cloud_profile/query.gql @@ -4,6 +4,12 @@ fragment CloudProfileFragment on CloudProfile { provider } +query GetCloudProfile($where: CloudProfileWhereUniqueInput!) { + cloudProfile(where: $where) { + ...CloudProfileFragment + } +} + query GetCloudProfiles($whereAccount: AccountWhereUniqueInput! $whereCloudProfile: CloudProfileWhereInput) { cloudProfiles( whereAccount: $whereAccount diff --git a/service/project/query.gql b/service/project/query.gql index 38be066..9dae739 100644 --- a/service/project/query.gql +++ b/service/project/query.gql @@ -2,6 +2,7 @@ fragment ProjectFragment on Project { id name createdAt + cloudProfileId }