Documentation ¶
Index ¶
- type ImageType
- type OrganizationClient
- func (c *OrganizationClient) CreateBrandingLocalization(b models.OrganizationalBrandingLocalizationable) (models.OrganizationalBrandingLocalizationable, error)
- func (c *OrganizationClient) DeleteBrandingLocalization(lid string) error
- func (c *OrganizationClient) DeleteDefaultBranding() error
- func (c *OrganizationClient) Get() (models.Organizationable, error)
- func (c *OrganizationClient) GetAll() (models.OrganizationCollectionResponseable, error)
- func (c *OrganizationClient) GetBrandingLocalization(lid string) (models.OrganizationalBrandingLocalizationable, error)
- func (c *OrganizationClient) GetDefaultBranding() (models.OrganizationalBrandingable, error)
- func (c *OrganizationClient) GetInformation() (models.TenantInformationable, error)
- func (c *OrganizationClient) NewBranding() models.OrganizationalBrandingable
- func (c *OrganizationClient) NewBrandingLocalization(lid string) models.OrganizationalBrandingLocalizationable
- func (c *OrganizationClient) Update(o models.Organizationable) (models.Organizationable, error)
- func (c *OrganizationClient) UpdateBrandingLocalization(b models.OrganizationalBrandingLocalizationable) (models.OrganizationalBrandingLocalizationable, error)
- func (c *OrganizationClient) UpdateDefaultBranding(b models.OrganizationalBrandingable) (models.OrganizationalBrandingable, error)
- func (c *OrganizationClient) UploadDefaultImage(it ImageType, body []byte) error
- func (c *OrganizationClient) UploadImage(lid string, it ImageType, body []byte) error
- type ServiceClient
- func (s *ServiceClient) AddApplicationPasswordCredentials(id, name string) (models.PasswordCredentialable, error)
- func (s *ServiceClient) Authorize(req *http.Request) error
- func (s *ServiceClient) CreateApplication(name string) (models.Applicationable, error)
- func (s *ServiceClient) CreateOrganizationClient(tid string)
- func (s *ServiceClient) CreateServicePrincipal(name string, appId string, resourceIds []string) (*string, *string, error)
- func (s *ServiceClient) DeleteKeySet(id string) error
- func (s *ServiceClient) DeletePolicies() error
- func (s *ServiceClient) DoRequest(req *http.Request) error
- func (s *ServiceClient) FindServicePrincipal(name string) bool
- func (s *ServiceClient) GenerateKey(keySetNameOrId, use, kty string) (models.TrustFrameworkKeySetable, error)
- func (s *ServiceClient) GetApplication(id string) (models.Applicationable, error)
- func (s *ServiceClient) GetKeySet(id string) (models.TrustFrameworkKeySetable, error)
- func (s *ServiceClient) GetPolicies() ([]string, error)
- func (s *ServiceClient) PatchApplication(id string, patch map[string]interface{}) (models.Applicationable, error)
- func (s *ServiceClient) Token() (*azcore.AccessToken, error)
- func (s *ServiceClient) UploadPkcs12(keySetNameOrId, certificate, password string) (models.TrustFrameworkKeySetable, error)
- func (s *ServiceClient) UploadPolicies(policies []policy.Policy) error
- func (s *ServiceClient) UploadSecret(keySetNameOrId, use, secret string) (models.TrustFrameworkKeySetable, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrganizationClient ¶ added in v0.8.0
type OrganizationClient struct {
// contains filtered or unexported fields
}
func (*OrganizationClient) CreateBrandingLocalization ¶ added in v0.8.0
func (c *OrganizationClient) CreateBrandingLocalization(b models.OrganizationalBrandingLocalizationable) (models.OrganizationalBrandingLocalizationable, error)
func (*OrganizationClient) DeleteBrandingLocalization ¶ added in v0.8.0
func (c *OrganizationClient) DeleteBrandingLocalization(lid string) error
func (*OrganizationClient) DeleteDefaultBranding ¶ added in v0.8.0
func (c *OrganizationClient) DeleteDefaultBranding() error
func (*OrganizationClient) Get ¶ added in v0.8.0
func (c *OrganizationClient) Get() (models.Organizationable, error)
func (*OrganizationClient) GetAll ¶ added in v0.8.0
func (c *OrganizationClient) GetAll() (models.OrganizationCollectionResponseable, error)
func (*OrganizationClient) GetBrandingLocalization ¶ added in v0.8.0
func (c *OrganizationClient) GetBrandingLocalization(lid string) (models.OrganizationalBrandingLocalizationable, error)
func (*OrganizationClient) GetDefaultBranding ¶ added in v0.8.0
func (c *OrganizationClient) GetDefaultBranding() (models.OrganizationalBrandingable, error)
func (*OrganizationClient) GetInformation ¶ added in v0.8.0
func (c *OrganizationClient) GetInformation() (models.TenantInformationable, error)
func (*OrganizationClient) NewBranding ¶ added in v0.8.0
func (c *OrganizationClient) NewBranding() models.OrganizationalBrandingable
func (*OrganizationClient) NewBrandingLocalization ¶ added in v0.8.0
func (c *OrganizationClient) NewBrandingLocalization(lid string) models.OrganizationalBrandingLocalizationable
func (*OrganizationClient) Update ¶ added in v0.8.0
func (c *OrganizationClient) Update(o models.Organizationable) (models.Organizationable, error)
func (*OrganizationClient) UpdateBrandingLocalization ¶ added in v0.8.0
func (c *OrganizationClient) UpdateBrandingLocalization(b models.OrganizationalBrandingLocalizationable) (models.OrganizationalBrandingLocalizationable, error)
func (*OrganizationClient) UpdateDefaultBranding ¶ added in v0.8.0
func (c *OrganizationClient) UpdateDefaultBranding(b models.OrganizationalBrandingable) (models.OrganizationalBrandingable, error)
func (*OrganizationClient) UploadDefaultImage ¶ added in v0.8.0
func (c *OrganizationClient) UploadDefaultImage(it ImageType, body []byte) error
func (*OrganizationClient) UploadImage ¶ added in v0.8.0
func (c *OrganizationClient) UploadImage(lid string, it ImageType, body []byte) error
type ServiceClient ¶
type ServiceClient struct { GraphClient *sdk.GraphServiceClient OrganizationClient *OrganizationClient // contains filtered or unexported fields }
ServiceClient is a client for interacting with a service.
func NewClientWithCredential ¶
func NewClientWithCredential(cred azcore.TokenCredential) (*ServiceClient, error)
NewClientWithCredential creates a new ServiceClient with the provided TokenCredential. It returns a pointer to the newly created ServiceClient and any error encountered.
The ServiceClient uses the provided TokenCredential for authentication and authorization. The TokenCredential must implement the azcore.TokenCredential interface.
Example usage:
cred, err := azidentity.NewClientSecretCredential(tenantID, clientID, clientSecret, authorities...) if err != nil { log.Fatal(err) } client, err := NewClientWithCredential(cred) if err != nil { log.Fatal(err) }
func (*ServiceClient) AddApplicationPasswordCredentials ¶ added in v0.10.0
func (s *ServiceClient) AddApplicationPasswordCredentials(id, name string) (models.PasswordCredentialable, error)
AddApplicationPasswordCredentials adds password credentials to the application with the specified ID. It takes the ID and name of the password credential as parameters. It returns the added password credential or an error if any.
func (*ServiceClient) Authorize ¶
func (s *ServiceClient) Authorize(req *http.Request) error
Authorize sets the Authorization header in the given *http.Request with the access token retrieved from the ServiceClient's TokenCredential. It returns an error if there is an error retrieving the token.
Example usage:
req, _ := http.NewRequest("GET", "https://api.example.com", nil) err := client.Authorize(req) if err != nil { log.Fatal(err) }
Returns:
- error: Any error encountered while getting the token
func (*ServiceClient) CreateApplication ¶ added in v0.7.0
func (s *ServiceClient) CreateApplication(name string) (models.Applicationable, error)
func (*ServiceClient) CreateOrganizationClient ¶ added in v0.8.0
func (s *ServiceClient) CreateOrganizationClient(tid string)
func (*ServiceClient) CreateServicePrincipal ¶ added in v0.7.0
func (s *ServiceClient) CreateServicePrincipal(name string, appId string, resourceIds []string) (*string, *string, error)
CreateServicePrincipal creates a service principal with the given name, appId, and resourceIds. It returns the app ID and secret password of the created service principal, or an error if any.
func (*ServiceClient) DeleteKeySet ¶
func (s *ServiceClient) DeleteKeySet(id string) error
DeleteKeySet deletes a key set with the given ID. It sends a DELETE request to the service's TrustFramework KeySets endpoint using the specified ID. The context.Background() function is used to create a new background context. The function returns an error if the DELETE request fails.
func (*ServiceClient) DeletePolicies ¶
func (s *ServiceClient) DeletePolicies() error
DeletePolicies deletes all policies from the ServiceClient. It first calls the GetPolicies method to retrieve the list of policies. If an error occurs while retrieving the policies, it returns the error. It then iterates over each policy ID and deletes the policy using the corresponding API call. If an error occurs while deleting a policy, it adds the error to a multierror and continues to the next policy. After deleting all policies, it returns nil if there were no errors.
func (*ServiceClient) DoRequest ¶
func (s *ServiceClient) DoRequest(req *http.Request) error
DoRequest sends an HTTP request and checks the response status code. It takes an *http.Request as input and returns any error encountered.
It creates an http.Client and defers the closure of idle connections. It then sends the request using the client's Do method and assigns the response to resp. If an error occurs while sending the request, it is returned.
The function defers the closure of the response body to ensure it is closed when the function returns. It reads the entire response body using io.ReadAll and assigns it to the body variable. If an error occurs while reading the response body, it is returned.
If the response status code is greater than or equal to 400, it returns an error message indicating the request failure, using the body contents as the error message.
Example usage:
req, err := http.NewRequest(http.MethodGet, "https://example.com", nil) if err != nil { log.Fatal(err) } err = client.DoRequest(req) if err != nil { log.Fatal(err) }
Returns:
- error: Any error encountered while sending the request or reading the response body
func (*ServiceClient) FindServicePrincipal ¶ added in v0.7.0
func (s *ServiceClient) FindServicePrincipal(name string) bool
FindServicePrincipal searches for a service principal with the given name. It returns true if a service principal with the specified name is found, false otherwise.
func (*ServiceClient) GenerateKey ¶
func (s *ServiceClient) GenerateKey(keySetNameOrId, use, kty string) (models.TrustFrameworkKeySetable, error)
GenerateKey generates a new key with the specified settings. It takes in the key set ID, use, and key type as parameters. It creates a request body with the specified use and key.
func (*ServiceClient) GetApplication ¶
func (s *ServiceClient) GetApplication(id string) (models.Applicationable, error)
GetApplication retrieves the application with the specified ID from the service.
func (*ServiceClient) GetKeySet ¶
func (s *ServiceClient) GetKeySet(id string) (models.TrustFrameworkKeySetable, error)
GetKeySet retrieves a trust framework key set from the service by its ID. It returns the trust framework key set object and an error, if any. Example usage:
keySet, err := service.GetKeySet("keySetId") if err != nil { // handle error } // use keySet
Parameters:
id - the ID of the trust framework key set to retrieve
Returns:
The trust framework key set object and an error, if any.
func (*ServiceClient) GetPolicies ¶
func (s *ServiceClient) GetPolicies() ([]string, error)
GetPolicies retrieves the list of policies from the ServiceClient. It returns a slice of strings, where each string represents a policy ID. If an error occurs while retrieving the policies, it returns nil and an error.
func (*ServiceClient) PatchApplication ¶
func (s *ServiceClient) PatchApplication(id string, patch map[string]interface{}) (models.Applicationable, error)
PatchApplication updates an application with the specified ID using the provided patch. It takes the ID of the application and a map containing the updates to be applied. If the patching process encounters an error, it returns an error with a descriptive message. If the request to patch the application fails, it returns an error with a descriptive message. If the patching process is successful, it returns nil.
func (*ServiceClient) Token ¶
func (s *ServiceClient) Token() (*azcore.AccessToken, error)
Token retrieves an access token from the ServiceClient's TokenCredential. It returns a pointer to the AccessToken and any error encountered.
If the ServiceClient's AccessToken is not already set, it calls the GetToken method on the TokenCredential, passing the ServiceClient's scopes as the TokenRequestOptions. If an error occurs while getting the token, it returns a nil AccessToken and an error message indicating the failure.
Example usage:
token, err := client.Token() if err != nil { log.Fatal(err) } fmt.Println("Access Token:", token.Token)
Returns:
- AccessToken: The access token retrieved from the TokenCredential
- error: Any error encountered while getting the token
func (*ServiceClient) UploadPkcs12 ¶
func (s *ServiceClient) UploadPkcs12(keySetNameOrId, certificate, password string) (models.TrustFrameworkKeySetable, error)
UploadPkcs12 uploads a PKCS12 certificate to the service for a specific trust framework key set identified by `ksId`. It takes the PKCS12 certificate and password as input.
func (*ServiceClient) UploadPolicies ¶
func (s *ServiceClient) UploadPolicies(policies []policy.Policy) error
UploadPolicies takes a slice of policy.Policy objects and uploads them to the ServiceClient. It performs the upload concurrently by launching a goroutine for each policy in the slice. The method waits for all the goroutines to finish using a sync.WaitGroup. If any errors occur during the upload, they are collected and returned as a single error using multierror.Append. The function returns nil if all the policies were uploaded successfully, or the aggregated error if any upload failed. Please note that it is important to handle and propagate the returned error appropriately in the calling code.
func (*ServiceClient) UploadSecret ¶ added in v0.9.0
func (s *ServiceClient) UploadSecret(keySetNameOrId, use, secret string) (models.TrustFrameworkKeySetable, error)