// SetCloudCredential sets new cloud credential for this model.
// Returned bool indicates if model credential was set.
165626
func (m *Model) SetCloudCredential(tag names.CloudCredentialTag) (bool, error) {
	cloud, err := m.st.Cloud(m.Cloud())
	if err != nil {
		return false, errors.Annotatef(err, "getting cloud %q", m.Cloud())
	}
	updating := true
	buildTxn := func(attempt int) ([]txn.Op, error) {
		if attempt > 0 {
			if err := m.Refresh(); err != nil {
				return nil, errors.Trace(err)
			}
		}
		if tag.Id() == m.doc.CloudCredential {
			updating = false
			return nil, jujutxn.ErrNoOperations
		}
		// Must be a valid credential that is already on the controller.
		credential, err := m.st.CloudCredential(tag)
		if err != nil {
			return nil, errors.Trace(err)
		}
		if !credential.IsValid() {
			return nil, errors.NotValidf("credential %q", tag.Id())
		}
		if err := validateCredentialForCloud(cloud, tag, credential); err != nil {
			return nil, errors.Trace(err)
		}
		return []txn.Op{{
			C:      modelsC,
			Id:     m.doc.UUID,
			Assert: txn.DocExists,
			Update: bson.D{{"$set", bson.D{{"cloud-credential", tag.Id()}}}},
		}}, nil
	}
	if err := m.st.db().Run(buildTxn); err != nil {
		return false, errors.Trace(err)
	}
	return updating, m.Refresh()
}
997364
func (s *Authorizer) SetAuthorizerCredentials(v string) *Authorizer {
	s.AuthorizerCredentials = &v
	return s
}
248432
func (s *PutIntegrationInput) SetCredentials(v string) *PutIntegrationInput {
	s.Credentials = &v
	return s
}
943498
func (s *ListCloudFrontOriginAccessIdentitiesOutput) SetCloudFrontOriginAccessIdentityList(v *OriginAccessIdentityList) *ListCloudFrontOriginAccessIdentitiesOutput {
	s.CloudFrontOriginAccessIdentityList = v
	return s
}
112039
func (c *MemStore) UpdateCredential(cloudName string, details cloud.CloudCredential) error {
	c.mu.Lock()
	defer c.mu.Unlock()

	if len(details.AuthCredentials) > 0 {
		c.Credentials[cloudName] = details
	} else {
		delete(c.Credentials, cloudName)
	}
	return nil
}
674452
func (s *UpdateUserPoolDomainOutput) SetCloudFrontDomain(v string) *UpdateUserPoolDomainOutput {
	s.CloudFrontDomain = &v
	return s
}
993220
func (s *GetFederationTokenOutput) SetCredentials(v *Credentials) *GetFederationTokenOutput {
	s.Credentials = v
	return s
}
1142293
func (s *ModifyDBInstanceInput) SetTdeCredentialPassword(v string) *ModifyDBInstanceInput {
	s.TdeCredentialPassword = &v
	return s
}
1108443
func (s *CreateCloudFrontOriginAccessIdentityInput) SetCloudFrontOriginAccessIdentityConfig(v *OriginAccessIdentityConfig) *CreateCloudFrontOriginAccessIdentityInput {
	s.CloudFrontOriginAccessIdentityConfig = v
	return s
}
47706
func (b *backend) ModelCredential() (*ModelCredential, error) {
	m, err := b.Model()
	if err != nil {
		return nil, errors.Trace(err)
	}

	modelCredentialTag, exists := m.CloudCredential()
	result := &ModelCredential{Model: m.ModelTag(), Exists: exists}
	if !exists {
		// A model credential is not set, we must check if the model
		// is on the cloud that requires a credential.
		supportsEmptyAuth, err := b.cloudSupportsNoAuth(m.Cloud())
		if err != nil {
			return nil, errors.Trace(err)
		}
		result.Valid = supportsEmptyAuth
		if !supportsEmptyAuth {
			// TODO (anastasiamac 2018-11-12) Figure out how to notify the users here - maybe set a model status?...
			logger.Warningf("model credential is not set for the model but the cloud requires it")
		}
		return result, nil
	}

	result.Credential = modelCredentialTag
	credential, err := b.CloudCredential(modelCredentialTag)
	if err != nil {
		if !errors.IsNotFound(err) {
			return nil, errors.Trace(err)
		}
		// In this situation, a model refers to a credential that does not exist in credentials collection.
		// TODO (anastasiamac 2018-11-12) Figure out how to notify the users here - maybe set a model status?...
		logger.Warningf("cloud credential reference is set for the model but the credential content is no longer on the controller")
		result.Valid = false
		return result, nil
	}
	result.Valid = credential.IsValid()
	return result, nil
}
390305
func (s *RDSDataSpec) SetDatabaseCredentials(v *RDSDatabaseCredentials) *RDSDataSpec {
	s.DatabaseCredentials = v
	return s
}
219689
func (config *Config) SetUAAClientCredentials(client string, clientSecret string) {
	config.ConfigFile.UAAOAuthClient = client
	config.ConfigFile.UAAOAuthClientSecret = clientSecret
}
873653
func (s *CreateCustomKeyStoreInput) SetCloudHsmClusterId(v string) *CreateCustomKeyStoreInput {
	s.CloudHsmClusterId = &v
	return s
}
861121
func (s *RegistryCredential) SetCredentialProvider(v string) *RegistryCredential {
	s.CredentialProvider = &v
	return s
}
393221
func (r *ChartRepository) setCredentials() {
	if t, ok := r.Client.(*getter.HttpGetter); ok {
		t.SetCredentials(r.Config.Username, r.Config.Password)
	}
}
782189
func (p environProviderCredentials) RegisterCredentials(cld cloud.Cloud) (map[string]*cloud.CloudCredential, error) {
	cloudName := cld.Name
	if cloudName != caas.K8sCloudMicrok8s {
		return make(map[string]*cloud.CloudCredential), nil
	}
	_, cred, _, err := p.builtinCloudGetter(p.cmdRunner)

	if err != nil {
		return nil, errors.Trace(err)
	}

	return map[string]*cloud.CloudCredential{
		cloudName: {
			DefaultCredential: cloudName,
			AuthCredentials: map[string]cloud.Credential{
				cloudName: cred,
			},
		},
	}, nil
}
15967
func (s *EncryptionConfiguration) SetCloudWatchEncryption(v *CloudWatchEncryption) *EncryptionConfiguration {
	s.CloudWatchEncryption = v
	return s
}