utils

package
v0.0.0-...-a4b769c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

* 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. *

* 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. *

Index

Constants

View Source
const (
	// APIImportRelativePath is the relative path of API import in publisher rest API
	APIImportRelativePath = "api/am/publisher/v4/apis/import?preserveProvider=false&overwrite=true&rotateRevision=true&preservePortalConfigurations=true"
	// TokenRelativePath is the relative path for getting token in publisher rest API
	TokenRelativePath = "oauth2/token"
	// APIDeleteRelativePath is the relative path of delete api in publisher rest API
	APIDeleteRelativePath = "api/am/publisher/v4/apis/"

	// AdminScope admin scope
	AdminScope Scope = "apim:admin"
	// ImportExportScope import export api scope
	ImportExportScope Scope = "apim:api_import_export"
	// OpenAPIDefaultYaml default open api spec yaml content
	OpenAPIDefaultYaml = `` /* 769-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func AddClientConnection

func AddClientConnection(clientID string, stream apkmgt.EventStreamService_StreamEventsServer)

AddClientConnection adds a client connection to the map

func Base64EncodeCredentials

func Base64EncodeCredentials(username, password string) string

Base64EncodeCredentials encodes the given username and password into a base64 string.

func CreateZipFile

func CreateZipFile(writer io.Writer, zipFiles []ZipFile) error

CreateZipFile creates a zip file using the provided io.Writer. It takes a slice of ZipFile structs containing information about the files to be added to the zip. Each ZipFile struct specifies the file path within the zip and its content. It returns an error if any operation fails.

func DeleteAPIRevision

func DeleteAPIRevision(apiUUID string, revisionID string, body string) error

DeleteAPIRevision deletes an API given its UUID.

func DeleteClientConnection

func DeleteClientConnection(clientID string)

DeleteClientConnection deletes a client connection from the map

func GetAllClientConnections

func GetAllClientConnections() map[string]apkmgt.EventStreamService_StreamEventsServer

GetAllClientConnections returns all client connections

func GetBasicAuthHeaderValue

func GetBasicAuthHeaderValue(username, password string) string

GetBasicAuthHeaderValue constructs and returns the Basic authentication header value using the provided username and password.

func GetSuitableAuthHeadervalue

func GetSuitableAuthHeadervalue(scopes []string) (string, error)

GetSuitableAuthHeadervalue returns an appropriate authentication header value based on whether client credentials are provided.

func GetToken

func GetToken(scopes []string, clientID string, clientSecret string) (string, error)

GetToken retrieves an OAuth token using the provided credentials and scopes.

func GetUniqueIDOfApplicationKeyMapping

func GetUniqueIDOfApplicationKeyMapping(applicationUUID string, keyType string, securityScheme string, envID string, organization string) string

GetUniqueIDOfApplicationKeyMapping returns the unique id of an application key mapping

func GetUniqueIDOfApplicationMapping

func GetUniqueIDOfApplicationMapping(applicationUUID string, subscriptionUUID string) string

GetUniqueIDOfApplicationMapping returns the unique id of an application mapping

func ImportAPI

func ImportAPI(apiZipName string, zipFileBytes *bytes.Buffer) (string, string, error)

ImportAPI imports an API from a zip file, returning the ID of the imported API.

func SendEvent

func SendEvent(event *subscription.Event)

SendEvent sends event to the common-controllers

func SendInitialEvent

func SendInitialEvent(srv apkmgt.EventStreamService_StreamEventsServer)

SendInitialEvent sends initial event to the enforcer

func SendInitialEventToAllConnectedClients

func SendInitialEventToAllConnectedClients()

SendInitialEventToAllConnectedClients sends initial event to all connected clients

Types

type Scope

type Scope string

Scope - token scope

type ZipFile

type ZipFile struct {
	Path    string
	Content string
}

ZipFile holds the content and the path of the file inside the zip folder

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL