package resolver // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. // Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" "fmt" "edge-infra.dev/pkg/edge/api/apierror" "edge-infra.dev/pkg/edge/api/graph/model" channelMappers "edge-infra.dev/pkg/edge/api/services/channels" "github.com/google/uuid" ) // DeleteChannel is the resolver for the deleteChannel field. func (r *mutationResolver) DeleteChannel(ctx context.Context, channelID uuid.UUID) (bool, error) { _, err := r.ChannelService.DeleteChannel(ctx, channelID, false) return err == nil, err } // RotateChannelNow is the resolver for the rotateChannelNow field. func (r *mutationResolver) RotateChannelNow(ctx context.Context, channelID uuid.UUID, bannerEdgeID uuid.UUID) (*model.Channel, error) { _, err := r.ChannelService.RotateChannelNow(ctx, bannerEdgeID, channelID) if err != nil { errorMsg := fmt.Sprintf(apierror.ChannelRotateErrorMsg, channelID) return nil, apierror.New(apierror.ChannelRotateError). AddGenericErrorExtension(errorMsg, err) } newRotatedChannel, err := r.ChannelService.GetChannel(ctx, channelID) if err != nil { errorMsg := fmt.Sprintf(apierror.GetChannelAPIErrorMsg, channelID) return nil, apierror.New(apierror.GetChannelsAPIError). AddGenericErrorExtension(errorMsg, err) } newChannel := channelMappers.ConvertChannelTypeToModelChannel(newRotatedChannel) return newChannel, nil } // CreateChannel is the resolver for the createChannel field. func (r *mutationResolver) CreateChannel(ctx context.Context, payload model.ChannelInput) (*model.Channel, error) { createChannel := channelMappers.MapChannelInput(payload) channel, err := r.ChannelService.CreateChannel(ctx, createChannel) if err != nil { errorMsg := fmt.Sprintf(apierror.CreateChannelAPIErrorMsg, payload.Name) return nil, apierror.New(apierror.CreateChannelIAMPolicyError). AddGenericErrorExtension(errorMsg, err) } createdChannel := channelMappers.ConvertChannelTypeToModelChannel(channel) return createdChannel, nil } // CreateChannelIam is the resolver for the createChannelIAM field. func (r *mutationResolver) CreateChannelIam(ctx context.Context, channelID uuid.UUID, saEmail string) (*model.ChannelIAMPolicy, error) { channelIAMPolicy, err := r.ChannelService.CreateChannelIAM(ctx, channelID, saEmail) if err != nil { errorMsg := fmt.Sprintf(apierror.CreateChannelIAMPolicyErrorMessage, saEmail) return nil, apierror.New(apierror.CreateChannelIAMPolicyError). AddGenericErrorExtension(errorMsg, err) } return channelIAMPolicy, nil } // Channels is the resolver for the channels field. func (r *queryResolver) Channels(ctx context.Context) ([]*model.Channel, error) { channels, err := r.ChannelService.GetChannels(ctx) if err != nil { return nil, apierror.New(apierror.GetChannelsAPIError). AddGenericErrorExtension(apierror.GetChannelsAPIErrorMsg, err) } channelModels := channelMappers.MapToChannelModels(channels) return channelModels, nil }